33 #ifndef DART_COMMON_COMPOSITE_HPP_ 34 #define DART_COMMON_COMPOSITE_HPP_ 36 #include "dart/common/ClassWithVirtualBase.hpp" 37 #include "dart/common/detail/CompositeData.hpp" 58 using AspectMap = std::map<std::type_index, std::unique_ptr<Aspect> >;
59 using RequiredAspectSet = std::unordered_set<std::type_index>;
61 template <
typename... Aspects>
64 template <
typename... Aspects>
102 void set(
const T* aspect);
108 void set(std::unique_ptr<T>&& aspect);
111 template <
class T,
typename... Args>
175 void _set(std::type_index type_idx,
const Aspect* aspect);
178 void _set(std::type_index type_idx, std::unique_ptr<Aspect> aspect);
194 void createAspects(T* );
197 template <
class T,
class NextAspect,
class... Aspects>
198 void createAspects(T* comp);
203 #include "dart/common/detail/Composite.hpp" 205 #endif // DART_COMMON_COMPOSITE_HPP_ void copyCompositeStateTo(State &outgoingStates) const
Fill outgoingStates with the states of the aspects inside this Composite.
Definition: Composite.cpp:170
static constexpr bool isSpecializedFor()
Check if this Composite is specialized for a specific type of Aspect.
Definition: Composite.hpp:131
void _set(std::type_index type_idx, const Aspect *aspect)
Non-templated version of set(const T*)
Definition: Composite.cpp:287
Definition: CompositeData.hpp:106
RequiredAspectSet mRequiredAspects
A set containing type information for Aspects which are not allowed to leave this composite...
Definition: Composite.hpp:185
std::unique_ptr< T > releaseAspect()
Remove an Aspect from this Composite, but return its unique_ptr instead of letting it be deleted...
Definition: Composite.hpp:115
void setCompositeProperties(const Properties &newProperties)
Set the properties of the aspects in this Composite based on the given Composite::Properties.
Definition: Composite.cpp:178
T * createAspect(Args &&... args)
Construct an Aspect inside of this Composite.
Definition: Composite.hpp:91
Definition: Aspect.cpp:40
Composite()=default
Default constructor.
AspectMap mAspectMap
A map that relates the type of Aspect to its pointer.
Definition: Composite.hpp:181
Definition: Aspect.hpp:47
void removeAspect()
Remove an Aspect from this Composite.
Definition: Composite.hpp:102
void matchAspects(const Composite *otherComposite)
Make the Aspects of this Composite match the Aspects of otherComposite.
Definition: Composite.cpp:256
Composite & operator=(const Composite &)=delete
It is currently unsafe to copy an Composite.
void setCompositeState(const State &newStates)
Set the states of the aspects in this Composite based on the given Composite::State.
Definition: Composite.cpp:154
bool has() const
Check if this Composite currently has a certain type of Aspect.
Definition: Composite.hpp:52
bool requiresAspect() const
Check if this Composite requires this specific type of Aspect.
Definition: Composite.hpp:138
Properties getCompositeProperties() const
Get the properties of the aspects inside of this Composite.
Definition: Composite.cpp:187
void removeFromComposite(Aspect *aspect)
Remove this Aspect from the Composite.
Definition: Composite.cpp:280
Composite is a base class that should be virtually inherited by any class that wants to be able to ma...
Definition: Composite.hpp:52
void copyCompositePropertiesTo(Properties &outgoingProperties) const
Fill outgoingProperties with the properties of the aspects inside this Composite. ...
Definition: Composite.cpp:196
virtual ~Composite()=default
Virtual destructor.
Definition: CompositeData.hpp:185
void addToComposite(Aspect *aspect)
Add this Aspect to the Composite.
Definition: Composite.cpp:273
void duplicateAspects(const Composite *fromComposite)
Give this Composite a copy of each Aspect from otherComposite.
Definition: Composite.cpp:206
State getCompositeState() const
Get the states of the aspects inside of this Composite.
Definition: Composite.cpp:161