Latest version: 0.7.0, download

Introduction

ObjSys is a C++ based objection serialization system. This means that it can serialize objects into, and from, packages. It can save entire groups of objects, including their references into a file, and later restore all of the objects and their references with a single function call.
Besides serializing objects, it can also determine and update references, and perform garbage collecting. While there is some object management going on that is visible to the user, the actual saving and loading of objects, as well as reference updating and garbage collecting is done using a single function per class, that in normal cases isn't more than just streaming in the persisent members of the class. Additionally, constructing new objects and destructing old objects is still done through the standard C++ new and delete operators, while no custom new and delete operators are necessary.

The library has a C++ interface only, and uses STL a lot. This means that serializing vectors, sets and lists is very easy. A class that has a member that is a vector of pointers to objects, the entire member can simply be streamed in a single, simple call.
When saving a package, this will automatically store the amount of objects and save all the objects in the vector. When loading, it automatically loads the original amount of objects and recreates all the objects that were in the vector. When collecting garbage, all objects are automatically checked for references.

Example usage

One of the type of projects this library is very suitable for is a game engine. A game contains lots of references to all kinds of different objects, and often needs serializing from file (textures, models, entities), serializing to file (save games), and garbage collecting. To make the use of this library within such a project more clear, take a look at the following diagram:



Wouldn't it be nice to have packages that contain the same type of objects - i.e. textures - and name them to further signify the contents? E.g. have a FluidTextures package containing all kinds of water, lava and slime textures, have a RockTextures package that contains all kinds of rock textures with and without grass, and so on, have a SkyTextures package that contains various textures used when rendering sky boxes? With the ObjSys library you can, and to use/load those packages, all you have to do is set a reference to the object by assigning a pointer value, and make the variable persistent.
The diagram shows a quick example: you have a level package (CoolLevel) that contains four objects. These objects reference each other, but some of the objects also reference objects that are in different packages (CoolTextures and CoolLogic). To create such a setup, all you have to do is define your own classes, base them off the base ObjSys base class, create members just like you are used to do and assign pointers, just like you are used to do. Then all you need to do is put them in packages by creating a new ObjSys package, add the existing objects to the packages and save the packages! When you then want to load the level in a different session of your application, you call a function and specify the name: PackageName.ObjectName and all dependencies and external imported packages and the necessary objects are all automatically loaded!

More information/Testing

I wrote this library just for fun. I needed a low level C++ project and decided a object serialization system was cool to write. I tested it only with the example program I included, but it runs flawless on all operating systems and valgrind doesn't complain at all.
If you think the system is cool, use it. If you encounter bugs, be sure to mail me (contact information can be found in the released packages).

Download

All available versions