Saga
Saga Game Engine
Loading...
Searching...
No Matches
Saga::ComponentReference< Component > Class Template Reference

Reference to a component. Will be valid as long as that component exists on a specific Entity, even if their pointer address has changed. More...

#include <componentReference.h>

Public Member Functions

 ComponentReference ()
 Construct a new Component Reference object.
 
 ComponentReference (std::shared_ptr< ComponentContainer< Component > > componentContainer, Entity entity)
 Construct a new Component Reference object.
 
virtual ~ComponentReference ()
 Destroy the Component Reference object.
 
 operator Component * ()
 Get a volatile pointer to the component this references. Since this pointer can change when components of the same type are added and removed from the world, it is not a good idea to use this pointer for a long time.
 
Component * operator-> ()
 Automatic cast of ComponentReference to their volatile Component pointer form.
 

Detailed Description

template<typename Component>
class Saga::ComponentReference< Component >

Reference to a component. Will be valid as long as that component exists on a specific Entity, even if their pointer address has changed.

Template Parameters
Componenttype of component this reference is for.

Constructor & Destructor Documentation

◆ ComponentReference() [1/2]

template<typename Component >
Saga::ComponentReference< Component >::ComponentReference ( )
inline

Construct a new Component Reference object.

◆ ComponentReference() [2/2]

template<typename Component >
Saga::ComponentReference< Component >::ComponentReference ( std::shared_ptr< ComponentContainer< Component > >  componentContainer,
Entity  entity 
)
inline

Construct a new Component Reference object.

Parameters
componentContainer
entity

◆ ~ComponentReference()

template<typename Component >
virtual Saga::ComponentReference< Component >::~ComponentReference ( )
inlinevirtual

Destroy the Component Reference object.

Member Function Documentation

◆ operator Component *()

template<typename Component >
Saga::ComponentReference< Component >::operator Component * ( )
inline

Get a volatile pointer to the component this references. Since this pointer can change when components of the same type are added and removed from the world, it is not a good idea to use this pointer for a long time.

Returns
Component* a reference to the component, or nullptr if none exists.

◆ operator->()

template<typename Component >
Component * Saga::ComponentReference< Component >::operator-> ( )
inline

Automatic cast of ComponentReference to their volatile Component pointer form.

Returns
Component* pointer to the component that this object references, or nullptr if they don't exist.

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