ObjectSystem¶
Inherited: None
Description¶
ObjectSystem helps to developers create new instances and serialize/deserialize them on disc or in memory.
Public Methods¶
ObjectSystem () |
|
void |
addObject (Object * object) |
bool |
compareTreads (ObjectSystem * system) const |
Object::ObjectList |
getAllObjectsByType (const TString & type) const |
Object * |
instantiateObject (const MetaObject * meta, const TString & name, Object * parent) |
void |
Static Methods¶
void |
blockObjectCache (bool flag) |
ObjectSystem::GroupMap |
factories () |
Object * |
findObject (uint32_t uuid) |
Object * |
findRoot (Object * object) |
uint32_t |
generateUUID () |
ObjectSystem::FactoryPair |
metaFactory (const TString & url) |
Object * |
objectCreate (const TString & url, const TString & name = TString(), Object * parent = nullptr, uint32_t id = 0) |
void |
replaceClonedUUID (Object * object, uint32_t uuid) |
void |
replaceUUID (Object * object, uint32_t uuid) |
Object * |
toObject (const Variant & variant, Object * parent = nullptr, const TString & name = TString()) |
toVariant (const Object * object, bool force = false) |
Methods Description¶
ObjectSystem::ObjectSystem ()
Constructs ObjectSystem.
ObjectSystem::~ObjectSystem ()
Destructs ObjectSystem, related objects and registered object factories.
void ObjectSystem::addObject (Object * object)
Adds an object to main pull of objects in ObjectSystem
void ObjectSystem::blockObjectCache (bool flag)
This function sets a flag that prevents objects from being cached for fast lookup.
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.
Object * ObjectSystem::findObject (uint32_t uuid)
Returns object with uuid. If the object doesn’t exist in the hierarchy this method returns nullptr.
Returns root object in the hierarchy.
uint32_t ObjectSystem::generateUUID ()
Returns the new unique ID based on random number generator.
Object::ObjectList ObjectSystem::getAllObjectsByType (TString & type) const
Returns a list of objects with specified type.
Warning: This is very small function!
Object * ObjectSystem::instantiateObject (MetaObject * meta, TString & 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.
ObjectSystem::FactoryPair ObjectSystem::metaFactory (TString & url)
Returns MetaObject for registered factory by provided url.
Returns new instance of type represented in url and name as child of parent object.
Note: Class represented as url should be registered first via factoryAdd()
Note: Optional id parameter can be used to set custom object identifier. If set to 0, a new UUID is automatically generated for the instance.
void ObjectSystem::processEvents ()
Updates all related objects.
void ObjectSystem::replaceClonedUUID (Object * object, uint32_t uuid)
Replaces current cloned uuid of the object with the new one.
Note: This is a service function. Developers shouldn’t call it manually.
void ObjectSystem::replaceUUID (Object * object, uint32_t uuid)
Replaces current uuid of the object with the new one.
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.
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.