33 #ifndef DART_COMMON_CLONEABLE_HPP_ 34 #define DART_COMMON_CLONEABLE_HPP_ 39 #include "dart/common/Memory.hpp" 69 virtual std::unique_ptr<T>
clone()
const = 0;
72 virtual void copy(
const T& anotherCloneable) = 0;
82 template <
class Base,
class Mixin>
89 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
98 template <
typename... Args>
99 MakeCloneable(Args&&... args);
102 MakeCloneable(
const Mixin& mixin);
105 MakeCloneable(Mixin&& mixin);
114 MakeCloneable&
operator=(
const Mixin& mixin);
120 MakeCloneable&
operator=(
const MakeCloneable& other);
123 MakeCloneable&
operator=(MakeCloneable&& other);
126 std::unique_ptr<Base>
clone()
const override final;
129 void copy(
const Base& other)
override final;
137 void (*setData)(OwnerT*,
const DataT&),
138 DataT (*getData)(
const OwnerT*)>
143 using Owner = OwnerT;
153 template <
typename... Args>
158 template <
typename... Args>
159 ProxyCloneable(Args&&... args);
162 ProxyCloneable(
const ProxyCloneable& other);
165 ProxyCloneable(ProxyCloneable&& other);
168 ProxyCloneable&
operator=(
const Data& data);
174 ProxyCloneable&
operator=(
const ProxyCloneable& other);
177 ProxyCloneable&
operator=(ProxyCloneable&& other);
180 void set(
const Data& data);
183 void set(Data&& data);
186 void set(
const ProxyCloneable& other);
189 void set(ProxyCloneable&& other);
198 const OwnerT* getOwner()
const;
201 std::unique_ptr<Base>
clone()
const override final;
204 void copy(
const Base& other)
override final;
219 template <
typename MapType>
260 void copy(
const MapType& otherMap,
bool merge =
false);
270 void merge(
const MapType& otherMap);
276 const MapType& getMap()
const;
286 template <
typename T>
306 std::unique_ptr<CloneableVector<T> >
clone()
const;
312 std::vector<T>& getVector();
315 const std::vector<T>& getVector()
const;
319 std::vector<T> mVector;
325 #include "dart/common/detail/Cloneable.hpp" 327 #endif // DART_COMMON_CLONEABLE_HPP_ std::unique_ptr< Data > mData
The ProxyCloneable will hold data in this field if it does not have an owner.
Definition: Cloneable.hpp:212
Cloneable is a CRTP base class that provides an interface for easily creating data structures that ar...
Definition: Cloneable.hpp:53
The MakeCloneable class is used to easily create an Cloneable (such as Node::State) which simply take...
Definition: Cloneable.hpp:83
virtual ~Cloneable()=default
Virtual destructor.
Cloneable()=default
Default constructor.
MapType mMap
A map containing the collection of States for the Aspect.
Definition: Cloneable.hpp:280
virtual void copy(const T &anotherCloneable)=0
Copy the contents of anotherCloneable into this one.
Definition: Aspect.cpp:40
Definition: Cloneable.hpp:139
Cloneable & operator=(const Cloneable &doNotCopy)=delete
Do not copy this class directly, use clone() or copy() instead.
OwnerT * mOwner
The ProxyCloneable will not store any data in mData if it has an Owner.
Definition: Cloneable.hpp:208
virtual std::unique_ptr< T > clone() const =0
Implement this function to allow your Cloneable type to be copied safely.
MapHolder is a templated wrapper class that is used to allow maps of Aspect::State and Aspect::Proper...
Definition: Cloneable.hpp:220
The CloneableVector type wraps a std::vector of an Cloneable type allowing it to be handled by an Clo...
Definition: Cloneable.hpp:287