CORGI
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
corgi::ComponentInterface Class Referenceabstract

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...

#include <component_interface.h>

Inherited by corgi::Component< AnimationData >, corgi::Component< CommonServicesData >, corgi::Component< GraphData >, corgi::Component< MetaData >, corgi::Component< PhysicsData >, corgi::Component< RenderMeshData >, corgi::Component< TransformData >, and corgi::Component< T >.

Detailed Description

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).

Public Types

typedef std::unique_ptr
< uint8_t, std::function< void(uint8_t *)> > 
RawDataUniquePtr
 A pointer type for exported raw data.
 

Public Member Functions

virtual ~ComponentInterface ()
 A destructor for the Component interface.
 
virtual void AddEntityGenerically (EntityRef &entity)=0
 Add an Entity to the Component. More...
 
virtual void RemoveEntity (EntityRef &entity)=0
 Remove an Entity from the Component's list. More...
 
virtual void UpdateAllEntities (WorldTime delta_time)=0
 Update all Entities that contain this Component. More...
 
virtual bool HasDataForEntity (const EntityRef &)=0
 Returns true if this component has data associated with the entity provided.
 
virtual void ClearComponentData ()=0
 Clears all Component data, effectively disassociating this Component from any Entities.
 
virtual void * GetComponentDataAsVoid (const EntityRef &)=0
 Gets the data for a given Entity as a void pointer. More...
 
virtual const void * GetComponentDataAsVoid (const EntityRef &) const =0
 Gets the data for a given ntity as a const void pointer. More...
 
virtual void Init ()=0
 This function is called after the Component is added to the EntityManager. (i.e. This typically happens once, at the beginning of the game before any Entities are added.)
 
virtual void InitEntity (EntityRef &entity)=0
 Called by the EntityManager every time an Entity is added to this Component. More...
 
virtual void AddFromRawData (EntityRef &entity, const void *data)=0
 Creates and populates an Entity from raw data. Components that want to be able to be constructed via the EntityFactory need to implement this. More...
 
virtual RawDataUniquePtr ExportRawData (const EntityRef &entity) const =0
 Serializes a Component's data for a specific Entity. More...
 
virtual void Cleanup ()=0
 Called just before removal from the EntityManager. (i.e. Usually when the game/state is over and everything is shutting down.)
 
virtual void CleanupEntity (EntityRef &entity)=0
 Called when the Entity is being removed from the Component. Components should implement this if they need to perform any cleanup on the Entity data. More...
 
virtual void SetEntityManager (EntityManager *entity_manager)=0
 Set the EntityManager for this Component. Usually this is assigned by the EntityManager itself. More...
 
virtual void SetComponentIdOnDataType (ComponentId id)=0
 Sets the Component ID for the data type. More...
 

Member Function Documentation

virtual void corgi::ComponentInterface::AddEntityGenerically ( EntityRef entity)
pure virtual

Add an Entity to the Component.

Note
Usually you will want to use Component::AddEntity, since that returns a pointer to the data assigned to the Component.
Parameters
[in,out]entityAn EntityRef reference to the Entity being added to this Component.

Implemented in corgi::Component< T >, corgi::Component< CommonServicesData >, corgi::Component< PhysicsData >, corgi::Component< TransformData >, corgi::Component< AnimationData >, corgi::Component< MetaData >, corgi::Component< RenderMeshData >, and corgi::Component< GraphData >.

virtual void corgi::ComponentInterface::AddFromRawData ( EntityRef entity,
const void *  data 
)
pure virtual

Creates and populates an Entity from raw data. Components that want to be able to be constructed via the EntityFactory need to implement this.

Parameters
[in,out]entityAn EntityRef that points to an Entity that is being added from the raw data.
[in]dataA void pointer to the raw data.

Implemented in PhysicsComponent, corgi::component_library::RenderMeshComponent, corgi::component_library::TransformComponent, corgi::component_library::GraphComponent, corgi::component_library::AnimationComponent, corgi::component_library::CommonServicesComponent, and corgi::component_library::MetaComponent.

virtual void corgi::ComponentInterface::CleanupEntity ( EntityRef entity)
pure virtual

Called when the Entity is being removed from the Component. Components should implement this if they need to perform any cleanup on the Entity data.

Parameters
[in]entityAn EntityRef reference to the Entity that is being removed and may need to be cleaned up.

Implemented in corgi::Component< T >, corgi::Component< CommonServicesData >, corgi::Component< PhysicsData >, corgi::Component< TransformData >, corgi::Component< AnimationData >, corgi::Component< MetaData >, corgi::Component< RenderMeshData >, corgi::Component< GraphData >, PhysicsComponent, corgi::component_library::TransformComponent, and corgi::component_library::MetaComponent.

virtual RawDataUniquePtr corgi::ComponentInterface::ExportRawData ( const EntityRef entity) const
pure virtual
virtual void* corgi::ComponentInterface::GetComponentDataAsVoid ( const EntityRef )
pure virtual

Gets the data for a given Entity as a void pointer.

Note
When using GetComponentDataAsVoid, the calling function is expected to know how to handle the data (since it is returned as a void pointer).
Warning
This pointer is NOT stable in memory. Calls to AddEntityGenerically may force the storage class to resize, shuffling around the location of this data.
Returns
Returns the Entity's data as a void pointer, or returns a nullptr if the data does not exist.

Implemented in corgi::Component< T >, corgi::Component< CommonServicesData >, corgi::Component< PhysicsData >, corgi::Component< TransformData >, corgi::Component< AnimationData >, corgi::Component< MetaData >, corgi::Component< RenderMeshData >, and corgi::Component< GraphData >.

virtual const void* corgi::ComponentInterface::GetComponentDataAsVoid ( const EntityRef ) const
pure virtual

Gets the data for a given ntity as a const void pointer.

Note
When using GetComponentDataAsVoid, the calling function is expected to know how to handle the data (since it is returned as a const void pointer).
Warning
This pointer is NOT stable in memory. Calls to AddEntity and AddEntityGenerically may force the storage class to resize, shuffling around the location of this data.
Returns
Returns the Entity's data as a const void pointer, or returns a nullptr if the data does not exist.

Implemented in corgi::Component< T >, corgi::Component< CommonServicesData >, corgi::Component< PhysicsData >, corgi::Component< TransformData >, corgi::Component< AnimationData >, corgi::Component< MetaData >, corgi::Component< RenderMeshData >, and corgi::Component< GraphData >.

virtual void corgi::ComponentInterface::RemoveEntity ( EntityRef entity)
pure virtual
virtual void corgi::ComponentInterface::SetComponentIdOnDataType ( ComponentId  id)
pure virtual
virtual void corgi::ComponentInterface::SetEntityManager ( EntityManager entity_manager)
pure virtual

Set the EntityManager for this Component. Usually this is assigned by the EntityManager itself.

Note
The EntityManager is used as the main point of contact for Components that need to talk to other things.
Parameters
[in]entity_managerA pointer to an EntityManager to associate with this Component.

Implemented in corgi::Component< T >, corgi::Component< CommonServicesData >, corgi::Component< PhysicsData >, corgi::Component< TransformData >, corgi::Component< AnimationData >, corgi::Component< MetaData >, corgi::Component< RenderMeshData >, and corgi::Component< GraphData >.


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