NAP
Public Types | Public Member Functions | List of all members
ComponentInstancePtr< TargetComponentType > Class Template Reference

#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 TargetComponentInstanceTypeoperator* () const
 
TargetComponentInstanceTypeoperator* ()
 
TargetComponentInstanceTypeoperator-> () const
 
TargetComponentInstanceTypeoperator-> ()
 
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
 
TargetComponentInstanceTypeget () const
 
TargetComponentInstanceTypeget ()
 

Description

template<class TargetComponentType>
class nap::ComponentInstancePtr< TargetComponentType >

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;

Member Typedef Documentation

◆ TargetComponentInstanceType

using TargetComponentInstanceType = typename TargetComponentType::InstanceType

Constructor & Destructor Documentation

◆ ComponentInstancePtr() [1/3]

ComponentInstancePtr ( )
default

◆ ComponentInstancePtr() [2/3]

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() [3/3]

ComponentInstancePtr ( const ComponentInstancePtrInitProxy< TargetComponentType, SourceComponentType > &  proxy)

Construct a ComponentInstancePtr from a ComponentInstancePtrInitProxy, which can be retrieved through initComponentInstancePtr.

Member Function Documentation

◆ get() [1/2]

◆ get() [2/2]

◆ operator!=() [1/4]

bool operator!= ( const ComponentInstancePtr< OTHER > &  other) const

◆ operator!=() [2/4]

bool operator!= ( const ComponentInstancePtr< TargetComponentType > &  other) const

◆ operator!=() [3/4]

bool operator!= ( const OTHER *  ptr) const

◆ operator!=() [4/4]

bool operator!= ( std::nullptr_t  ) const

◆ operator*() [1/2]

◆ operator*() [2/2]

const TargetComponentInstanceType& operator* ( ) const

◆ operator->() [1/2]

TargetComponentInstanceType* operator-> ( )

◆ operator->() [2/2]

TargetComponentInstanceType* operator-> ( ) const

◆ operator<()

bool operator< ( const ComponentInstancePtr< TargetComponentType > &  other) const

◆ operator<=()

bool operator<= ( const ComponentInstancePtr< TargetComponentType > &  other) const

◆ operator==() [1/4]

bool operator== ( const ComponentInstancePtr< OTHER > &  other) const

◆ operator==() [2/4]

bool operator== ( const ComponentInstancePtr< TargetComponentType > &  other) const

◆ operator==() [3/4]

bool operator== ( const OTHER *  ptr) const

◆ operator==() [4/4]

bool operator== ( std::nullptr_t  ) const

◆ operator>()

bool operator> ( const ComponentInstancePtr< TargetComponentType > &  other) const

◆ operator>=()

bool operator>= ( const ComponentInstancePtr< TargetComponentType > &  other) const