Nebula
Loading...
Searching...
No Matches
Game::ComponentSerialization Class Reference

#include <componentserialization.h>

Detailed Description

Component serialization functions.

Implements various serialization functions for different types of components

Classes

struct  Serializer
 

Public Types

enum  OverridableType { ENTITY , RESOURCE , NUM_OVERRIDABLE_TYPES }
 
using DeserializeJsonFunc = std::function<void(Ptr<IO::JsonReader> const&, const char* name, void*)>
 
using SerializeJsonFunc = std::function<void(Ptr<IO::JsonWriter> const&, const char* name, void*)>
 

Static Public Member Functions

static ComponentSerializationInstance ()
 The registry's constructor is called by the Instance() method, and nobody else.
 
static void Destroy ()
 This static method is used to destroy the registry object and should be called right before the main function exits.
 
template<typename TYPE>
static void Register (ComponentId component)
 
static void Deserialize (Ptr< IO::JsonReader > const &reader, ComponentId component, void *ptr)
 ptr points to the location where the value should be stored. Make sure you have room for it!
 
static void Serialize (Ptr< IO::JsonWriter > const &writer, ComponentId component, void *ptr)
 ptr points to the value that should be stored
 
static void Override (ComponentId component, DeserializeJsonFunc deserialize, SerializeJsonFunc serialize)
 override a specific components serialization and deserialization funcs
 
static void OverrideType (OverridableType type, DeserializeJsonFunc deserialize, SerializeJsonFunc serialize)
 override a specific type serializer. This will be called instead of a standard variant.
 
static DeserializeJsonFuncGetTypeDeserializeFunc (OverridableType type)
 Get the deserialize override for a specific type.
 
static SerializeJsonFuncGetTypeSerializeFunc (OverridableType type)
 Get the serialize override for a specific type.
 

Private Member Functions

 ComponentSerialization ()
 
 ~ComponentSerialization ()
 
bool ValidateTypeSize (ComponentId component, uint32_t size)
 validate that the size of MemDb::AttributeRegistry's component named 'name' has typesize of 'size'
 

Private Attributes

Util::Array< Serializerserializers
 
Serializer typeOverrides [NUM_OVERRIDABLE_TYPES]
 

Static Private Attributes

static ComponentSerializationSingleton = nullptr
 

Member Typedef Documentation

◆ DeserializeJsonFunc

using Game::ComponentSerialization::DeserializeJsonFunc = std::function<void(Ptr<IO::JsonReader> const&, const char* name, void*)>

◆ SerializeJsonFunc

using Game::ComponentSerialization::SerializeJsonFunc = std::function<void(Ptr<IO::JsonWriter> const&, const char* name, void*)>

Member Enumeration Documentation

◆ OverridableType

Enumerator
ENTITY 
RESOURCE 
NUM_OVERRIDABLE_TYPES 

Constructor & Destructor Documentation

◆ ComponentSerialization()

Game::ComponentSerialization::ComponentSerialization ( )
private

◆ ~ComponentSerialization()

Game::ComponentSerialization::~ComponentSerialization ( )
private

Member Function Documentation

◆ Deserialize()

void Game::ComponentSerialization::Deserialize ( Ptr< IO::JsonReader > const & reader,
ComponentId component,
void * ptr )
static

ptr points to the location where the value should be stored. Make sure you have room for it!

◆ Destroy()

void Game::ComponentSerialization::Destroy ( )
static

This static method is used to destroy the registry object and should be called right before the main function exits.

It will make sure that no accidential memory leaks are reported by the debug heap.

◆ GetTypeDeserializeFunc()

ComponentSerialization::DeserializeJsonFunc & Game::ComponentSerialization::GetTypeDeserializeFunc ( OverridableType type)
static

Get the deserialize override for a specific type.

◆ GetTypeSerializeFunc()

ComponentSerialization::SerializeJsonFunc & Game::ComponentSerialization::GetTypeSerializeFunc ( OverridableType type)
static

Get the serialize override for a specific type.

◆ Instance()

ComponentSerialization * Game::ComponentSerialization::Instance ( )
static

The registry's constructor is called by the Instance() method, and nobody else.

◆ Override()

void Game::ComponentSerialization::Override ( ComponentId component,
DeserializeJsonFunc deserialize,
SerializeJsonFunc serialize )
static

override a specific components serialization and deserialization funcs

◆ OverrideType()

void Game::ComponentSerialization::OverrideType ( OverridableType type,
DeserializeJsonFunc deserialize,
SerializeJsonFunc serialize )
static

override a specific type serializer. This will be called instead of a standard variant.

◆ Register()

template<typename TYPE>
void Game::ComponentSerialization::Register ( ComponentId component)
inlinestatic

◆ Serialize()

void Game::ComponentSerialization::Serialize ( Ptr< IO::JsonWriter > const & writer,
ComponentId component,
void * ptr )
static

ptr points to the value that should be stored

◆ ValidateTypeSize()

bool Game::ComponentSerialization::ValidateTypeSize ( ComponentId component,
uint32_t size )
private

validate that the size of MemDb::AttributeRegistry's component named 'name' has typesize of 'size'

Member Data Documentation

◆ serializers

Util::Array<Serializer> Game::ComponentSerialization::serializers
private

◆ Singleton

ComponentSerialization * Game::ComponentSerialization::Singleton = nullptr
staticprivate

◆ typeOverrides

Serializer Game::ComponentSerialization::typeOverrides[NUM_OVERRIDABLE_TYPES]
private

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