#include <component.h>
Public Types | |
using | TargetComponentInstanceType = typename TargetComponentType::InstanceType |
Public Member Functions | |
ComponentInstancePtr ()=default | |
template<class SourceComponentType > | |
ComponentInstancePtr (ComponentInstance *sourceComponentInstance, ComponentPtr< TargetComponentType >(SourceComponentType::*componentMemberPointer)) | |
template<class SourceComponentType > | |
ComponentInstancePtr (const ComponentInstancePtrInitProxy< TargetComponentType, SourceComponentType > &proxy) | |
const TargetComponentInstanceType & | operator* () const |
TargetComponentInstanceType & | operator* () |
TargetComponentInstanceType * | operator-> () const |
TargetComponentInstanceType * | operator-> () |
bool | operator== (const ComponentInstancePtr< TargetComponentType > &other) const |
template<typename OTHER > | |
bool | operator== (const ComponentInstancePtr< OTHER > &other) const |
template<typename OTHER > | |
bool | operator== (const OTHER *ptr) const |
bool | operator== (std::nullptr_t) const |
bool | operator!= (const ComponentInstancePtr< TargetComponentType > &other) const |
template<typename OTHER > | |
bool | operator!= (const ComponentInstancePtr< OTHER > &other) const |
template<typename OTHER > | |
bool | operator!= (const OTHER *ptr) const |
bool | operator!= (std::nullptr_t) const |
bool | operator< (const ComponentInstancePtr< TargetComponentType > &other) const |
bool | operator> (const ComponentInstancePtr< TargetComponentType > &other) const |
bool | operator<= (const ComponentInstancePtr< TargetComponentType > &other) const |
bool | operator>= (const ComponentInstancePtr< TargetComponentType > &other) const |
TargetComponentInstanceType * | get () const |
TargetComponentInstanceType * | get () |
ComponentInstancePtr is used in ComponentInstance classes to point to other ComponentInstance objects directly. ComponentInstances are spawned from Components at runtime. The ComponentInstancePtr class makes sure that the internal pointer is mapped to the spawned ComponentInstance target object.
The Component of a ComponentInstance must hold a ComponentPtr to another Component. When an ComponentInstancePtr is constructed, the user should provide the mapping to the ComponentPtr in the Component, by providing the pointer to the member.
Example:
class SomeComponent : public Component { ComponentPtr<OtherComponent> mOtherComponent; }; class SomeComponentInstance : public ComponentInstance { ComponentInstancePtr<OtherComponent> mOtherComponent = initComponentInstancePtr(this, &SomeComponent::mOtherComponent); };
In the example above, SomeComponentInstance::mOtherComponent will point the instance that corresponds to the Component in SomeComponent::mOtherComponent.
Vectors of ComponentsPtrs are supported in the same way:
Example:
class SomeComponent : public Component { std::vector<ComponentPtr<OtherComponent>> mOtherComponentList; }; class SomeComponentInstance : public ComponentInstance { std::vector<ComponentInstancePtr<OtherComponent>> mOtherComponentList = initComponentInstancePtr(this, &SomeComponent::mOtherComponentList); };
Here, each element in SomeComponentInstance::mOtherComponentList will point to each instance that corresponds to each element in the vector SomeComponent::mOtherComponentList;
using TargetComponentInstanceType = typename TargetComponentType::InstanceType |
|
default |
ComponentInstancePtr | ( | ComponentInstance * | sourceComponentInstance, |
ComponentPtr< TargetComponentType >SourceComponentType::* | componentMemberPointer | ||
) |
Construct a ComponentInstancePtr from a ComponentInstance and member pointer to the ComponentPtr containing the target we're pointing at. This constructor is deprecated and should not be used anymore; use initComponentInstancePtr instead. It is provided for backwards compatibility only.
ComponentInstancePtr | ( | const ComponentInstancePtrInitProxy< TargetComponentType, SourceComponentType > & | proxy | ) |
Construct a ComponentInstancePtr from a ComponentInstancePtrInitProxy, which can be retrieved through initComponentInstancePtr.
TargetComponentInstanceType* get | ( | ) |
TargetComponentInstanceType* get | ( | ) | const |
bool operator!= | ( | const ComponentInstancePtr< OTHER > & | other | ) | const |
bool operator!= | ( | const ComponentInstancePtr< TargetComponentType > & | other | ) | const |
bool operator!= | ( | const OTHER * | ptr | ) | const |
bool operator!= | ( | std::nullptr_t | ) | const |
TargetComponentInstanceType& operator* | ( | ) |
const TargetComponentInstanceType& operator* | ( | ) | const |
TargetComponentInstanceType* operator-> | ( | ) |
TargetComponentInstanceType* operator-> | ( | ) | const |
bool operator< | ( | const ComponentInstancePtr< TargetComponentType > & | other | ) | const |
bool operator<= | ( | const ComponentInstancePtr< TargetComponentType > & | other | ) | const |
bool operator== | ( | const ComponentInstancePtr< OTHER > & | other | ) | const |
bool operator== | ( | const ComponentInstancePtr< TargetComponentType > & | other | ) | const |
bool operator== | ( | const OTHER * | ptr | ) | const |
bool operator== | ( | std::nullptr_t | ) | const |
bool operator> | ( | const ComponentInstancePtr< TargetComponentType > & | other | ) | const |
bool operator>= | ( | const ComponentInstancePtr< TargetComponentType > & | other | ) | const |