Inherited: Object


ObjectSystem helps to developers create new instances and serialize/deserialize them on disc or in memory.

Public Methods

ObjectSystem ()

~ObjectSystem ()


compareTreads (ObjectSystem * system) const

template <typename T> void

factoryAdd (const std::string & group, const MetaObject * meta)

template <typename T> void

factoryRemove (const std::string & group)


getAllObjectsByType (const std::string & type) const

Object *

instantiateObject (const MetaObject * meta, const std::string & name, Object * parent)


processEvents ()

Public Enums

enum ObjectSystem::FactoryMap

This container holds all registered Objects which can be easily created through objectCreate().

See also objectCreate().

enum ObjectSystem::GroupMap

This container holds links between objects and groups. Groups helps to manage objects and not used directly.

See also objectCreate().

Static Methods


factories ()

Object *

findObject (int uuid, Object * root)

Object *

findRoot (Object * object)


generateUUID ()

ObjectSystem::FactoryPair *

metaFactory (const std::string & uri)

template <typename T> T

objectCreate (const std::string & name = …, Object * parent = 0)

Object *

objectCreate (const std::string & uri, const std::string & name = …, Object * parent = nullptr)


replaceUUID (Object * object, int uuid)

Object *

toObject (const Variant & variant, Object * parent = nullptr, const std::string & name = …)


toVariant (const Object * object, bool force = false)

Methods Description

ObjectSystem::ObjectSystem ()

Constructs ObjectSystem.

ObjectSystem::~ObjectSystem ()

Destructs ObjectSystem, related objects and registered object factories.

bool ObjectSystem::compareTreads (ObjectSystem * system) const

Returns true in case of other system execues in the same thread with current system; otherwise returns false.

ObjectSystem::GroupMap ObjectSystem::factories ()

Returns all registered classes.

template <typename T> void ObjectSystem::factoryAdd (std::string & group, MetaObject * meta)

Registers class with T type, meta object and group to object instantiation mechanism.

Note: New classes inherited from base Object class can be automaticaly registered using T::registerClassFactory(). This is preferable way to use this functionality.

template <typename T> void ObjectSystem::factoryRemove (std::string & group)

Unregisters class with type T and group from object instantiation mechanism.

Note: The preferable way to use this function is T::unregisterClassFactory() invocation.

Object * root)

Returns object with uuid or which was clonned from this. This algorithm recursively going down from the root object If the object doesn’t exist in the hierarchy this method returns nullptr.

Object * object)

Returns root object in the hierarchy.

int ObjectSystem::generateUUID ()

Returns the new unique ID based on random number generator.

Object::ObjectList ObjectSystem::getAllObjectsByType (std::string & type) const

Returns a list of objects with specified type.

Warning: This is very small function!

Object * meta, std::string & name, Object * parent)

The basic method to spawn a new object based on the provided meta object, name of object and parent object. Returns a pointer to spawned object.

:ref:`ObjectSystem::FactoryPair<api_ObjectSystem::FactoryPair>`* ObjectSystem::metaFactory (std::string & uri)

Returns MetaObject for registered factory by provided uri.

template <typename T> T ObjectSystem::objectCreate (std::string & name = …, Object * parent = 0)

Returns new instance of type T and name as child of parent object.

Note: Class T should be registered first via factoryAdd()

See also factoryAdd() and factoryRemove().

Object * parent = nullptr)

Returns new instance of type represented in uri and name as child of parent object.

Note: Class represented as uri should be registered first via factoryAdd()

See also factoryAdd() and factoryRemove().

void ObjectSystem::processEvents ()

Updates all related objects.

void ObjectSystem::replaceUUID (Object * object, int uuid)

Replaces current uuid of the object with the new one.

Object & variant, Object * parent = nullptr, std::string & name = …)

Returns object deserialized from variant based representation. The Variant representation can be loaded from BSON or JSON formats or retrieved from memory. Deserialization will try to restore objects hierarchy with parent, its properties and connections. The root object will be created with a name in case of this parameter provided.

Variant ObjectSystem::toVariant (Object * object, bool force = false)

Returns serialized to Variant version of object inherited from Object class. This method saves all object property values, active connections and necessary parameters.

Note: All childs of object will be also serialized.

Note: Function will ignore Object::isSerializable in case of force flag provided.

The returned value can be saved on disk in BSON or JSON form or keep it in memory. Developers is able to save own data using Object::saveUserData() mechanism.