33 #ifndef DART_COMMON_DETAIL_ASPECTWITHVERSION_HPP_ 34 #define DART_COMMON_DETAIL_ASPECTWITHVERSION_HPP_ 36 #include "dart/common/Aspect.hpp" 37 #include "dart/common/Deprecated.hpp" 38 #include "dart/common/StlHelpers.hpp" 51 class CompositeT = Composite,
52 void (*updateState)(DerivedT*) = &NoOp<DerivedT*> >
57 using Derived = DerivedT;
58 using StateData = StateDataT;
59 using CompositeType = CompositeT;
61 constexpr
static void (*UpdateState)(Derived*) = updateState;
72 template <
typename... BaseArgs>
74 : Base(
std::forward<BaseArgs>(args)...), mState(state)
80 void setAspectState(
const Aspect::State& otherState)
override final;
86 void setState(
const StateData& state);
89 const State& getState()
const;
92 std::unique_ptr<Aspect> cloneAspect()
const override;
105 typename PropertiesDataT,
107 void (*updateProperties)(DerivedT*) = &NoOp<DerivedT*> >
112 using Derived = DerivedT;
113 using PropertiesData = PropertiesDataT;
114 using CompositeType = CompositeT;
116 constexpr
static void (*UpdateProperties)(Derived*) = updateProperties;
129 const PropertiesData& properties = PropertiesData());
132 template <
typename... BaseArgs>
134 const PropertiesData& properties, BaseArgs&&... args)
135 : Base(
std::forward<BaseArgs>(args)...), mProperties(properties)
141 void setAspectProperties(
148 void setProperties(
const PropertiesData& properties);
154 std::unique_ptr<Aspect> cloneAspect()
const override;
157 std::size_t incrementVersion();
161 void notifyPropertiesUpdate();
164 void notifyPropertiesUpdated();
183 void (*updateState)(DerivedT*)>
186 UpdateState)(DerivedT*);
194 void (*updateState)(DerivedT*)>
197 : BaseT(), mState(state)
208 void (*updateState)(DerivedT*)>
212 setState(static_cast<const State&>(otherState));
221 void (*updateState)(DerivedT*)>
224 getAspectState()
const 235 void (*updateState)(DerivedT*)>
237 setState(
const StateData& state)
239 static_cast<StateData&
>(mState) = state;
240 UpdateState(static_cast<Derived*>(
this));
249 void (*updateState)(DerivedT*)>
262 void (*updateState)(DerivedT*)>
263 std::unique_ptr<Aspect>
267 return std::make_unique<Derived>(mState);
280 typename PropertiesDataT,
282 void (*updateProperties)(DerivedT*)>
288 updateProperties>::UpdateProperties)(DerivedT*);
294 typename PropertiesDataT,
296 void (*updateProperties)(DerivedT*)>
304 : BaseT(), mProperties(properties)
313 typename PropertiesData,
315 void (*updateProperties)(DerivedT*)>
324 setProperties(static_cast<const Properties&>(someProperties));
331 typename PropertiesData,
333 void (*updateProperties)(DerivedT*)>
339 updateProperties>::getAspectProperties()
const 348 typename PropertiesData,
350 void (*updateProperties)(DerivedT*)>
356 updateProperties>::setProperties(
const PropertiesData& properties)
358 static_cast<PropertiesData&
>(mProperties) = properties;
359 this->notifyPropertiesUpdated();
366 typename PropertiesData,
368 void (*updateProperties)(DerivedT*)>
374 updateProperties>::getProperties()
const ->
const Properties&
383 typename PropertiesData,
385 void (*updateProperties)(DerivedT*)>
391 updateProperties>::cloneAspect()
const 393 return std::make_unique<Derived>(mProperties);
400 typename PropertiesData,
402 void (*updateProperties)(DerivedT*)>
408 updateProperties>::incrementVersion()
410 if (CompositeType* comp = this->getComposite())
420 typename PropertiesData,
422 void (*updateProperties)(DerivedT*)>
428 updateProperties>::notifyPropertiesUpdate()
430 notifyPropertiesUpdated();
437 typename PropertiesData,
439 void (*updateProperties)(DerivedT*)>
445 updateProperties>::notifyPropertiesUpdated()
447 UpdateProperties(static_cast<Derived*>(
this));
448 this->incrementVersion();
455 #endif // DART_COMMON_DETAIL_ASPECTWITHVERSION_HPP_ AspectWithState(const StateData &state, BaseArgs &&... args)
Construct this Aspect and pass args into the constructor of the Base class.
Definition: AspectWithVersion.hpp:73
The MakeCloneable class is used to easily create an Cloneable (such as Node::State) which simply take...
Definition: Cloneable.hpp:83
Definition: SharedLibraryManager.hpp:46
If your Aspect has Properties, then that Properties class should inherit this Aspect::Properties clas...
Definition: Aspect.hpp:85
std::size_t incrementVersion()
Increment the version of this Aspect and its Composite.
Definition: AspectWithVersion.hpp:408
Definition: Aspect.cpp:40
If your Aspect has a State, then that State class should inherit this Aspect::State class...
Definition: Aspect.hpp:64
State mState
State of this Aspect.
Definition: AspectWithVersion.hpp:96
Properties mProperties
Properties of this Aspect.
Definition: AspectWithVersion.hpp:168
AspectWithProtectedProperties generates implementations of the Property managing functions for an Asp...
Definition: AspectWithVersion.hpp:108
AspectWithProtectedState generates implementations of the State managing functions for an Aspect clas...
Definition: AspectWithVersion.hpp:53
Composite is a base class that should be virtually inherited by any class that wants to be able to ma...
Definition: Composite.hpp:52
AspectWithVersionedProperties(const PropertiesData &properties, BaseArgs &&... args)
Construct this Aspect and pass args into the constructor of the Base class.
Definition: AspectWithVersion.hpp:133