39 template<
typename TYPE>
68template<
typename TYPE>
75 TYPE& value = *(
static_cast<TYPE*
>(ptr));
76 reader->Get(value, name);
82 TYPE& value = *(
static_cast<TYPE*
>(ptr));
83 writer->Add(value, name);
89 if (!reg->ValidateTypeSize(component,
sizeof(TYPE)))
91 n_error(
"Trying to add a serializer that works on different sized component compared to what is registered in the MemDb::AttributeRegistry!");
98 while (reg->serializers.Size() <= component.id)
100 reg->serializers.Grow();
101 reg->serializers.Resize(reg->serializers.Capacity());
104 reg->serializers[component.id] = s;
Component serialization functions.
Definition componentserialization.h:31
static void Destroy()
This static method is used to destroy the registry object and should be called right before the main ...
Definition componentserialization.cc:39
ComponentSerialization()
Definition componentserialization.cc:73
static void Serialize(Ptr< IO::JsonWriter > const &writer, ComponentId component, void *ptr)
ptr points to the value that should be stored
Definition componentserialization.cc:63
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!
Definition componentserialization.cc:52
~ComponentSerialization()
Definition componentserialization.cc:81
Util::Array< Serializer > serializers
Definition componentserialization.h:62
static void Register(ComponentId component)
Definition componentserialization.h:70
static ComponentSerialization * Instance()
The registry's constructor is called by the Instance() method, and nobody else.
Definition componentserialization.cc:22
static ComponentSerialization * Singleton
Definition componentserialization.h:51
bool ValidateTypeSize(ComponentId component, uint32_t size)
validate that the size of MemDb::AttributeRegistry's component named 'name' has typesize of 'size'
Definition componentserialization.cc:90
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
Nebula's dynamic array class.
Definition array.h:60
Nebula delegate class, allows to store a function, method or lambda call into a C++ object for later ...
Definition delegate.h:39
void __cdecl n_error(const char *msg,...)
This function is called when a serious situation is encountered which requires abortion of the applic...
Definition debug.cc:138
Game::EditorState.
Definition graphicsmanager.h:60
Definition componentserialization.h:57
DeserializeJsonFunc deserializeJson
Definition componentserialization.h:58
SerializeJsonFunc serializeJson
Definition componentserialization.h:59
Definition attributeid.h:19