Skip to content
Snippets Groups Projects

Draft: Resolve "Implementation of new nodes creation"

Open Joan Vallvé Navarro requested to merge 454-implementation-of-new-nodes-creation into devel
1 file
+ 100
19
Compare changes
  • Side-by-side
  • Inline
@@ -39,9 +39,9 @@ namespace wolf
@@ -39,9 +39,9 @@ namespace wolf
// class CaptureBase
// class CaptureBase
class CaptureBase : public NodeStateBlocks
class CaptureBase : public NodeStateBlocks
{
{
friend FeatureBase;
friend class FeatureBase;
friend FactorBase;
friend class FactorBase;
friend FrameBase;
friend class FrameBase;
private:
private:
FrameBaseWPtr frame_ptr_;
FrameBaseWPtr frame_ptr_;
@@ -79,20 +79,39 @@ class CaptureBase : public NodeStateBlocks
@@ -79,20 +79,39 @@ class CaptureBase : public NodeStateBlocks
const PriorComposite& _state_priors = {});
const PriorComposite& _state_priors = {});
~CaptureBase() override = default;
~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;
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;
bool hasChildren() const override;
/** \brief Emplace a FactorBlockDifference with zero difference between the state _key of this capture and
/** \brief Emplace a FactorBlockDifference with zero difference between the state _key of this capture and
* _capture_origin
* _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);
virtual FactorBasePtr emplaceDriftFactor(CaptureBasePtr _capture_origin, char _key, bool _apply_loss_function);
// Type
/**
virtual bool isMotion() const
* \brief Is a motion if there is motion detected.
{
*
return false;
* \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();
bool process();
unsigned int id() const override;
unsigned int id() const override;
@@ -134,13 +153,40 @@ class CaptureBase : public NodeStateBlocks
@@ -134,13 +153,40 @@ class CaptureBase : public NodeStateBlocks
void fix() override;
void fix() override;
void unfix() override;
void unfix() override;
void move(FrameBasePtr);
/** \brief Move the capture to a new frame
void link(FrameBasePtr);
*
 
* \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();
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>
template <typename classType, typename... T>
static std::shared_ptr<classType> emplace(FrameBasePtr _frm_ptr, T&&... all);
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,
virtual void printHeader(int depth,
bool factored_by,
bool factored_by,
bool metric,
bool metric,
@@ -148,6 +194,15 @@ class CaptureBase : public NodeStateBlocks
@@ -148,6 +194,15 @@ class CaptureBase : public NodeStateBlocks
std::ostream& stream,
std::ostream& stream,
std::string _tabs = "") const;
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,
void print(int depth,
bool factored_by,
bool factored_by,
bool metric,
bool metric,
@@ -155,22 +210,32 @@ class CaptureBase : public NodeStateBlocks
@@ -155,22 +210,32 @@ class CaptureBase : public NodeStateBlocks
std::ostream& stream = std::cout,
std::ostream& stream = std::cout,
std::string _tabs = "") const;
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;
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:
private:
FeatureBasePtr addFeature(FeatureBasePtr _ft_ptr);
FeatureBasePtr addFeature(FeatureBasePtr _ft_ptr);
void removeFeature(FeatureBasePtr _ft_ptr);
void removeFeature(FeatureBasePtr _ft_ptr);
public:
public:
CaptureBasePtr shared_from_this_capture()
CaptureBasePtr shared_from_this_capture();
{
CaptureBaseConstPtr shared_from_this_capture() const;
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());
};
};
};
} // namespace wolf
} // namespace wolf
@@ -182,6 +247,12 @@ class CaptureBase : public NodeStateBlocks
@@ -182,6 +247,12 @@ class CaptureBase : public NodeStateBlocks
namespace wolf
namespace wolf
{
{
 
 
inline bool CaptureBase::isMotion() const
 
{
 
return false;
 
}
 
template <typename classType, typename... T>
template <typename classType, typename... T>
std::shared_ptr<classType> CaptureBase::emplace(FrameBasePtr _frm_ptr, T&&... all)
std::shared_ptr<classType> CaptureBase::emplace(FrameBasePtr _frm_ptr, T&&... all)
{
{
@@ -289,4 +360,14 @@ inline void CaptureBase::setTimeStampToNow()
@@ -289,4 +360,14 @@ inline void CaptureBase::setTimeStampToNow()
time_stamp_.setToNow();
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
} // namespace wolf
Loading