Skip to content
Snippets Groups Projects
Commit 48fb8128 authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

frameBase::getCapturesOfType of specific type

parent 9e7a92f7
No related branches found
No related tags found
1 merge request!466devel->main
...@@ -139,17 +139,17 @@ class FrameBase : public NodeBase, public HasStateBlocks, public std::enable_sha ...@@ -139,17 +139,17 @@ class FrameBase : public NodeBase, public HasStateBlocks, public std::enable_sha
bool isConstrainedBy(const FactorBaseConstPtr& _factor) const; bool isConstrainedBy(const FactorBaseConstPtr& _factor) const;
template <class C> template <class C>
CaptureBaseConstPtr getCaptureOfType() const; std::shared_ptr<const C> getCaptureOfType() const;
template <class C> template <class C>
CaptureBasePtr getCaptureOfType(); std::shared_ptr<C> getCaptureOfType();
CaptureBaseConstPtr getCaptureOfType(const std::string& type) const; CaptureBaseConstPtr getCaptureOfType(const std::string& type) const;
CaptureBasePtr getCaptureOfType(const std::string& type); CaptureBasePtr getCaptureOfType(const std::string& type);
template <class C> template <class C>
CaptureBaseConstPtrList getCapturesOfType() const; std::list<std::shared_ptr<const C>> getCapturesOfType() const;
template <class C> template <class C>
CaptureBasePtrList getCapturesOfType(); std::list<std::shared_ptr<C>> getCapturesOfType();
CaptureBaseConstPtrList getCapturesOfType(const std::string& type) const; CaptureBaseConstPtrList getCapturesOfType(const std::string& type) const;
CaptureBasePtrList getCapturesOfType(const std::string& type); CaptureBasePtrList getCapturesOfType(const std::string& type);
...@@ -290,40 +290,52 @@ inline void FrameBase::setTrajectory(TrajectoryBasePtr _trj_ptr) ...@@ -290,40 +290,52 @@ inline void FrameBase::setTrajectory(TrajectoryBasePtr _trj_ptr)
} }
template <class C> template <class C>
inline CaptureBaseConstPtr FrameBase::getCaptureOfType() const inline std::shared_ptr<const C> FrameBase::getCaptureOfType() const
{ {
for (auto capture_ptr : getCaptureList()) for (auto capture_ptr : getCaptureList())
if (std::dynamic_pointer_cast<C>(capture_ptr) != nullptr) {
auto cap_derived = std::dynamic_pointer_cast<C>(capture_ptr);
if (cap_derived)
return capture_ptr; return capture_ptr;
}
return nullptr; return nullptr;
} }
template <class C> template <class C>
inline CaptureBasePtr FrameBase::getCaptureOfType() inline std::shared_ptr<C> FrameBase::getCaptureOfType()
{ {
for (auto capture_ptr : getCaptureList()) for (auto capture_ptr : getCaptureList())
if (std::dynamic_pointer_cast<C>(capture_ptr) != nullptr) {
auto cap_derived = std::dynamic_pointer_cast<C>(capture_ptr);
if (cap_derived)
return capture_ptr; return capture_ptr;
}
return nullptr; return nullptr;
} }
template <class C> template <class C>
inline CaptureBaseConstPtrList FrameBase::getCapturesOfType() const inline std::list<std::shared_ptr<const C>> FrameBase::getCapturesOfType() const
{ {
CaptureBaseConstPtrList captures; std::list<std::shared_ptr<const C>> captures;
for (auto capture_ptr : getCaptureList()) for (auto capture_ptr : getCaptureList())
if (std::dynamic_pointer_cast<C>(capture_ptr) != nullptr) {
auto cap_derived = std::dynamic_pointer_cast<C>(capture_ptr);
if (cap_derived)
captures.push_back(capture_ptr); captures.push_back(capture_ptr);
}
return captures; return captures;
} }
template <class C> template <class C>
inline CaptureBasePtrList FrameBase::getCapturesOfType() inline std::list<std::shared_ptr<C>> FrameBase::getCapturesOfType()
{ {
CaptureBasePtrList captures; std::list<std::shared_ptr<C>> captures;
for (auto capture_ptr : getCaptureList()) for (auto capture_ptr : getCaptureList())
if (std::dynamic_pointer_cast<C>(capture_ptr) != nullptr) {
auto cap_derived = std::dynamic_pointer_cast<C>(capture_ptr);
if (cap_derived)
captures.push_back(capture_ptr); captures.push_back(capture_ptr);
}
return captures; return captures;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment