![]() |
Safir SDK Core
|
This class is an object factory for all automatically generated DOB classes. More...
#include <Safir/Dob/Typesystem/ObjectFactory.h>
Public Member Functions | |
ObjectPtr | CreateObject (const TypeId typeId) const |
Create a new "empty" object from a typeid. | |
std::vector< std::pair< TypeId, Int64 > > | GetRegisteredTypes () const |
GetRegisteredTypes - Get types wich have been registered in the ObjectFactory. | |
Blob deserialization part. | |
ObjectPtr | CreateObject (char const *const blob) const |
Create a new object from a blob. | |
Static Public Member Functions | |
static ObjectFactory & | Instance () |
Get the instance of the singleton. | |
Registration part. | |
Stuff for registering classes with the object factory. | |
typedef ObjectPtr(* | CreateObjectCallback) (Int64 handle) |
Function signature of the create callback function. | |
bool | RegisterClass (const TypeId typeId, const Int64 checksum, CreateObjectCallback createFunction) |
Register a class with the object factory. | |
This class is an object factory for all automatically generated DOB classes.
Each generated class automatically registers itself with this class. Users can call the CreateObject(TypeId) routine to create objects of a desired type (this is if they receive the type id from some other application so that they cannot call the Create routine of the class itself directly).
Function signature of the create callback function.
This is the signature of the function that the object factory will call to create the object. If handle == 0 then just create an empty object.
ObjectPtr Safir::Dob::Typesystem::ObjectFactory::CreateObject | ( | char const *const | blob | ) | const |
Create a new object from a blob.
This method takes a blob and extracts the typeId from it and then calls the appropriate callback to create the object.
blob | [in] - The blob to deserialize. |
IllegalValueException | If the type represented by the blob isn't found in the ObjectFactory. |
Create a new "empty" object from a typeid.
This method takes a TypeId and calls the appropriate callback to create an object of the desired type.
typeId | [in] - The TypeId of the object to create. |
IllegalValueException | If the type couldn't be found in the ObjectFactory. |
std::vector< std::pair< TypeId, Int64 > > Safir::Dob::Typesystem::ObjectFactory::GetRegisteredTypes | ( | ) | const |
GetRegisteredTypes - Get types wich have been registered in the ObjectFactory.
Intended for debug and diagnostics.
|
static |
Get the instance of the singleton.
bool Safir::Dob::Typesystem::ObjectFactory::RegisterClass | ( | const TypeId | typeId, |
const Int64 | checksum, | ||
CreateObjectCallback | createFunction ) |
Register a class with the object factory.
typeId | [in] - The TypeId of the object that should be created using createFunction. |
checksum | [in] - Checksum of all members and parameters in the class. |
createFunction | [in] - The function to call to create the object. |