NAP
Public Member Functions | List of all members
ComponentPtr< ComponentType > Class Template Reference

#include <component.h>

Public Member Functions

 ComponentPtr ()=default
 
 ComponentPtr (ComponentType *component)
 
const std::string & getInstancePath () const
 
virtual std::string toString () const override
 
virtual void assign (const std::string &targetID, rtti::Object &targetObject) override
 
const ComponentType & operator* () const
 
ComponentType & operator* ()
 
const ComponentType * operator-> () const
 
ComponentType * operator-> ()
 
bool operator== (const ComponentPtr< ComponentType > &other) const
 
template<typename OTHER >
bool operator== (const ComponentPtr< OTHER > &other) const
 
template<typename OTHER >
bool operator== (const OTHER *ptr) const
 
bool operator== (std::nullptr_t) const
 
bool operator!= (const ComponentPtr< ComponentType > &other) const
 
template<typename OTHER >
bool operator!= (const ComponentPtr< OTHER > &other) const
 
template<typename OTHER >
bool operator!= (const OTHER *ptr) const
 
bool operator!= (std::nullptr_t) const
 
bool operator< (const ComponentPtr< ComponentType > &other) const
 
bool operator> (const ComponentPtr< ComponentType > &other) const
 
bool operator<= (const ComponentPtr< ComponentType > &other) const
 
bool operator>= (const ComponentPtr< ComponentType > &other) const
 
ComponentType * get () const
 
ComponentType * get ()
 

Description

template<class ComponentType>
class nap::ComponentPtr< ComponentType >

Typed version of ComponentPtrBase. ComponentPtr stores the path and the pointer to the target resource.

When pointing to other other components through ComponentPtrs, you can do so using a 'path' to the target component. This path can be of two forms:

Paths consisting out of multiple elements can be either relative or absolute and come in three forms:

When there are ChildEntityIDs on the path, it's possible for the ChildEntityID to be ambiguous (for example, when an entity has multiple children with the same ID). For example, consider the following entity hierarchy:

CarEntity -> WheelEntity -> TransformComponent -> WheelEntity -> TransformComponent -> WheelEntity -> TransformComponent -> WheelEntity -> TransformComponent

Pointing directly to one of these TransformComponents using a component path is not possible, because it would be ambiguous. To disambiguate which specific child entity is meant, the user can append a ':[child_index]' to the ChildEntityID on the path.

In this case, to point to the TransformComponent of the second wheel, the user would use the following path: './WheelEntity:1/TransformComponent'

Constructor & Destructor Documentation

◆ ComponentPtr() [1/2]

ComponentPtr ( )
default

◆ ComponentPtr() [2/2]

ComponentPtr ( ComponentType *  component)

Member Function Documentation

◆ assign()

virtual void assign ( const std::string &  targetID,
rtti::Object targetObject 
)
overridevirtual

◆ get() [1/2]

ComponentType* get ( )

◆ get() [2/2]

ComponentType* get ( ) const

◆ getInstancePath()

const std::string& getInstancePath ( ) const

◆ operator!=() [1/4]

bool operator!= ( const ComponentPtr< ComponentType > &  other) const

◆ operator!=() [2/4]

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

◆ operator!=() [3/4]

bool operator!= ( const OTHER *  ptr) const

◆ operator!=() [4/4]

bool operator!= ( std::nullptr_t  ) const

◆ operator*() [1/2]

ComponentType& operator* ( )

◆ operator*() [2/2]

const ComponentType& operator* ( ) const

◆ operator->() [1/2]

ComponentType* operator-> ( )

◆ operator->() [2/2]

const ComponentType* operator-> ( ) const

◆ operator<()

bool operator< ( const ComponentPtr< ComponentType > &  other) const

◆ operator<=()

bool operator<= ( const ComponentPtr< ComponentType > &  other) const

◆ operator==() [1/4]

bool operator== ( const ComponentPtr< ComponentType > &  other) const

◆ operator==() [2/4]

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

◆ operator==() [3/4]

bool operator== ( const OTHER *  ptr) const

◆ operator==() [4/4]

bool operator== ( std::nullptr_t  ) const

◆ operator>()

bool operator> ( const ComponentPtr< ComponentType > &  other) const

◆ operator>=()

bool operator>= ( const ComponentPtr< ComponentType > &  other) const

◆ toString()

virtual std::string toString ( ) const
overridevirtual