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

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

#include <serializable.h>

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

List of all members.

Public Member Functions

CO_API uint64_t getDirty () const
virtual CO_API bool isDirty () const
virtual CO_API bool isDirty (const uint64_t dirtyBits) const
virtual CO_API uint128_t commit (const uint32_t incarnation=CO_COMMIT_NEXT)
 Commit a new version of this object.

Protected Member Functions

CO_API Serializable ()
 Construct a new Serializable.
CO_API Serializable (const Serializable &)
 Construct an unmapped, unregistered copy of an serializable.
virtual CO_API ~Serializable ()
 Destruct the serializable.
virtual void serialize (co::DataOStream &, const uint64_t)
 Worker for pack() and getInstanceData().
virtual void deserialize (co::DataIStream &, const uint64_t)
 Worker for unpack() and applyInstanceData().
virtual ChangeType getChangeType () const
virtual CO_API void setDirty (const uint64_t bits)
 Add dirty flags to mark data for distribution.
virtual CO_API void unsetDirty (const uint64_t bits)
 Remove dirty flags to clear data from distribution.
virtual CO_API void notifyAttached ()
 Notify that this object has been registered or mapped.

Protected Types

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

Friends

class detail::Serializable

Detailed Description

Base class for distributed, inheritable objects.

This class implements one usage pattern of co::Object, which allows subclassing and serialization of distributed Objects. The implementation hierarchy co::Serializable -> eq::fabric::Object -> eq::fabric::Frustum illustrates the usage of this class.

Definition at line 35 of file serializable.h.


Member Enumeration Documentation

enum co::Serializable::DirtyBits [protected]

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

Subclasses should define their own bits, starting at DIRTY_CUSTOM.

Version:
1.0

Reimplemented in co::ObjectMap.

Definition at line 97 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 an serializable.

Version:
1.0
virtual CO_API co::Serializable::~Serializable ( ) [protected, virtual]

Destruct the serializable.

Version:
1.0

Member Function Documentation

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

Commit a new version of this object.

Objects using the change type STATIC can not be committed.

Master instances will increment new versions continously, starting at VERSION_FIRST. If the object has not changed, no new version will be generated, that is, the current version is returned. The high value of the returned version will always be 0.

Slave objects can be commited, but have certain caveats for serialization. Please refer to the Programming Guide for more details. Slave object commits will return a random version on a successful commit, or VERSION_NONE if the object has not changed since the last commit. The high value of a successful commit will never be 0.

The incarnation count is meaningful for buffered master objects. The commit implementation will keep all instance data committed with an incarnation count newer than current_incarnation - getAutoObsolete(). By default, each call to commit creates a new incarnation, retaining the data from last getAutoObsolete() commit calls. When the application wishes to auto obsolete by another metric than commit calls, it has to consistently provide an incarnation counter. Buffers with a higher incarnation count than the current are discarded. A typical use case is to tie the auto obsoletion to an application-specific frame loop. Decreasing the incarnation counter will lead to undefined results.

Parameters:
incarnationthe commit incarnation for auto obsoletion.
Returns:
the new head version.

Reimplemented from co::Object.

Reimplemented in co::ObjectMap.

virtual void co::Serializable::deserialize ( co::DataIStream ,
const uint64_t   
) [inline, 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 in co::ObjectMap.

Definition at line 87 of file serializable.h.

virtual ChangeType co::Serializable::getChangeType ( ) const [inline, protected, virtual]
Returns:
how the changes are to be handled.

Reimplemented from co::Object.

Reimplemented in co::ObjectMap.

Definition at line 89 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
virtual CO_API bool co::Serializable::isDirty ( ) const [virtual]
Returns:
true if the serializable has to be committed.
Version:
1.0

Reimplemented from co::Object.

Reimplemented in co::ObjectMap.

virtual CO_API bool co::Serializable::isDirty ( const uint64_t  dirtyBits) const [virtual]
Returns:
true if the given dirty bit is set.
Version:
1.0
virtual CO_API void co::Serializable::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::Object.

Reimplemented in co::ObjectMap.

virtual void co::Serializable::serialize ( co::DataOStream ,
const uint64_t   
) [inline, 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 in co::ObjectMap.

Definition at line 75 of file serializable.h.

virtual CO_API void co::Serializable::setDirty ( const uint64_t  bits) [protected, virtual]

Add dirty flags to mark data for distribution.

Version:
1.0
virtual CO_API void co::Serializable::unsetDirty ( const uint64_t  bits) [protected, virtual]

Remove dirty flags to clear data from distribution.

Version:
1.0

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