CORGI
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Component

Component classes and functions. More...

Detailed Description

Component classes and functions.

Classes

class  corgi::Component< T >
 A Component is an object that encapsulates all data and logic for Entities of a particular type. More...
 
struct  corgi::ComponentIdLookup< T >
 A templated struct for holding type-dependent data. More...
 
class  corgi::ComponentInterface
 An interface that provides basic Component functionality. All Components will inherit from this class. It provides the minimum set of things that are uniform across all Components (without needing to know the specific type of Component that it is). More...
 

Macros

#define CORGI_REGISTER_COMPONENT(ComponentType, DataType)
 
#define CORGI_DEFINE_COMPONENT(ComponentType, DataType)
 
#define CORGI_REGISTER_COMPONENT_ID_LOOKUP(DataType)
 
#define CORGI_DEFINE_COMPONENT_ID_LOOKUP(DataType)
 

Macro Definition Documentation

#define CORGI_DEFINE_COMPONENT (   ComponentType,
  DataType 
)
Value:
#define CORGI_DEFINE_COMPONENT_ID_LOOKUP(DataType)
Definition: component_id_lookup.h:88

Handles defining the storage location for the Component for a given Component type and data type. It should be placed at the top of the .cpp file for that Component (after the includes but before the namespaces).

Parameters
ComponentTypeThe name of the Component class.
DataTypeThe name of the struct that holds the Component data. (i.e. The type that the Component was specialized for.)
#define CORGI_DEFINE_COMPONENT_ID_LOOKUP (   DataType)
Value:
namespace corgi { \
ComponentId ComponentIdLookup<DataType>::component_id = kInvalidComponent; \
}
const ComponentId kInvalidComponent
A sentinel value to represent an invalid Component.
Definition: entity_common.h:44
uint16_t ComponentId
This represents the ID of a Component.
Definition: entity_common.h:36

This macro handles defining the storage location for the Component ID for a given data type. It is usually invoked by CORGI_DEFINE_COMPONENT, rather than invoking it directly.

Parameters
DataTypeThe name of the struct that holds the Component data. (i.e. The type that the Component was specialized for.)
#define CORGI_REGISTER_COMPONENT (   ComponentType,
  DataType 
)
Value:
#define CORGI_REGISTER_COMPONENT_ID_LOOKUP(DataType)
Definition: component_id_lookup.h:73

Each Component needs to use this macro in its header, in order to declare the necessary constants for lookups.

Note
Since the macro includes its own namespace defintions, this should ideally be called outside of any namespaces.
Parameters
ComponentTypeThe name of the Component class.
DataTypeThe name of the struct that holds the Component data. (i.e. The type that the Component was specialized for.)
#define CORGI_REGISTER_COMPONENT_ID_LOOKUP (   DataType)
Value:
namespace corgi { \
template <> \
struct ComponentIdLookup<DataType> { \
static ComponentId component_id; \
}; \
}
uint16_t ComponentId
This represents the ID of a Component.
Definition: entity_common.h:36

This macro handles the lower level job of generating code to associate data with a type. It is usually invoked by CORGI_REGISTER_COMPONENT, rather than invoking it directly. (Since registration of a Component requires multiple datatype/ID registrations.)

Parameters
DataTypeThe name of the struct that holds the Component data. (i.e. The type that the Component was specialized for.)