From 29e975c76cbfa0e6fd35cfcf42d15883fc905278 Mon Sep 17 00:00:00 2001 From: joanvallve <jvallve@iri.upc.edu> Date: Fri, 11 Dec 2015 15:35:54 +0100 Subject: [PATCH] added the recommendation of not using delete and use destruct() instead, in documentation of all classes. --- src/capture_base.h | 6 ++++++ src/capture_fix.h | 5 +++++ src/capture_gps.h | 6 +++++- src/capture_gps_fix.h | 5 +++++ src/capture_laser_2D.h | 8 ++++---- src/capture_motion.h | 5 +++++ src/capture_odom_2D.h | 7 ++++++- src/capture_void.h | 5 +++++ src/constraint_base.cpp | 6 ------ src/constraint_base.h | 13 +++---------- src/constraint_container.h | 7 ++++++- src/constraint_corner_2D.h | 7 ++++++- src/constraint_fix.h | 7 ++++++- src/constraint_gps_2D.h | 7 ++++++- src/constraint_gps_pseudorange.h | 5 +++++ src/constraint_odom_2D.h | 5 +++++ src/constraint_sparse.h | 6 +++--- src/examples/test_wolf_imported_graph.cpp | 2 +- src/feature_base.h | 4 ++-- src/feature_corner_2D.h | 6 +++--- src/feature_fix.h | 5 +++++ src/feature_gps_fix.h | 5 +++++ src/feature_gps_pseudorange.h | 5 +++++ src/feature_odom_2D.h | 5 +++++ src/frame_base.cpp | 6 ------ src/frame_base.h | 15 ++++----------- src/hardware_base.h | 4 ++-- src/landmark_base.cpp | 6 ------ src/landmark_base.h | 11 ++--------- src/landmark_container.h | 6 +++--- src/landmark_corner_2D.h | 8 ++++---- src/map_base.h | 4 ++-- src/node_linked.h | 4 ++-- src/sensor_base.h | 5 +++++ src/sensor_gps.h | 5 +++++ src/sensor_gps_fix.h | 8 ++++---- src/sensor_laser_2D.h | 6 +++--- src/sensor_odom_2D.h | 8 ++++---- src/trajectory_base.h | 4 ++-- src/wolf_manager.cpp | 2 +- src/wolf_problem.cpp | 7 ++++++- src/wolf_problem.h | 11 +++++++++-- 42 files changed, 165 insertions(+), 97 deletions(-) diff --git a/src/capture_base.h b/src/capture_base.h index cd195be7f..ac99b54e9 100644 --- a/src/capture_base.h +++ b/src/capture_base.h @@ -38,6 +38,12 @@ class CaptureBase : public NodeLinked<FrameBase, FeatureBase> CaptureBase(const TimeStamp& _ts, SensorBase* _sensor_ptr, const Eigen::VectorXs& _data, const Eigen::MatrixXs& _data_covariance); + + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~CaptureBase(); /** \brief Set link to Frame diff --git a/src/capture_fix.h b/src/capture_fix.h index 103f9452e..984abf00c 100644 --- a/src/capture_fix.h +++ b/src/capture_fix.h @@ -16,6 +16,11 @@ class CaptureFix : public CaptureBase CaptureFix(const TimeStamp& _ts, SensorBase* _sensor_ptr, const Eigen::VectorXs& _data, const Eigen::MatrixXs& _data_covariance); + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~CaptureFix(); virtual void processCapture(); diff --git a/src/capture_gps.h b/src/capture_gps.h index 4aa9d3c96..ca9be411b 100644 --- a/src/capture_gps.h +++ b/src/capture_gps.h @@ -40,7 +40,11 @@ public: CaptureGPS(const TimeStamp& _ts, SensorBase* _sensor_ptr, const Eigen::VectorXs& _raw_data); - + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~CaptureGPS(); void processCapture(); diff --git a/src/capture_gps_fix.h b/src/capture_gps_fix.h index 1a17154a4..2f8ebd4dd 100644 --- a/src/capture_gps_fix.h +++ b/src/capture_gps_fix.h @@ -18,6 +18,11 @@ class CaptureGPSFix : public CaptureBase CaptureGPSFix(const TimeStamp& _ts, SensorBase* _sensor_ptr, const Eigen::VectorXs& _data, const Eigen::MatrixXs& _data_covariance); + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~CaptureGPSFix(); virtual void processCapture(); diff --git a/src/capture_laser_2D.h b/src/capture_laser_2D.h index 95c402510..babf6c1cd 100644 --- a/src/capture_laser_2D.h +++ b/src/capture_laser_2D.h @@ -69,10 +69,10 @@ class CaptureLaser2D : public CaptureBase **/ CaptureLaser2D(const TimeStamp & _ts, SensorBase* _sensor_ptr, const std::vector<float>& _ranges, const std::vector<float>& _intensities); - /** \brief Destructor - * - * Destructor - * + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * **/ virtual ~CaptureLaser2D(); diff --git a/src/capture_motion.h b/src/capture_motion.h index d27227232..e62f91e4f 100644 --- a/src/capture_motion.h +++ b/src/capture_motion.h @@ -22,6 +22,11 @@ class CaptureMotion : public CaptureBase CaptureMotion(const TimeStamp& _init_ts, const TimeStamp& _final_ts, SensorBase* _sensor_ptr, const Eigen::VectorXs& _data, const Eigen::MatrixXs& _data_covariance); + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~CaptureMotion(); virtual void integrateCapture(CaptureMotion* _new_capture) = 0; diff --git a/src/capture_odom_2D.h b/src/capture_odom_2D.h index d53d8677e..c3a5d8c9b 100644 --- a/src/capture_odom_2D.h +++ b/src/capture_odom_2D.h @@ -20,7 +20,12 @@ class CaptureOdom2D : public CaptureMotion CaptureOdom2D(const TimeStamp& _init_ts, const TimeStamp& _final_ts, SensorBase* _sensor_ptr, const Eigen::Vector3s& _data); CaptureOdom2D(const TimeStamp& _init_ts, const TimeStamp& _final_ts, SensorBase* _sensor_ptr, const Eigen::Vector3s& _data, const Eigen::Matrix3s& _data_covariance); - + + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~CaptureOdom2D(); virtual void processCapture(); diff --git a/src/capture_void.h b/src/capture_void.h index da96557eb..1de4522e5 100644 --- a/src/capture_void.h +++ b/src/capture_void.h @@ -10,6 +10,11 @@ class CaptureVoid : public CaptureBase public: CaptureVoid(const TimeStamp& _ts, SensorBase* _sensor_ptr); + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~CaptureVoid(); virtual Eigen::VectorXs computePrior(const TimeStamp& _now) const; diff --git a/src/constraint_base.cpp b/src/constraint_base.cpp index 31d31c97c..b3110fcff 100644 --- a/src/constraint_base.cpp +++ b/src/constraint_base.cpp @@ -70,12 +70,6 @@ ConstraintBase::~ConstraintBase() landmark_ptr_->removeConstraintTo(this); } -//void ConstraintBase::destruct() -//{ -// if (!is_deleting_) -// up_node_ptr_->removeDownNode(this); -//} - ConstraintType ConstraintBase::getType() const { return type_; diff --git a/src/constraint_base.h b/src/constraint_base.h index c59fd6413..fa41df4eb 100644 --- a/src/constraint_base.h +++ b/src/constraint_base.h @@ -55,20 +55,13 @@ class ConstraintBase : public NodeLinked<FeatureBase, NodeTerminus> **/ ConstraintBase(ConstraintType _tp, LandmarkBase* _landmark_ptr, ConstraintStatus _status); - /** \brief Destructor - * - * Destructor + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * **/ virtual ~ConstraintBase(); - /** \brief Destructor call if is not already deleting - * - * Destructor call if is not already deleting - * - */ - //virtual void destruct(); - /** \brief Returns the constraint type * * Returns the constraint type diff --git a/src/constraint_container.h b/src/constraint_container.h index bfedc48f3..dd45e22fc 100644 --- a/src/constraint_container.h +++ b/src/constraint_container.h @@ -23,7 +23,12 @@ class ConstraintContainer: public ConstraintSparse<3,2,1,2,1> assert(_corner >= 0 && _corner <= 3 && "Wrong corner id in constraint container constructor"); lmk_ptr_->addConstraintTo(this); } - + + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~ConstraintContainer() { //std::cout << "deleting ConstraintContainer " << nodeId() << std::endl; diff --git a/src/constraint_corner_2D.h b/src/constraint_corner_2D.h index 9f5c2c478..d603f9165 100644 --- a/src/constraint_corner_2D.h +++ b/src/constraint_corner_2D.h @@ -16,7 +16,12 @@ class ConstraintCorner2D: public ConstraintSparse<3,2,1,2,1> { landmark_ptr_->addConstraintTo(this); } - + + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~ConstraintCorner2D() { //std::cout << "deleting ConstraintCorner2D " << nodeId() << std::endl; diff --git a/src/constraint_fix.h b/src/constraint_fix.h index a254a9d81..fef49f4b9 100644 --- a/src/constraint_fix.h +++ b/src/constraint_fix.h @@ -16,7 +16,12 @@ class ConstraintFix: public ConstraintSparse<3,2,1> { //std::cout << "creating ConstraintFix " << std::endl; } - + + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~ConstraintFix() { // diff --git a/src/constraint_gps_2D.h b/src/constraint_gps_2D.h index 777496bda..074093005 100644 --- a/src/constraint_gps_2D.h +++ b/src/constraint_gps_2D.h @@ -16,7 +16,12 @@ class ConstraintGPS2D: public ConstraintSparse<2,2> { // } - + + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~ConstraintGPS2D() { // diff --git a/src/constraint_gps_pseudorange.h b/src/constraint_gps_pseudorange.h index 8a8b1e232..afb698c08 100644 --- a/src/constraint_gps_pseudorange.h +++ b/src/constraint_gps_pseudorange.h @@ -26,6 +26,11 @@ public: createConstraint((FeatureGPSPseudorange*) _ftr_ptr); } + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~ConstraintGPSPseudorange() { diff --git a/src/constraint_odom_2D.h b/src/constraint_odom_2D.h index 69fc4f1f4..312d55c3e 100644 --- a/src/constraint_odom_2D.h +++ b/src/constraint_odom_2D.h @@ -16,6 +16,11 @@ class ConstraintOdom2D : public ConstraintSparse<3, 2, 1, 2, 1> // } + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~ConstraintOdom2D() { // diff --git a/src/constraint_sparse.h b/src/constraint_sparse.h index a00aa5bf4..e1918b355 100644 --- a/src/constraint_sparse.h +++ b/src/constraint_sparse.h @@ -106,9 +106,9 @@ class ConstraintSparse: public ConstraintBase StateBlock* _state8Ptr = nullptr, StateBlock* _state9Ptr = nullptr ) ; - /** \brief Destructor - * - * Destructor + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * **/ virtual ~ConstraintSparse(); diff --git a/src/examples/test_wolf_imported_graph.cpp b/src/examples/test_wolf_imported_graph.cpp index 41f1f79f2..33380ff31 100644 --- a/src/examples/test_wolf_imported_graph.cpp +++ b/src/examples/test_wolf_imported_graph.cpp @@ -48,7 +48,7 @@ int main(int argc, char** argv) unsigned int MAX_VERTEX = atoi(argv[2]); if (MAX_VERTEX == 0) MAX_VERTEX = 1e6; std::ifstream offLineFile_; - clock_t t1, t2; + clock_t t1; ceres::Solver::Summary summary_full, summary_prun; Eigen::MatrixXs Sigma_ii(3,3), Sigma_ij(3,3), Sigma_jj(3,3), Sigma_z(3,3), Ji(3,3), Jj(3,3); WolfScalar xi, yi, thi, si, ci, xj, yj; diff --git a/src/feature_base.h b/src/feature_base.h index d541679b2..fd41174bb 100644 --- a/src/feature_base.h +++ b/src/feature_base.h @@ -37,9 +37,9 @@ class FeatureBase : public NodeLinked<CaptureBase,ConstraintBase> */ FeatureBase(const Eigen::VectorXs& _measurement, const Eigen::MatrixXs& _meas_covariance); - /** \brief Destructor + /** \brief Default destructor (not recommended) * - * Destructor + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * */ virtual ~FeatureBase(); diff --git a/src/feature_corner_2D.h b/src/feature_corner_2D.h index 5de276c47..8c9cd7a76 100644 --- a/src/feature_corner_2D.h +++ b/src/feature_corner_2D.h @@ -17,9 +17,9 @@ class FeatureCorner2D : public FeatureBase */ FeatureCorner2D(const Eigen::Vector4s & _measurement, const Eigen::Matrix4s & _meas_covariance); //TODO: add const WolfScalar& aperture); - /** \brief Destructor - * - * destructor + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * */ virtual ~FeatureCorner2D(); diff --git a/src/feature_fix.h b/src/feature_fix.h index 122d816fe..8d1bf068b 100644 --- a/src/feature_fix.h +++ b/src/feature_fix.h @@ -19,6 +19,11 @@ class FeatureFix : public FeatureBase */ FeatureFix(const Eigen::VectorXs& _measurement, const Eigen::MatrixXs& _meas_covariance); + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~FeatureFix(); }; #endif diff --git a/src/feature_gps_fix.h b/src/feature_gps_fix.h index 9e7228548..e59982f20 100644 --- a/src/feature_gps_fix.h +++ b/src/feature_gps_fix.h @@ -26,6 +26,11 @@ class FeatureGPSFix : public FeatureBase */ FeatureGPSFix(const Eigen::VectorXs& _measurement, const Eigen::MatrixXs& _meas_covariance); + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~FeatureGPSFix(); }; #endif diff --git a/src/feature_gps_pseudorange.h b/src/feature_gps_pseudorange.h index 97a614e89..891ef0643 100644 --- a/src/feature_gps_pseudorange.h +++ b/src/feature_gps_pseudorange.h @@ -43,6 +43,11 @@ public: FeatureGPSPseudorange(const WolfScalar &_satellite_data); + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~FeatureGPSPseudorange(); diff --git a/src/feature_odom_2D.h b/src/feature_odom_2D.h index b220c8b3c..d8ba3a6aa 100644 --- a/src/feature_odom_2D.h +++ b/src/feature_odom_2D.h @@ -26,6 +26,11 @@ class FeatureOdom2D : public FeatureBase */ FeatureOdom2D(const Eigen::VectorXs& _measurement, const Eigen::MatrixXs& _meas_covariance); + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~FeatureOdom2D(); /** \brief Generic interface to find constraints diff --git a/src/frame_base.cpp b/src/frame_base.cpp index 4a717f7bb..d3ae71cb3 100644 --- a/src/frame_base.cpp +++ b/src/frame_base.cpp @@ -51,12 +51,6 @@ FrameBase::~FrameBase() //std::cout << "constraints deleted" << std::endl; } -//void FrameBase::destruct() -//{ -// if (!is_deleting_) -// up_node_ptr_->removeDownNode(this); -//} - void FrameBase::addConstraintTo(ConstraintBase* _ctr_ptr) { constraint_to_list_.push_back(_ctr_ptr); diff --git a/src/frame_base.h b/src/frame_base.h index 71d596a53..7c6972697 100644 --- a/src/frame_base.h +++ b/src/frame_base.h @@ -52,21 +52,14 @@ class FrameBase : public NodeLinked<TrajectoryBase,CaptureBase> * **/ FrameBase(const FrameType & _tp, const TimeStamp& _ts, StateBlock* _p_ptr, StateBlock* _o_ptr = nullptr); - - /** \brief Destructor - * - * Destructor + + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * **/ virtual ~FrameBase(); - /** \brief Destructor call if is not already deleting - * - * Destructor call if is not already deleting - * - */ - //virtual void destruct(); - /** \brief Link with a constraint * * Link with a constraint diff --git a/src/hardware_base.h b/src/hardware_base.h index 99556845d..b5868996b 100644 --- a/src/hardware_base.h +++ b/src/hardware_base.h @@ -20,9 +20,9 @@ class HardwareBase : public NodeLinked<WolfProblem,SensorBase> **/ HardwareBase(); - /** \brief Destructor + /** \brief Default destructor (not recommended) * - * Destructor + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * **/ ~HardwareBase(); diff --git a/src/landmark_base.cpp b/src/landmark_base.cpp index a52f79cc6..de4fea69e 100644 --- a/src/landmark_base.cpp +++ b/src/landmark_base.cpp @@ -39,12 +39,6 @@ LandmarkBase::~LandmarkBase() //std::cout << "constraints deleted" << std::endl; } -//void LandmarkBase::destruct() -//{ -// if (!is_deleting_) -// up_node_ptr_->removeDownNode(this); -//} - void LandmarkBase::addConstraintTo(ConstraintBase* _ctr_ptr) { constraint_to_list_.push_back(_ctr_ptr); diff --git a/src/landmark_base.h b/src/landmark_base.h index de18a044a..4b73d8dbd 100644 --- a/src/landmark_base.h +++ b/src/landmark_base.h @@ -45,20 +45,13 @@ class LandmarkBase : public NodeLinked<MapBase, NodeTerminus> **/ LandmarkBase(const LandmarkType & _tp, StateBlock* _p_ptr, StateBlock* _o_ptr = nullptr); - /** \brief Destructor + /** \brief Default destructor (not recommended) * - * Destructor + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * **/ virtual ~LandmarkBase(); - /** \brief Destructor call if is not already deleting - * - * Destructor call if is not already deleting - * - */ - //virtual void destruct(); - /** \brief Link with a constraint * * Link with a constraint diff --git a/src/landmark_container.h b/src/landmark_container.h index d02b3158a..46f766f02 100644 --- a/src/landmark_container.h +++ b/src/landmark_container.h @@ -62,9 +62,9 @@ class LandmarkContainer : public LandmarkBase **/ LandmarkContainer(StateBlock* _p_ptr, StateBlock* _o_ptr, LandmarkCorner2D* _corner_A_ptr, LandmarkCorner2D* _corner_B_ptr, LandmarkCorner2D* _corner_C_ptr, LandmarkCorner2D* _corner_D_ptr, const WolfScalar& _witdh=2.44, const WolfScalar& _length=12.2); - /** \brief Destructor - * - * Destructor + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * **/ virtual ~LandmarkContainer(); diff --git a/src/landmark_corner_2D.h b/src/landmark_corner_2D.h index 5e3e7d240..0707edbe5 100644 --- a/src/landmark_corner_2D.h +++ b/src/landmark_corner_2D.h @@ -28,10 +28,10 @@ class LandmarkCorner2D : public LandmarkBase * **/ LandmarkCorner2D(StateBlock* _p_ptr, StateBlock* _o_ptr, const WolfScalar& _aperture=0); - - /** \brief Destructor - * - * Destructor + + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * **/ virtual ~LandmarkCorner2D(); diff --git a/src/map_base.h b/src/map_base.h index 2acbb034a..d65a628c4 100644 --- a/src/map_base.h +++ b/src/map_base.h @@ -30,9 +30,9 @@ class MapBase : public NodeLinked<WolfProblem,LandmarkBase> **/ MapBase(); - /** \brief Destructor + /** \brief Default destructor (not recommended) * - * Destructor + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * **/ ~MapBase(); diff --git a/src/node_linked.h b/src/node_linked.h index 16b0c150e..28e2de3c5 100644 --- a/src/node_linked.h +++ b/src/node_linked.h @@ -58,9 +58,9 @@ class NodeLinked : public NodeBase */ NodeLinked(const NodeLocation _loc, const std::string& _label); - /** \brief Default destructor + /** \brief Default destructor (not recommended) * - * Default destructor + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * */ virtual ~NodeLinked(); diff --git a/src/sensor_base.h b/src/sensor_base.h index 507fc6330..399691b06 100644 --- a/src/sensor_base.h +++ b/src/sensor_base.h @@ -61,6 +61,11 @@ class SensorBase : public NodeLinked<HardwareBase,NodeTerminus> // **/ // SensorBase(const SensorType & _tp, StateBlock* _p_ptr, StateBlock* _o_ptr, unsigned int _params_size, const bool _extr_dyn = false); + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~SensorBase(); // const SensorType getSensorType() const; diff --git a/src/sensor_gps.h b/src/sensor_gps.h index 7222413ff..ca459c1f9 100644 --- a/src/sensor_gps.h +++ b/src/sensor_gps.h @@ -29,6 +29,11 @@ public: //pointer to sensor position and orientation. SensorGPS(StateBlock *_p_ptr, StateBlock *_o_ptr, StateBlock* _bias_ptr); + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) + * + **/ virtual ~SensorGPS(); diff --git a/src/sensor_gps_fix.h b/src/sensor_gps_fix.h index 2a45bf05c..8a300fbe9 100644 --- a/src/sensor_gps_fix.h +++ b/src/sensor_gps_fix.h @@ -17,10 +17,10 @@ class SensorGPSFix : public SensorBase * **/ SensorGPSFix(StateBlock* _p_ptr, StateBlock* _o_ptr, const double& _noise); - - /** \brief Destructor - * - * Destructor + + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * **/ virtual ~SensorGPSFix(); diff --git a/src/sensor_laser_2D.h b/src/sensor_laser_2D.h index 076648fda..8ab58ee48 100644 --- a/src/sensor_laser_2D.h +++ b/src/sensor_laser_2D.h @@ -31,9 +31,9 @@ class SensorLaser2D : public SensorBase SensorLaser2D(StateBlock* _p_ptr, StateBlock* _o_ptr); //SensorLaser2D(const Eigen::VectorXs & _sp, const laserscanutils::ScanParams & _params); - /** \brief Destructor - * - * Destructor + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * **/ virtual ~SensorLaser2D(); diff --git a/src/sensor_odom_2D.h b/src/sensor_odom_2D.h index 65be03c8c..e823f9398 100644 --- a/src/sensor_odom_2D.h +++ b/src/sensor_odom_2D.h @@ -19,10 +19,10 @@ class SensorOdom2D : public SensorBase * **/ SensorOdom2D(StateBlock* _p_ptr, StateBlock* _o_ptr, const WolfScalar& _disp_noise_factor, const WolfScalar& _rot_noise_factor); - - /** \brief Destructor - * - * Destructor + + /** \brief Default destructor (not recommended) + * + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * **/ virtual ~SensorOdom2D(); diff --git a/src/trajectory_base.h b/src/trajectory_base.h index c041bcd89..5f191ddc2 100644 --- a/src/trajectory_base.h +++ b/src/trajectory_base.h @@ -35,9 +35,9 @@ class TrajectoryBase : public NodeLinked<WolfProblem,FrameBase> **/ TrajectoryBase(); - /** \brief Destructor + /** \brief Default destructor (not recommended) * - * Destructor + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * **/ ~TrajectoryBase(); diff --git a/src/wolf_manager.cpp b/src/wolf_manager.cpp index e905ef397..66f182717 100644 --- a/src/wolf_manager.cpp +++ b/src/wolf_manager.cpp @@ -51,7 +51,7 @@ WolfManager::WolfManager(const FrameStructure _frame_structure, WolfManager::~WolfManager() { - std::cout << "deleting wolf manager..." << std::endl; + //std::cout << "deleting wolf manager..." << std::endl; delete problem_; } diff --git a/src/wolf_problem.cpp b/src/wolf_problem.cpp index c185cfe31..61cc63d5f 100644 --- a/src/wolf_problem.cpp +++ b/src/wolf_problem.cpp @@ -26,7 +26,7 @@ WolfProblem::WolfProblem(TrajectoryBase* _trajectory_ptr, MapBase* _map_ptr, Har WolfProblem::~WolfProblem() { - std::cout << "deleting wolf problem " << nodeId() << std::endl; + //std::cout << "deleting wolf problem " << nodeId() << std::endl; state_block_add_list_.clear(); covariances_.clear(); state_block_update_list_.clear(); @@ -39,6 +39,11 @@ WolfProblem::~WolfProblem() hardware_ptr_->destruct(); } +void WolfProblem::destruct() +{ + delete this; +} + void WolfProblem::addStateBlockPtr(StateBlock* _state_ptr) { // add the state unit to the list diff --git a/src/wolf_problem.h b/src/wolf_problem.h index e2b4fb949..8c632c8fd 100644 --- a/src/wolf_problem.h +++ b/src/wolf_problem.h @@ -55,13 +55,20 @@ class WolfProblem: public NodeBase */ WolfProblem(TrajectoryBase* _trajectory_ptr, MapBase* _map_ptr=nullptr, HardwareBase* _hardware_ptr=nullptr); - /** \brief Default destructor + /** \brief Default destructor (not recommended) * - * Default destructor + * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * */ virtual ~WolfProblem(); + /** \brief Wolf destructor + * + * Wolf destructor (please use it instead of delete for guaranteeing the wolf tree integrity) + * + */ + virtual void destruct() final; + /** \brief Adds a new state block to be added to solver manager * * Adds a new state block to be added to solver manager -- GitLab