Collage  0.6.1
Public Member Functions | Protected Member Functions | Protected Types
co::ObjectMap Class Reference

Central distributed object registry. More...

#include <objectMap.h>

+ Inheritance diagram for co::ObjectMap:
+ Collaboration diagram for co::ObjectMap:

List of all members.

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 Objectget (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...

Detailed Description

Central distributed object registry.

Definition at line 29 of file objectMap.h.


Member Enumeration Documentation

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.


Constructor & Destructor Documentation

CO_API co::ObjectMap::ObjectMap ( ObjectHandler handler,
ObjectFactory factory 
)

Construct a new ObjectMap.

Parameters:
handlerused for object registration and mapping
factoryto create & destroy slave objects
Version:
0.5.1
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.

Version:
0.5.1

Member Function Documentation

virtual CO_API uint128_t co::ObjectMap::commit ( const uint32_t  incarnation = CO_COMMIT_NEXT) [virtual]

Commits all registered objects.

Version:
0.5.1

Reimplemented from co::Serializable.

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.

See also:
serialize()
Version:
1.0

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.

Parameters:
identifierunique object identifier used for map operation
instancealready created instance to skip factory creation
Returns:
0 if not registered, the valid instance otherwise
Version:
0.5.1
virtual ChangeType co::ObjectMap::getChangeType ( ) const [inline, protected, virtual]
Returns:
how the changes are to be handled.

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]
Returns:
true if the serializable has to be committed.
Version:
1.0

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.

See also:
isMaster()

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.

Parameters:
objectthe new object to add and register
typeunique object type to create object via slave factory
Returns:
false on failed ObjectHandler::registerObject, true otherwise
Version:
0.5.1
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.

Version:
1.0

Reimplemented from co::Serializable.


The documentation for this class was generated from the following file:
Generated on Mon Nov 26 2012 14:41:44 for Collage 0.6.1 by  doxygen 1.7.6.1