Cogs.Foundation
|
A shared_pointer type pointer to a component in an entity. More...
#include <ComponentPtr.h>
Public Types | |
typedef ComponentType | value_type |
Public Member Functions | |
ComponentPtr ()=default | |
ComponentPtr (const std::shared_ptr< Entity > &owner) | |
Initializes a component pointer for component in the given entity. | |
ComponentPtr (std::shared_ptr< Entity > &&owner) noexcept | |
Initializes a component pointer for component in the given entity. | |
ComponentPtr (const ComponentPtr< ComponentType > &source) | |
Initializes a component pointer as a copy constructor. | |
ComponentPtr (ComponentPtr< ComponentType > &&source) noexcept | |
Initializes a component pointer using RValue constructor. | |
constexpr | ComponentPtr (std::nullptr_t) |
Construct empty instance. | |
ComponentPtr< ComponentType > & | operator= (const ComponentPtr< ComponentType > &rhs) |
ComponentPtr< ComponentType > & | operator= (ComponentPtr< ComponentType > &&rhs) noexcept |
ComponentType * | get () const |
ComponentType * | operator-> () const |
operator bool () const | |
bool conversion for checking if the component can be accessed. | |
constexpr bool | operator== (const ComponentPtr< ComponentType > &other) const |
Comparison operator. If the entity of both objects are equal the objects are considered equal. | |
void | reset () |
Reset to empty. | |
std::shared_ptr< Entity > | getEntity () const |
Get the owning entity. | |
Private Attributes | |
std::shared_ptr< Entity > | owner |
A shared_pointer type pointer to a component in an entity.
Components are by default only accessed using raw pointers. A raw component pointer cannot be saved as the object may be moved when creating more components in the component pool.
typedef ComponentType Cogs::ComponentModel::ComponentPtr< ComponentType >::value_type |
|
default |
|
inline |
Initializes a component pointer for component in the given entity.
|
inlinenoexcept |
Initializes a component pointer for component in the given entity.
|
inline |
Initializes a component pointer as a copy constructor.
|
inlinenoexcept |
Initializes a component pointer using RValue constructor.
|
inlineconstexpr |
Construct empty instance.
|
inline |
|
inline |
Get the owning entity.
References Cogs::ComponentModel::ComponentPtr< ComponentType >::owner.
|
inline |
bool conversion for checking if the component can be accessed.
References Cogs::ComponentModel::ComponentPtr< ComponentType >::operator->(), and Cogs::ComponentModel::ComponentPtr< ComponentType >::owner.
|
inline |
|
inlinenoexcept |
|
inline |
|
inlineconstexpr |
Comparison operator. If the entity of both objects are equal the objects are considered equal.
References Cogs::ComponentModel::ComponentPtr< ComponentType >::owner.
|
inline |
Reset to empty.
References Cogs::ComponentModel::ComponentPtr< ComponentType >::owner.
|
private |
Referenced by Cogs::ComponentModel::ComponentPtr< ComponentType >::get(), Cogs::ComponentModel::ComponentPtr< ComponentType >::getEntity(), Cogs::ComponentModel::ComponentPtr< ComponentType >::operator bool(), Cogs::ComponentModel::ComponentPtr< ComponentType >::operator=(), Cogs::ComponentModel::ComponentPtr< ComponentType >::operator==(), and Cogs::ComponentModel::ComponentPtr< ComponentType >::reset().