Loading...
Searching...
No Matches
hellfire::ComponentRegistry Class Reference

#include <ComponentRegistry.h>

Collaboration diagram for hellfire::ComponentRegistry:

Public Types

using SerializeFn = std::function< nlohmann::json(const Entity &)>
 
using DeserializeFn = std::function< void(Entity &, const nlohmann::json &)>
 
using HasComponentFn = std::function< bool(const Entity &)>
 

Public Member Functions

 ComponentRegistry (const ComponentRegistry &)=delete
 
ComponentRegistryoperator= (const ComponentRegistry &)=delete
 
template<ComponentType T>
void register_component (const std::string &type_name)
 
nlohmann::json serialize_all_components (const Entity &entity) const
 
bool deserialize_component (Entity &entity, const nlohmann::json &comp_json) const
 
void deserialize_all_components (Entity &entity, const nlohmann::json &components) const
 

Static Public Member Functions

static ComponentRegistryinstance ()
 

Private Member Functions

 ComponentRegistry ()=default
 

Private Attributes

std::unordered_map< std::type_index, std::string > type_names_
 
std::unordered_map< std::string, std::type_index > name_to_type_
 
std::unordered_map< std::type_index, HasComponentFnhas_component_
 
std::unordered_map< std::type_index, SerializeFnserializers_
 
std::unordered_map< std::string, DeserializeFndeserializers_
 

Detailed Description

Definition at line 17 of file ComponentRegistry.h.

Member Typedef Documentation

◆ DeserializeFn

using hellfire::ComponentRegistry::DeserializeFn = std::function<void(Entity&, const nlohmann::json &)>

Definition at line 20 of file ComponentRegistry.h.

◆ HasComponentFn

using hellfire::ComponentRegistry::HasComponentFn = std::function<bool(const Entity&)>

Definition at line 21 of file ComponentRegistry.h.

◆ SerializeFn

using hellfire::ComponentRegistry::SerializeFn = std::function<nlohmann::json(const Entity&)>

Definition at line 19 of file ComponentRegistry.h.

Constructor & Destructor Documentation

◆ ComponentRegistry() [1/2]

hellfire::ComponentRegistry::ComponentRegistry ( const ComponentRegistry )
delete

◆ ComponentRegistry() [2/2]

hellfire::ComponentRegistry::ComponentRegistry ( )
privatedefault

Member Function Documentation

◆ deserialize_all_components()

void hellfire::ComponentRegistry::deserialize_all_components ( Entity entity,
const nlohmann::json &  components 
) const
inline

Definition at line 83 of file ComponentRegistry.h.

◆ deserialize_component()

bool hellfire::ComponentRegistry::deserialize_component ( Entity entity,
const nlohmann::json &  comp_json 
) const
inline

Definition at line 72 of file ComponentRegistry.h.

◆ instance()

static ComponentRegistry & hellfire::ComponentRegistry::instance ( )
inlinestatic

Definition at line 23 of file ComponentRegistry.h.

◆ operator=()

ComponentRegistry & hellfire::ComponentRegistry::operator= ( const ComponentRegistry )
delete

◆ register_component()

template<ComponentType T>
void hellfire::ComponentRegistry::register_component ( const std::string &  type_name)
inline

Definition at line 34 of file ComponentRegistry.h.

◆ serialize_all_components()

nlohmann::json hellfire::ComponentRegistry::serialize_all_components ( const Entity entity) const
inline

Definition at line 58 of file ComponentRegistry.h.

Member Data Documentation

◆ deserializers_

std::unordered_map<std::string, DeserializeFn> hellfire::ComponentRegistry::deserializers_
private

Definition at line 96 of file ComponentRegistry.h.

◆ has_component_

std::unordered_map<std::type_index, HasComponentFn> hellfire::ComponentRegistry::has_component_
private

Definition at line 94 of file ComponentRegistry.h.

◆ name_to_type_

std::unordered_map<std::string, std::type_index> hellfire::ComponentRegistry::name_to_type_
private

Definition at line 93 of file ComponentRegistry.h.

◆ serializers_

std::unordered_map<std::type_index, SerializeFn> hellfire::ComponentRegistry::serializers_
private

Definition at line 95 of file ComponentRegistry.h.

◆ type_names_

std::unordered_map<std::type_index, std::string> hellfire::ComponentRegistry::type_names_
private

Definition at line 92 of file ComponentRegistry.h.


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