Equalizer
1.2.1
|
Central distributed object registry. More...
#include <objectMap.h>
Public Member Functions | |
CO_API | ObjectMap (ObjectHandler &handler, ObjectFactory &factory) |
Construct a new ObjectMap. | |
virtual CO_API | ~ObjectMap () |
Destroy an ObjectMap. | |
CO_API bool | register_ (Object *object, const uint32_t type) |
Add and register a new object as master instance to this objectMap. | |
CO_API Object * | get (const uint128_t &identifier, Object *instance=0) |
Map and return an object. | |
virtual CO_API uint128_t | commit (const uint32_t incarnation=CO_COMMIT_NEXT) |
Commits all registered objects. | |
Protected Member Functions | |
virtual CO_API bool | isDirty () const |
virtual CO_API void | serialize (DataOStream &os, const uint64_t dirtyBits) |
Worker for pack() and getInstanceData(). | |
virtual CO_API void | deserialize (DataIStream &is, const uint64_t dirtyBits) |
Worker for unpack() and applyInstanceData(). | |
virtual ChangeType | getChangeType () const |
virtual CO_API void | notifyAttached () |
Notify that this object has been registered or mapped. | |
Protected Types | |
enum | DirtyBits { DIRTY_ADDED = Serializable::DIRTY_CUSTOM << 0, DIRTY_CHANGED = Serializable::DIRTY_CUSTOM << 1, DIRTY_CUSTOM = Serializable::DIRTY_CUSTOM << 2 } |
The changed parts of the object since the last serialize(). More... |
Central distributed object registry.
Definition at line 29 of file objectMap.h.
enum co::ObjectMap::DirtyBits [protected] |
The changed parts of the object since the last serialize().
Reimplemented from co::Serializable.
Definition at line 95 of file objectMap.h.
CO_API co::ObjectMap::ObjectMap | ( | ObjectHandler & | handler, |
ObjectFactory & | factory | ||
) |
Construct a new ObjectMap.
handler | used for object registration and mapping |
factory | to create & destroy slave objects |
virtual CO_API co::ObjectMap::~ObjectMap | ( | ) | [virtual] |
Destroy an ObjectMap.
All registered and mapped objects will be deregistered and unmapped. All mapped objects will be destroyed using the object factory.
virtual CO_API uint128_t co::ObjectMap::commit | ( | const uint32_t | incarnation = CO_COMMIT_NEXT | ) | [virtual] |
virtual CO_API void co::ObjectMap::deserialize | ( | DataIStream & | , |
const uint64_t | |||
) | [protected, virtual] |
Worker for unpack() and applyInstanceData().
This function is called with the dirty bits send by the master instance. The dirty bits are received beforehand, and do not need to be deserialized by the overriding method.
Reimplemented from co::Serializable.
CO_API Object* co::ObjectMap::get | ( | const uint128_t & | identifier, |
Object * | instance = 0 |
||
) |
Map and return an object.
The object is either created via its type specified upon registering or an already created instance is used if passed to this function. The object will be mapped to the version that was current on registration time.
identifier | unique object identifier used for map operation |
instance | already created instance to skip factory creation |
virtual ChangeType co::ObjectMap::getChangeType | ( | ) | const [inline, protected, virtual] |
Reimplemented from co::Serializable.
Definition at line 90 of file objectMap.h.
References co::Object::DELTA.
virtual CO_API bool co::ObjectMap::isDirty | ( | ) | const [protected, virtual] |
Reimplemented from co::Serializable.
virtual CO_API void co::ObjectMap::notifyAttached | ( | ) | [protected, virtual] |
Notify that this object has been registered or mapped.
The method is called from the thread initiating the registration or mapping, after the operation has been completed successfully.
Reimplemented from co::Serializable.
CO_API bool co::ObjectMap::register_ | ( | Object * | object, |
const uint32_t | type | ||
) |
Add and register a new object as master instance to this objectMap.
Upon registering using the object handler, this object will be remembered for serialization on the next call to commit.
object | the new object to add and register |
type | unique object type to create object via slave factory |
virtual CO_API void co::ObjectMap::serialize | ( | DataOStream & | , |
const uint64_t | |||
) | [protected, virtual] |
Worker for pack() and getInstanceData().
Override this and deserialize() if you want to distribute subclassed data.
This method is called with DIRTY_ALL from getInstanceData() and with the actual dirty bits from pack(), which also resets the dirty state afterwards. The dirty bits are transmitted beforehand, and do not need to be transmitted by the overriding method.
Reimplemented from co::Serializable.