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

Manages the event graphs for any Entity that wishes to utilize the event system. More...

#include <graph.h>

Inherits corgi::Component< GraphData >.

Detailed Description

Manages the event graphs for any Entity that wishes to utilize the event system.

Note
Once the Entities themselves have been initialized, initialize the graphs. The graphs must be initialized after the Entities because the graphs may reference the Entities.

Public Member Functions

void PostLoadFixup ()
 Fixes up all loaded Entities. More...
 
void EntityPostLoadFixup (corgi::EntityRef &entity)
 Fixes up a given Entity. More...
 
breadboard::NodeEventBroadcaster * GetCreateBroadcaster (corgi::EntityRef entity)
 Get the broadcaster for a given Entity. More...
 
virtual ~GraphComponent ()
 Destructor for GraphComponent.
 
virtual void Init ()
 Initialize the GraphComponent.
 
virtual void AddFromRawData (corgi::EntityRef &entity, const void *raw_data)
 Deserialize a flat binary buffer to create and populate an Entity from raw data. More...
 
virtual RawDataUniquePtr ExportRawData (const corgi::EntityRef &entity) const
 Serializes a GraphComponent's data for a given Entity. More...
 
virtual void UpdateAllEntities (corgi::WorldTime delta_time)
 Broadcasts a kAdvanceFrameEventId event to update all Entities' graphs. More...
 
const corgi::EntityRefgraph_entity () const
 
breadboard::NodeEventBroadcaster * advance_frame_broadcaster ()
 
- Public Member Functions inherited from corgi::Component< GraphData >
 Component ()
 Construct a Component without an EntityManager.
 
virtual ~Component ()
 Destructor for a Component.
 
virtual void AddEntityGenerically (EntityRef &entity)
 Provides an alternate way to add Entities if you do not care about the returned data structure, and if you do not feel like casting the BaseComponent into something more specific. More...
 
GraphData * AddEntity (EntityRef &entity, AllocationLocation alloc_location)
 Adds an Entity to the list that this Component is tracking. More...
 
GraphData * AddEntity (EntityRef &entity)
 Adds an Entity to the list that this Component is tracking. More...
 
virtual void RemoveEntity (EntityRef &entity)
 Removes an Entity from the list of Entities. More...
 
virtual EntityIterator RemoveEntity (EntityIterator iter)
 Removes an Entity from the list of Entities. More...
 
virtual EntityIterator begin ()
 Gets an iterator that will iterate over every Entity associated with the Component, starting from the beginning. More...
 
virtual EntityIterator end ()
 Gets an iterator that points to the end of the list of all entites in the Component. More...
 
virtual bool HasDataForEntity (const EntityRef &entity)
 Checks if this component contains any data associated with the supplied entity.
 
virtual void * GetComponentDataAsVoid (const EntityRef &entity)
 Gets the data for a given Entity as a void pointer. More...
 
virtual const void * GetComponentDataAsVoid (const EntityRef &entity) const
 Gets the data for a given Entity as a const void pointer. More...
 
GraphData * GetComponentData (size_t data_index)
 Gets the Component data stored at a given index. More...
 
GraphData * GetComponentData (const EntityRef &entity)
 Gets the data for a given Entity. More...
 
const GraphData * GetComponentData (size_t data_index) const
 Gets the Component data stored at a given index. More...
 
const GraphData * GetComponentData (const EntityRef &entity) const
 Gets the data for a given Entity. More...
 
virtual void ClearComponentData ()
 Clears all tracked Component data.
 
ComponentDataType * Data (const EntityRef &entity)
 A utility function for retrieving the Component data for an Entity from a specific Component. More...
 
ComponentDataType * Data (const EntityRef &entity) const
 A utility function for retrieving the Component data for an Entity from a specific Component. More...
 
bool IsRegisteredWithComponent (const EntityRef &entity)
 A utility function for checking if an entity is registered with a particular component. More...
 
ComponentDataType * GetComponent ()
 A utility function for retrieving a reference to a specific Component object, by type. More...
 
virtual void InitEntity (EntityRef &)
 Override this function with code that should be executed when an Entity is added to the Component.
 
virtual void Cleanup ()
 Override this function with any code that executes when this Component is removed from the EntityManager. (i.e. Usually when the game/state is over and everything is shutting down.)
 
virtual void CleanupEntity (EntityRef &)
 Override this function with any code that needs to be executed when an Entity is removed from this Component.
 
virtual void SetEntityManager (EntityManager *entity_manager)
 Set the EntityManager for this Component. More...
 
virtual void SetComponentIdOnDataType (ComponentId id)
 Sets the Component ID on the data type. More...
 
- Public Member Functions inherited from corgi::ComponentInterface
virtual ~ComponentInterface ()
 A destructor for the Component interface.
 

Additional Inherited Members

- Public Types inherited from corgi::Component< GraphData >
typedef VectorPool
< ComponentData >::Iterator 
EntityIterator
 An iterator to iterate through all of the Entities in the Component.
 
typedef GraphData value_type
 The templated data type stored by this Component.
 
- Public Types inherited from corgi::ComponentInterface
typedef std::unique_ptr
< uint8_t, std::function< void(uint8_t *)> > 
RawDataUniquePtr
 A pointer type for exported raw data.
 
- Static Public Member Functions inherited from corgi::Component< GraphData >
static ComponentId GetComponentId ()
 Get the ID for this Component. More...
 
- Protected Member Functions inherited from corgi::Component< GraphData >
size_t GetComponentDataIndex (const EntityRef &entity) const
 Get the index of the Component data for a given Entity. More...
 
- Protected Attributes inherited from corgi::Component< GraphData >
VectorPool< ComponentData > component_data_
 Storage for all of the data for the Component.
 
EntityManagerentity_manager_
 A pointer to the EntityManager for this Component. This is the main point of contact for Components that need to talk to other things.
 
std::unordered_map
< EntityIdType, ComponentIndex
component_index_lookup_
 A map, for translating unique entity IDs into vectorpool indexes.
 

Member Function Documentation

virtual void corgi::component_library::GraphComponent::AddFromRawData ( corgi::EntityRef entity,
const void *  raw_data 
)
virtual

Deserialize a flat binary buffer to create and populate an Entity from raw data.

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

Implements corgi::ComponentInterface.

breadboard::NodeEventBroadcaster* corgi::component_library::GraphComponent::advance_frame_broadcaster ( )
inline
Returns
Returns a pointer to the NodeEventBroadcaster that is called once per frame.
void corgi::component_library::GraphComponent::EntityPostLoadFixup ( corgi::EntityRef entity)

Fixes up a given Entity.

Parameters
[in]entityAn EntityRef reference to the Entity that will be fixed up.
virtual RawDataUniquePtr corgi::component_library::GraphComponent::ExportRawData ( const corgi::EntityRef entity) const
virtual

Serializes a GraphComponent's data for a given Entity.

Parameters
[in]entityAn EntityRef reference to an Entity whose corresponding GraphData will be serialized.
Returns
Returns a RawDataUniquePtr to the start of the raw data in a flat binary buffer.

Reimplemented from corgi::Component< GraphData >.

breadboard::NodeEventBroadcaster* corgi::component_library::GraphComponent::GetCreateBroadcaster ( corgi::EntityRef  entity)

Get the broadcaster for a given Entity.

Parameters
[in]entityAn EntityRef to the Entity whose broadcaster should be returned.
Returns
Returns a NodeEventBroadcaster for the Entity, even if it does not yet have one.
const corgi::EntityRef& corgi::component_library::GraphComponent::graph_entity ( ) const
inline
Returns
Returns a const EntityRef reference to the Entity that is currently being initialized.

During initialization, this value iterates over each Entity, one at a time.

Note
After initialization, the return value from this function is not meaningful. It would simply return the last Entity that was initialized.
void corgi::component_library::GraphComponent::PostLoadFixup ( )

Fixes up all loaded Entities.

Note
If you create single Entities later, individual calls to EntityPostLoadFixup are required on a per-Entity basis.
virtual void corgi::component_library::GraphComponent::UpdateAllEntities ( corgi::WorldTime  delta_time)
virtual

Broadcasts a kAdvanceFrameEventId event to update all Entities' graphs.

Parameters
[in]delta_timeA WorldTime corresponding to the delta time since the last call to this function.

Reimplemented from corgi::Component< GraphData >.


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