Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
CmpPtr< T > Class Template Reference

A simplified syntax for accessing entity components. More...

#include <CmpPtr.h>

Public Member Functions

 CmpPtr (const CSimContext &context, entity_id_t ent)
 
 CmpPtr (const CSimulation2 &simulation, entity_id_t ent)
 
 CmpPtr (CEntityHandle ent)
 
Toperator-> ()
 
 operator bool_type () const
 

Private Types

typedef void(CmpPtr::* bool_type )() const
 

Private Member Functions

void this_type_does_not_support_comparisons () const
 

Private Attributes

Tm
 

Detailed Description

template<typename T>
class CmpPtr< T >

A simplified syntax for accessing entity components.

E.g. to get the Position component, write:

* CmpPtr<ICmpPosition> cmpPosition(context, ent);
* if (!cmpPosition)
* // do something (maybe just silently abort; you should never crash if the
* // component is missing, even if you're sure it should never be missing)
*

where context is (if you're writing component code) a CSimContext object, or (if you're writing external engine code that makes use of the simulation system) a CSimulation2 object; and ent is the entity ID.

ent can be CComponentManager::SYSTEM_ENTITY (if you're writing a component), or CSimulation2::SYSTEM_ENTITY (for external code), if you want to access the global singleton system components.

You should never hold onto a component pointer outside of the method in which you acquire it, because it might get deleted and invalidate your pointer. (Components will never be deleted while inside a simulation method.)

Definition at line 55 of file CmpPtr.h.

Member Typedef Documentation

template<typename T>
typedef void(CmpPtr::* CmpPtr< T >::bool_type)() const
private

Definition at line 63 of file CmpPtr.h.

Constructor & Destructor Documentation

template<typename T>
CmpPtr< T >::CmpPtr ( const CSimContext context,
entity_id_t  ent 
)
inline

Definition at line 67 of file CmpPtr.h.

template<typename T>
CmpPtr< T >::CmpPtr ( const CSimulation2 simulation,
entity_id_t  ent 
)
inline

Definition at line 72 of file CmpPtr.h.

template<typename T>
CmpPtr< T >::CmpPtr ( CEntityHandle  ent)
inline

Definition at line 77 of file CmpPtr.h.

Member Function Documentation

template<typename T>
CmpPtr< T >::operator bool_type ( ) const
inline

Definition at line 88 of file CmpPtr.h.

template<typename T>
T* CmpPtr< T >::operator-> ( )
inline

Definition at line 86 of file CmpPtr.h.

template<typename T>
void CmpPtr< T >::this_type_does_not_support_comparisons ( ) const
inlineprivate

Definition at line 64 of file CmpPtr.h.

Member Data Documentation

template<typename T>
T* CmpPtr< T >::m
private

Definition at line 58 of file CmpPtr.h.


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