Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/system/ComponentManager.h
Context not available. | |||||
#include "simulation2/system/Components.h" | #include "simulation2/system/Components.h" | ||||
#include "simulation2/system/Entity.h" | #include "simulation2/system/Entity.h" | ||||
#include "simulation2/system/IComponent.h" | #include "simulation2/system/IComponent.h" | ||||
#include "simulation2/system/ComponentDataHolder.h" | |||||
#include <boost/random/linear_congruential.hpp> | #include <boost/random/linear_congruential.hpp> | ||||
#include <map> | #include <map> | ||||
Context not available. | |||||
InterfaceId iid; | InterfaceId iid; | ||||
AllocFunc alloc; | AllocFunc alloc; | ||||
jprahman: nit: Should AllocFunc -> ConstructFunc for symmetry and precision (since allocation is not… | |||||
DeallocFunc dealloc; | DeallocFunc dealloc; | ||||
size_t size; | |||||
size_t align; | |||||
std::string name; | std::string name; | ||||
std::string schema; // RelaxNG fragment | std::string schema; // RelaxNG fragment | ||||
std::unique_ptr<JS::PersistentRootedValue> ctor; // only valid if type == CT_Script | std::unique_ptr<JS::PersistentRootedValue> ctor; // only valid if type == CT_Script | ||||
}; | }; | ||||
std::unordered_map<ComponentTypeId, CComponentDataHolder*> m_ComponentData; | |||||
Done Inline ActionsThese are owning pointer right? Why not storing the actual objects? phosit: These are owning pointer right? Why not storing the actual objects? | |||||
public: | public: | ||||
CComponentManager(CSimContext&, std::shared_ptr<ScriptContext> cx, bool skipScriptFunctions = false); | CComponentManager(CSimContext&, std::shared_ptr<ScriptContext> cx, bool skipScriptFunctions = false); | ||||
Context not available. | |||||
void RegisterMessageType(MessageTypeId mtid, const char* name); | void RegisterMessageType(MessageTypeId mtid, const char* name); | ||||
void RegisterComponentType(InterfaceId, ComponentTypeId, AllocFunc, DeallocFunc, const char*, const std::string& schema); | void RegisterComponentType(InterfaceId, ComponentTypeId, AllocFunc, DeallocFunc, size_t size, size_t align, const char*, const std::string& schema); | ||||
void RegisterComponentTypeScriptWrapper(InterfaceId, ComponentTypeId, AllocFunc, DeallocFunc, const char*, const std::string& schema); | void RegisterComponentTypeScriptWrapper(InterfaceId, ComponentTypeId, AllocFunc, DeallocFunc, size_t size, size_t align, const char*, const std::string& schema); | ||||
void MarkScriptedComponentForSystemEntity(CComponentManager::ComponentTypeId cid); | void MarkScriptedComponentForSystemEntity(CComponentManager::ComponentTypeId cid); | ||||
Context not available. | |||||
using InterfaceListUnordered = std::unordered_map<entity_id_t, IComponent*>; | using InterfaceListUnordered = std::unordered_map<entity_id_t, IComponent*>; | ||||
InterfaceList GetEntitiesWithInterface(InterfaceId iid) const; | InterfaceList GetEntitiesWithInterface(InterfaceId iid) const; | ||||
const InterfaceListUnordered& GetEntitiesWithInterfaceUnordered(InterfaceId iid) const; | SComponentDataGenerator* GetEntitiesWithInterfaceUnordered(InterfaceId iid) const; | ||||
/** | /** | ||||
* Send a message, targeted at a particular entity. The message will be received by any | * Send a message, targeted at a particular entity. The message will be received by any | ||||
Context not available. | |||||
std::map<ComponentTypeId, ComponentType> m_ComponentTypesById; | std::map<ComponentTypeId, ComponentType> m_ComponentTypesById; | ||||
std::vector<CComponentManager::ComponentTypeId> m_ScriptedSystemComponents; | std::vector<CComponentManager::ComponentTypeId> m_ScriptedSystemComponents; | ||||
std::vector<std::unordered_map<entity_id_t, IComponent*> > m_ComponentsByInterface; // indexed by InterfaceId | std::vector<std::unordered_map<entity_id_t, IComponent*> > m_ComponentsByInterface; // indexed by InterfaceId | ||||
std::vector<CComponentDataHolder*> m_ComponentDataByInterface; // indexed by InterfaceId | |||||
std::map<ComponentTypeId, std::map<entity_id_t, IComponent*> > m_ComponentsByTypeId; | std::map<ComponentTypeId, std::map<entity_id_t, IComponent*> > m_ComponentsByTypeId; | ||||
std::map<MessageTypeId, std::vector<ComponentTypeId> > m_LocalMessageSubscriptions; | std::map<MessageTypeId, std::vector<ComponentTypeId> > m_LocalMessageSubscriptions; | ||||
std::map<MessageTypeId, std::vector<ComponentTypeId> > m_GlobalMessageSubscriptions; | std::map<MessageTypeId, std::vector<ComponentTypeId> > m_GlobalMessageSubscriptions; | ||||
Context not available. |
Wildfire Games · Phabricator
nit: Should AllocFunc -> ConstructFunc for symmetry and precision (since allocation is not handled by the pool allocator)?