Serialization System
This project is a serialization system that can serialize and deserialize C++ objects to and from custom files. The system is designed to be easy to use and flexible, allowing for the serialization of complex data structures.
The system was also made with the idea in mind of reflection to be able to automatically create a renderer to render a specific object without having to write a renderer for each object.
To make it easy to use I created a macro that can be used to define how to serialize and deserialize an object.
class Component : public DOT::Serializable
{
private:
CU::GUID myGUID;
CU::GUID myOwnerGUID;
bool myIsActive = true;
public:
Class_DOT_Definition(Component, myGUID, myOwnerGUID, myIsActive)
};
The system also supports polymorphism, so you can serialize a base class, and if that variable stores a derived class then the system will automatically serialize the derived class, and when they deserialize the data the derived class will be intact.
The only things required are to use the correct macro in the h file and also use a macro in the classes cpp file
// H file
class LightComponent : public Component
{
protected:
CU::Vector3f myColor = {1,1,1};
float myIntensity = 1;
public:
Child_DOT_Definition(LightComponent, Component, myColor, myIntensity)
};
// CPP file
REGISTER_DOT_Child(LightComponent)
This polymorphism is also supported in vectors, so you can have a vector of base class smart pointers and the system will automatically serialize and deserialize the derived classes.
The system is made so that if you can serialize an object then you can have another object that contains that object and the system will automatically be able to serialize and deserialize that object.
Because of the polymorphism ability the objects have to inherit a base class, and then have a macro inside its definition, but if this is not possible then there is a way to define a serialization and deserialization function for an object. Outside of the object itself.
// H file
External_DOT_Definition(CU::Vector3f, x, y, z)
The system architecture is built in such a way to allow for adding and removing variables from a serialized type while keeping all none changed data, so programmers can change classes without any data being lost.