Collage  1.4.0
High-performance C++ library for developing object-oriented distributed applications.
co::Serializable Class Reference

Base class for distributed, inheritable objects. More...

#include <serializable.h>

+ Inheritance diagram for co::Serializable:
+ Collaboration diagram for co::Serializable:

Public Member Functions

CO_API uint64_t getDirty () const
 
CO_API bool isDirty () const override
 
virtual CO_API bool isDirty (const uint64_t dirtyBits) const
 
CO_API uint128_t commit (const uint32_t incarnation=CO_COMMIT_NEXT) override
 
- Public Member Functions inherited from co::Object
virtual CO_API ~Object ()
 Destruct the distributed object. More...
 
CO_API bool isAttached () const
 
CO_API LocalNodePtr getLocalNode ()
 
CO_API void setID (const uint128_t &identifier)
 Set the object's unique identifier. More...
 
CO_API const uint128_t & getID () const
 
CO_API uint32_t getInstanceID () const
 
CO_API bool isBuffered () const
 
CO_API bool isMaster () const
 
virtual uint64_t getMaxVersions () const
 Limit the number of queued versions on slave instances. More...
 
virtual CO_API uint32_t chooseCompressor () const
 Return the compressor to be used for data transmission. More...
 
CO_API void push (const uint128_t &groupID, const uint128_t &objectType, const Nodes &nodes)
 Push the instance data of the object to the given nodes. More...
 
CO_API void setAutoObsolete (const uint32_t count)
 Automatically obsolete old versions. More...
 
CO_API uint32_t getAutoObsolete () const
 
virtual CO_API uint128_t sync (const uint128_t &version=VERSION_HEAD)
 Sync to a given version. More...
 
CO_API uint128_t getHeadVersion () const
 
CO_API uint128_t getVersion () const
 
virtual CO_API void notifyNewHeadVersion (const uint128_t &version)
 Notification that a new head version was received by a slave object. More...
 
virtual void notifyNewVersion ()
 Notification that a new version was received by a master object. More...
 
CO_API ObjectOCommand send (NodePtr node, const uint32_t cmd, const uint32_t instanceID=CO_INSTANCE_ALL)
 Send a command with optional data to object instance(s) on another node. More...
 
virtual void notifyAttach ()
 Notify that this object will be registered or mapped. More...
 
virtual CO_API void notifyDetach ()
 Notify that this object will be deregistered or unmapped. More...
 
virtual void notifyDetached ()
 Notify that this object has been deregistered or unmapped. More...
 
uint32_t getMasterInstanceID () const
 
NodePtr getMasterNode ()
 
CO_API void removeSlave (NodePtr node, const uint32_t instanceID)
 
CO_API void removeSlaves (NodePtr node)
 
void setMasterNode (NodePtr node)
 
void addInstanceDatas (const ObjectDataIStreamDeque &, const uint128_t &)
 
void setupChangeManager (const Object::ChangeType type, const bool master, LocalNodePtr localNode, const uint32_t masterInstanceID)
 
virtual CO_API void attach (const uint128_t &id, const uint32_t instanceID)
 
virtual CO_API void detach ()
 
void transfer (Object *from)
 
void applyMapData (const uint128_t &version)
 
void sendInstanceData (Nodes &nodes)
 
- Public Member Functions inherited from co::Dispatcher
Dispatcheroperator= (const Dispatcher &)
 
template<typename T >
void registerCommand (const uint32_t command, const CommandFunc< T > &func, CommandQueue *queue)
 Register a command member function for a command. More...
 
virtual CO_API bool dispatchCommand (ICommand &command)
 Dispatch a command from the receiver thread to the registered queue. More...
 

Protected Types

enum  DirtyBits { DIRTY_NONE = 0, DIRTY_CUSTOM = 1, DIRTY_ALL = 0xFFFFFFFFFFFFFFFFull }
 The changed parts of the serializable since the last pack(). More...
 

Protected Member Functions

CO_API Serializable ()
 Construct a new Serializable. More...
 
CO_API Serializable (const Serializable &)
 Construct an unmapped, unregistered copy of a serializable. More...
 
virtual CO_API ~Serializable ()
 Destruct the serializable. More...
 
Serializableoperator= (const Serializable &from)
 NOP assignment operator. More...
 
virtual void serialize (co::DataOStream &, const uint64_t)
 Worker for pack() and getInstanceData(). More...
 
virtual void deserialize (co::DataIStream &, const uint64_t)
 Worker for unpack() and applyInstanceData(). More...
 
virtual CO_API void setDirty (const uint64_t bits)
 Add dirty flags to mark data for distribution. More...
 
virtual CO_API void unsetDirty (const uint64_t bits)
 Remove dirty flags to clear data from distribution. More...
 
ChangeType getChangeType () const override
 
CO_API void notifyAttached () override
 
void getInstanceData (co::DataOStream &os) final
 Serialize all instance information of this distributed object. More...
 
CO_API void applyInstanceData (co::DataIStream &is) final
 Deserialize the instance data. More...
 
CO_API void pack (co::DataOStream &os) final
 Serialize the modifications since the last call to commit(). More...
 
CO_API void unpack (co::DataIStream &is) final
 Deserialize a change. More...
 
- Protected Member Functions inherited from co::Object
CO_API Object ()
 Construct a new distributed object. More...
 
Objectoperator= (const Object &)
 NOP assignment operator. More...
 
CO_API Object (const Object &)
 Copy construct a new, unattached object. More...
 
- Protected Member Functions inherited from co::Dispatcher
CO_API Dispatcher (const Dispatcher &from)
 
CO_API bool _cmdUnknown (ICommand &command)
 The default handler for handling commands. More...
 

Friends

class detail::Serializable
 

Additional Inherited Members

- Public Types inherited from co::Object
enum  ChangeType {
  NONE, STATIC, INSTANCE, DELTA,
  UNBUFFERED
}
 Object change handling characteristics, see Programming Guide. More...
 
- Public Types inherited from co::Dispatcher
typedef CommandFunc< DispatcherFunc
 The signature of the base Dispatcher callback. More...
 

Detailed Description

Base class for distributed, inheritable objects.

This class implements one usage pattern of Object, which allows subclassing and serialization of distributed Objects using dirty bits.

Definition at line 36 of file serializable.h.

Member Enumeration Documentation

The changed parts of the serializable since the last pack().

Subclasses should define their own bits, starting at DIRTY_CUSTOM.

Version
1.0

Definition at line 100 of file serializable.h.

Constructor & Destructor Documentation

CO_API co::Serializable::Serializable ( )
protected

Construct a new Serializable.

Version
1.0
CO_API co::Serializable::Serializable ( const Serializable )
protected

Construct an unmapped, unregistered copy of a serializable.

Version
1.0
virtual CO_API co::Serializable::~Serializable ( )
protectedvirtual

Destruct the serializable.

Version
1.0

Member Function Documentation

CO_API void co::Serializable::applyInstanceData ( co::DataIStream is)
finalprotectedvirtual

Deserialize the instance data.

This method is called during object mapping to populate slave instances with the master object's data.

Parameters
isthe input stream.
Version
1.0

Implements co::Object.

CO_API uint128_t co::Serializable::commit ( const uint32_t  incarnation = CO_COMMIT_NEXT)
overridevirtual
See also
Object::commit()

Reimplemented from co::Object.

virtual void co::Serializable::deserialize ( co::DataIStream ,
const uint64_t   
)
inlineprotectedvirtual

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 in co::ObjectMap.

Definition at line 92 of file serializable.h.

ChangeType co::Serializable::getChangeType ( ) const
inlineoverrideprotectedvirtual
See also
Object::getChangeType()

Reimplemented from co::Object.

Definition at line 114 of file serializable.h.

References co::Object::DELTA.

CO_API uint64_t co::Serializable::getDirty ( ) const
Returns
the current dirty bit mask.
Version
1.0
void co::Serializable::getInstanceData ( co::DataOStream os)
inlinefinalprotectedvirtual

Serialize all instance information of this distributed object.

Parameters
osThe output stream.
Version
1.0

Implements co::Object.

Definition at line 119 of file serializable.h.

References serialize().

+ Here is the call graph for this function:

CO_API bool co::Serializable::isDirty ( ) const
overridevirtual
Returns
true if the serializable has to be committed.
Version
1.0

Reimplemented from co::Object.

virtual CO_API bool co::Serializable::isDirty ( const uint64_t  dirtyBits) const
virtual
Returns
true if the given dirty bits are set.
Version
1.0
CO_API void co::Serializable::notifyAttached ( )
overrideprotectedvirtual
See also
Object::notifyAttached()

Reimplemented from co::Object.

Serializable& co::Serializable::operator= ( const Serializable from)
inlineprotected

NOP assignment operator.

Version
1.1.1

Definition at line 66 of file serializable.h.

References co::Object::operator=().

+ Here is the call graph for this function:

CO_API void co::Serializable::pack ( co::DataOStream os)
finalprotectedvirtual

Serialize the modifications since the last call to commit().

No new version will be created if no data is written to the output stream.

Parameters
osthe output stream.
Version
1.0

Reimplemented from co::Object.

virtual void co::Serializable::serialize ( co::DataOStream ,
const uint64_t   
)
inlineprotectedvirtual

Worker for pack() and getInstanceData().

Override this and deserialize() 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 in co::ObjectMap.

Definition at line 80 of file serializable.h.

Referenced by getInstanceData().

+ Here is the caller graph for this function:

virtual CO_API void co::Serializable::setDirty ( const uint64_t  bits)
protectedvirtual

Add dirty flags to mark data for distribution.

Version
1.0
CO_API void co::Serializable::unpack ( co::DataIStream is)
finalprotectedvirtual

Deserialize a change.

Parameters
isthe input data stream.
Version
1.0

Reimplemented from co::Object.

virtual CO_API void co::Serializable::unsetDirty ( const uint64_t  bits)
protectedvirtual

Remove dirty flags to clear data from distribution.

Version
1.0

The documentation for this class was generated from the following file: