diff --git a/include/core/capture/capture_base.h b/include/core/capture/capture_base.h index 33fefbac329798f889965f8dc40084ae0351b2cf..c575674dbbc5e926c9666f34b85397e202900529 100644 --- a/include/core/capture/capture_base.h +++ b/include/core/capture/capture_base.h @@ -39,9 +39,9 @@ namespace wolf // class CaptureBase class CaptureBase : public NodeStateBlocks { - friend FeatureBase; - friend FactorBase; - friend FrameBase; + friend class FeatureBase; + friend class FactorBase; + friend class FrameBase; private: FrameBaseWPtr frame_ptr_; @@ -79,20 +79,39 @@ class CaptureBase : public NodeStateBlocks const PriorComposite& _state_priors = {}); ~CaptureBase() override = default; + + /** \brief Remove the capture + * + * \param viral_remove_parent_without_children If true, removes the parent if it has no other children. + */ void remove(bool viral_remove_parent_without_children = false) override; + + /** \brief Check if the capture has any children + * + * \return true if the capture has children, false otherwise + */ bool hasChildren() const override; /** \brief Emplace a FactorBlockDifference with zero difference between the state _key of this capture and * _capture_origin + * + * \param _capture_origin The origin capture to add the factor drift. + * \param _key The key of the state to be factored. + * \param _apply_loss_function Whether to apply a loss function to the factor. */ virtual FactorBasePtr emplaceDriftFactor(CaptureBasePtr _capture_origin, char _key, bool _apply_loss_function); - // Type - virtual bool isMotion() const - { - return false; - } + /** + * \brief Is a motion if there is motion detected. + * + * \return true if the capture is of type motion, false otherwise. + */ + virtual bool isMotion() const; + /** \brief Process the capture + * + * \return true if the process is successful, false otherwise + */ bool process(); unsigned int id() const override; @@ -134,13 +153,40 @@ class CaptureBase : public NodeStateBlocks void fix() override; void unfix() override; - void move(FrameBasePtr); - void link(FrameBasePtr); + /** \brief Move the capture to a new frame + * + * \param _frm_ptr Pointer to the new frame. + */ + void move(FrameBasePtr _frm_ptr); + + /** \brief Link the capture to a frame + * + * \param _frm_ptr Pointer to the frame. + */ + void link(FrameBasePtr _frm_ptr); + + /** \brief Unlink the capture from its current frame + */ void unlink(); + /** \brief Emplace a new capture of type classType + * + * \param _frm_ptr Pointer to the frame to link the new capture to. + * \param all Variadic template arguments to forward to the constructor of classType. + * \return A shared pointer to the newly created capture. + */ template <typename classType, typename... T> static std::shared_ptr<classType> emplace(FrameBasePtr _frm_ptr, T&&... all); + /** \brief Print the header information of the capture + * + * \param depth The depth of the header. + * \param factored_by Whether to include factors in the print. + * \param metric Whether to print metric information. + * \param state_blocks Whether to print state blocks information. + * \param stream The output stream to print to. + * \param _tabs The tabs to use for indentation. + */ virtual void printHeader(int depth, bool factored_by, bool metric, @@ -148,6 +194,15 @@ class CaptureBase : public NodeStateBlocks std::ostream& stream, std::string _tabs = "") const; + /** \brief Print the capture details + * + * \param depth The depth of the print. + * \param factored_by Whether to include factors in the print. + * \param metric Whether to include metric information. + * \param state_blocks Whether to include state blocks. + * \param stream The output stream to print to. + * \param _tabs The tabs to use for indentation. + */ void print(int depth, bool factored_by, bool metric, @@ -155,22 +210,32 @@ class CaptureBase : public NodeStateBlocks std::ostream& stream = std::cout, std::string _tabs = "") const; + /** \brief Perform a local check on the capture + * + * \param _verbose Whether to print verbose output. + * \param _stream The output stream to print to. + * \param _tabs The tabs to use for indentation. + * \return A CheckLog object containing the results of the check. + */ virtual CheckLog localCheck(bool _verbose, std::ostream& _stream, std::string _tabs = "") const; - bool check(CheckLog& _log, bool _verbose, std::ostream& _stream, std::string _tabs = "") const; + + /** \brief Check the capture + * + * \param _log The log to store check results. + * \param _verbose Whether to enable verbose output. + * \param _stream The output stream to print to. + * \param _tabs The tabs to use for indentation. + * \return true if the check is successful, false otherwise + */ + bool check(CheckLog& _log, bool _verbose, std::ostream& _stream, std::string _tabs = "") const; private: FeatureBasePtr addFeature(FeatureBasePtr _ft_ptr); void removeFeature(FeatureBasePtr _ft_ptr); public: - CaptureBasePtr shared_from_this_capture() - { - return std::static_pointer_cast<CaptureBase>(shared_from_this()); - }; - CaptureBaseConstPtr shared_from_this_capture() const - { - return std::static_pointer_cast<const CaptureBase>(shared_from_this()); - }; + CaptureBasePtr shared_from_this_capture(); + CaptureBaseConstPtr shared_from_this_capture() const; }; } // namespace wolf @@ -182,6 +247,12 @@ class CaptureBase : public NodeStateBlocks namespace wolf { + +inline bool CaptureBase::isMotion() const +{ + return false; +} + template <typename classType, typename... T> std::shared_ptr<classType> CaptureBase::emplace(FrameBasePtr _frm_ptr, T&&... all) { @@ -289,4 +360,14 @@ inline void CaptureBase::setTimeStampToNow() time_stamp_.setToNow(); } +inline CaptureBasePtr CaptureBase::shared_from_this_capture() +{ + return std::static_pointer_cast<CaptureBase>(shared_from_this()); +} + +inline CaptureBaseConstPtr CaptureBase::shared_from_this_capture() const +{ + return std::static_pointer_cast<const CaptureBase>(shared_from_this()); +} + } // namespace wolf