33 #ifndef DART_COMMON_COMPOSITE_HPP_
34 #define DART_COMMON_COMPOSITE_HPP_
58 using AspectMap = std::map<std::type_index, std::unique_ptr<Aspect> >;
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);
197 template <
class T,
class NextAspect,
class... Aspects>
Definition: Aspect.hpp:48
Composite is a base class that should be virtually inherited by any class that wants to be able to ma...
Definition: Composite.hpp:53
std::unordered_set< std::type_index > RequiredAspectSet
Definition: Composite.hpp:59
RequiredAspectSet mRequiredAspects
A set containing type information for Aspects which are not allowed to leave this composite.
Definition: Composite.hpp:185
State getCompositeState() const
Get the states of the aspects inside of this Composite.
Definition: Composite.cpp:161
void duplicateAspects(const Composite *fromComposite)
Give this Composite a copy of each Aspect from otherComposite.
Definition: Composite.cpp:206
static constexpr bool isSpecializedFor()
Check if this Composite is specialized for a specific type of Aspect.
Definition: Composite.hpp:131
void copyCompositeStateTo(State &outgoingStates) const
Fill outgoingStates with the states of the aspects inside this Composite.
Definition: Composite.cpp:170
std::map< std::type_index, std::unique_ptr< Aspect > > AspectMap
Definition: Composite.hpp:58
void removeAspect()
Remove an Aspect from this Composite.
Definition: Composite.hpp:102
bool requiresAspect() const
Check if this Composite requires this specific type of Aspect.
Definition: Composite.hpp:138
void _set(std::type_index type_idx, const Aspect *aspect)
Non-templated version of set(const T*)
Definition: Composite.cpp:287
T * get()
Get a certain type of Aspect from this Composite.
Definition: Composite.hpp:59
Composite & operator=(const Composite &)=delete
It is currently unsafe to copy an Composite.
Properties getCompositeProperties() const
Get the properties of the aspects inside of this Composite.
Definition: Composite.cpp:187
void addToComposite(Aspect *aspect)
Add this Aspect to the Composite.
Definition: Composite.cpp:273
void removeFromComposite(Aspect *aspect)
Remove this Aspect from the Composite.
Definition: Composite.cpp:280
Composite(Composite &&)=delete
It is currently unsafe to move an Composite.
Composite & operator=(Composite &&)=delete
It is currently unsafe to move an Composite.
Composite()=default
Default constructor.
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
bool has() const
Check if this Composite currently has a certain type of Aspect.
Definition: Composite.hpp:52
void copyCompositePropertiesTo(Properties &outgoingProperties) const
Fill outgoingProperties with the properties of the aspects inside this Composite.
Definition: Composite.cpp:196
Composite(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
T * createAspect(Args &&... args)
Construct an Aspect inside of this Composite.
Definition: Composite.hpp:91
AspectMap mAspectMap
A map that relates the type of Aspect to its pointer.
Definition: Composite.hpp:181
virtual ~Composite()=default
Virtual destructor.
void matchAspects(const Composite *otherComposite)
Make the Aspects of this Composite match the Aspects of otherComposite.
Definition: Composite.cpp:256
void set(const T *aspect)
Make a clone of the aspect and place the clone into this Composite.
Definition: Composite.hpp:77
Definition: CompositeData.hpp:186
Definition: CompositeData.hpp:107
CompositeData< CompositeStateMap, GetState > CompositeState
Definition: CompositeData.hpp:176
CompositeData< CompositePropertiesMap, GetProperties > CompositeProperties
Definition: CompositeData.hpp:178
void createAspects(T *)
Attach an arbitrary number of Aspects to the specified Composite type.
Definition: Composite.hpp:145
Definition: BulletCollisionDetector.cpp:65