Cogs.Core
Public Types | Public Member Functions | Private Attributes | List of all members
Cogs::ComponentModel::ComponentPtr< ComponentType > Class Template Reference

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 (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< EntitygetEntity () const
 Get the owning entity.
 

Private Attributes

std::shared_ptr< Entityowner
 

Detailed Description

template<typename ComponentType>
class Cogs::ComponentModel::ComponentPtr< ComponentType >

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.

Definition at line 16 of file ComponentPtr.h.

Member Typedef Documentation

◆ value_type

template<typename ComponentType >
typedef ComponentType Cogs::ComponentModel::ComponentPtr< ComponentType >::value_type

Definition at line 20 of file ComponentPtr.h.

Constructor & Destructor Documentation

◆ ComponentPtr() [1/5]

template<typename ComponentType >
Cogs::ComponentModel::ComponentPtr< ComponentType >::ComponentPtr ( const std::shared_ptr< Entity > &  owner)
inline

Initializes a component pointer for component in the given entity.

Definition at line 25 of file ComponentPtr.h.

◆ ComponentPtr() [2/5]

template<typename ComponentType >
Cogs::ComponentModel::ComponentPtr< ComponentType >::ComponentPtr ( std::shared_ptr< Entity > &&  owner)
inlinenoexcept

Initializes a component pointer for component in the given entity.

Definition at line 31 of file ComponentPtr.h.

◆ ComponentPtr() [3/5]

template<typename ComponentType >
Cogs::ComponentModel::ComponentPtr< ComponentType >::ComponentPtr ( const ComponentPtr< ComponentType > &  source)
inline

Initializes a component pointer as a copy constructor.

Definition at line 37 of file ComponentPtr.h.

◆ ComponentPtr() [4/5]

template<typename ComponentType >
Cogs::ComponentModel::ComponentPtr< ComponentType >::ComponentPtr ( ComponentPtr< ComponentType > &&  source)
inlinenoexcept

Initializes a component pointer using RValue constructor.

Definition at line 43 of file ComponentPtr.h.

◆ ComponentPtr() [5/5]

template<typename ComponentType >
constexpr Cogs::ComponentModel::ComponentPtr< ComponentType >::ComponentPtr ( std::nullptr_t  )
inlineconstexpr

Construct empty instance.

Definition at line 49 of file ComponentPtr.h.

Member Function Documentation

◆ get()

template<typename ComponentType >
ComponentType * Cogs::ComponentModel::ComponentPtr< ComponentType >::get ( ) const
inline

Definition at line 66 of file ComponentPtr.h.

◆ getEntity()

template<typename ComponentType >
std::shared_ptr< Entity > Cogs::ComponentModel::ComponentPtr< ComponentType >::getEntity ( ) const
inline

Get the owning entity.

Definition at line 91 of file ComponentPtr.h.

◆ operator bool()

template<typename ComponentType >
Cogs::ComponentModel::ComponentPtr< ComponentType >::operator bool ( ) const
inline

bool conversion for checking if the component can be accessed.

Definition at line 79 of file ComponentPtr.h.

◆ operator->()

template<typename ComponentType >
ComponentType * Cogs::ComponentModel::ComponentPtr< ComponentType >::operator-> ( ) const
inline

Definition at line 71 of file ComponentPtr.h.

◆ operator=() [1/2]

template<typename ComponentType >
ComponentPtr< ComponentType > & Cogs::ComponentModel::ComponentPtr< ComponentType >::operator= ( ComponentPtr< ComponentType > &&  rhs)
inlinenoexcept

Definition at line 60 of file ComponentPtr.h.

◆ operator=() [2/2]

template<typename ComponentType >
ComponentPtr< ComponentType > & Cogs::ComponentModel::ComponentPtr< ComponentType >::operator= ( const ComponentPtr< ComponentType > &  rhs)
inline

Definition at line 54 of file ComponentPtr.h.

◆ operator==()

template<typename ComponentType >
constexpr bool Cogs::ComponentModel::ComponentPtr< ComponentType >::operator== ( const ComponentPtr< ComponentType > &  other) const
inlineconstexpr

Comparison operator. If the entity of both objects are equal the objects are considered equal.

Definition at line 82 of file ComponentPtr.h.

◆ reset()

template<typename ComponentType >
void Cogs::ComponentModel::ComponentPtr< ComponentType >::reset ( )
inline

Reset to empty.

See also
ComponentPtr<ComponentType>

Definition at line 85 of file ComponentPtr.h.

Member Data Documentation

◆ owner

template<typename ComponentType >
std::shared_ptr<Entity> Cogs::ComponentModel::ComponentPtr< ComponentType >::owner
private

Definition at line 94 of file ComponentPtr.h.


The documentation for this class was generated from the following file: