ZG  "1.00
 All Classes Namespaces Files Functions Variables Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Friends | List of all members
IDatabaseObject Class Referenceabstract

An interface for an object that represents the full contents of a ZG database. More...

#include <IDatabaseObject.h>

Inheritance diagram for IDatabaseObject:
Inheritance graph
[legend]

Public Member Functions

 IDatabaseObject ()
 Default Constructor. More...
 
virtual ~IDatabaseObject ()
 Destructor. More...
 
virtual void SetToDefaultState ()=0
 Should be implemented to set this object to its default/just-default-constructed state. More...
 
virtual status_t SetFromArchive (const ConstMessageRef &archive)=0
 Should be implemented to replace this object's entire state with the state contained in (archive) More...
 
virtual status_t SaveToArchive (const MessageRef &archive) const =0
 Should be implemented to save this object's entire state into (archive). More...
 
virtual uint32 GetCurrentChecksum () const =0
 Should return the current checksum of this object. More...
 
virtual uint32 CalculateChecksum () const =0
 This method should be implemented to recalculate the database's current checksum from scratch. More...
 
virtual ConstMessageRef SeniorUpdate (const ConstMessageRef &seniorDoMsg)=0
 Should update this object's state using the passed-in senior-do-Message (whose semantics are left up to the subclass to define), and then return a reference to a Message that can be used later to update the junior copies of this database to the same final state that this object is now in. More...
 
virtual status_t JuniorUpdate (const ConstMessageRef &juniorDoMsg)=0
 Should update this object's state using the passed-in junior-do-Messsage (that was previously returned by a call to SeniorUpdate() on the senior peer's instance of this object) More...
 
virtual String ToString () const =0
 Should return this object's state as a human-readable string. More...
 
ZGDatabasePeerSessionGetDatabasePeerSession ()
 Returns a pointer to the ZGDatabasePeerSession object that created us, or NULL if this object was not created by a ZGDatabasePeerSession. More...
 
const ZGDatabasePeerSessionGetDatabasePeerSession () const
 As above, but returns a const/read-only pointer. More...
 

Protected Member Functions

const IDatabaseObjectGetDatabaseObject (uint32 whichDatabase) const
 Returns a read-only pointer to the specified IDatabaseObject held by our ZGDatabasePeerSession, or NULL if we don't have a ZGDatabasePeerSession or if the specified database doesn't exist. More...
 
bool IsPeerOnline (const ZGPeerID &pid) const
 Returns true iff the peer with the specified ID is currently on line. More...
 
const Hashtable< ZGPeerID,
ConstMessageRef > & 
GetOnlinePeers () const
 Returns a table of the currently online peers (and their attributes), or an empty table if we have no ZGDatabasePeerSession. More...
 
virtual uint64 GetNetworkTime64 () const
 Returns the current network time, or 0 if we have no ZGDatabasePeerSession. More...
 
virtual uint64 GetRunTime64ForNetworkTime64 (uint64 networkTime64TimeStamp) const
 Returns the local time corresponding to a given network time, or 0 if we have no ZGDatabasePeerSession. More...
 
virtual uint64 GetNetworkTime64ForRunTime64 (uint64 runTime64TimeStamp) const
 Returns the network time corresponding to a given local time, or 0 if we have no ZGDatabasePeerSession. More...
 
virtual int64 GetToNetworkTimeOffset () const
 Returns the number of microseconds that should be added to a GetRunTime64() value to turn it into a GetNetworkTime64() value, or subtracted to do the inverse operation. More...
 

Friends

class ZGDatabasePeerSession
 

Detailed Description

An interface for an object that represents the full contents of a ZG database.

Definition at line 14 of file IDatabaseObject.h.

Constructor & Destructor Documentation

IDatabaseObject ( )
inline

Default Constructor.

Definition at line 18 of file IDatabaseObject.h.

virtual ~IDatabaseObject ( )
inlinevirtual

Destructor.

Definition at line 21 of file IDatabaseObject.h.

Member Function Documentation

virtual uint32 CalculateChecksum ( ) const
pure virtual

This method should be implemented to recalculate the database's current checksum from scratch.

Note that unlike GetCurrentChecksum(), this method should not just returned a precomputed/running checksum, but rather it should grovel over all the data in the database manually. This method will only be called during debugging sessions (e.g. to verify that the running checksum is correct) so it is okay if its implementation is relatively expensive.

Implemented in MusicSheet, NoteAssignmentsMap, and PlaybackState.

virtual uint32 GetCurrentChecksum ( ) const
pure virtual

Should return the current checksum of this object.

This checksum should always correspond exactly to this object's current state, and unless this object is quite small, it should be implemented as a running checksum so that this call can just return a known value rather than recalculating the checksum from the data during this call. That is because this method will be called rather often (e.g. once after any other call that changes this object's state) and therefore it is better if this call can be made as inexpensive as possible.

Implemented in MusicSheet, NoteAssignmentsMap, and PlaybackState.

const IDatabaseObject* GetDatabaseObject ( uint32  whichDatabase) const
protected

Returns a read-only pointer to the specified IDatabaseObject held by our ZGDatabasePeerSession, or NULL if we don't have a ZGDatabasePeerSession or if the specified database doesn't exist.

Parameters
whichDatabaseindex of the database object we want to access
ZGDatabasePeerSession* GetDatabasePeerSession ( )
inline

Returns a pointer to the ZGDatabasePeerSession object that created us, or NULL if this object was not created by a ZGDatabasePeerSession.

(Note that this pointer is not set until after our constructor returns, this method will always return NULL if called from a constructor)

Definition at line 85 of file IDatabaseObject.h.

const ZGDatabasePeerSession* GetDatabasePeerSession ( ) const
inline

As above, but returns a const/read-only pointer.

Definition at line 88 of file IDatabaseObject.h.

virtual uint64 GetNetworkTime64 ( ) const
protectedvirtual

Returns the current network time, or 0 if we have no ZGDatabasePeerSession.

Implements INetworkTimeProvider.

virtual uint64 GetNetworkTime64ForRunTime64 ( uint64  runTime64TimeStamp) const
protectedvirtual

Returns the network time corresponding to a given local time, or 0 if we have no ZGDatabasePeerSession.

Parameters
runTime64TimeStampa local-clock time, in microseconds

Implements INetworkTimeProvider.

const Hashtable<ZGPeerID, ConstMessageRef>& GetOnlinePeers ( ) const
protected

Returns a table of the currently online peers (and their attributes), or an empty table if we have no ZGDatabasePeerSession.

virtual uint64 GetRunTime64ForNetworkTime64 ( uint64  networkTime64TimeStamp) const
protectedvirtual

Returns the local time corresponding to a given network time, or 0 if we have no ZGDatabasePeerSession.

Parameters
networkTime64TimeStampa network-clock time, in microseconds

Implements INetworkTimeProvider.

virtual int64 GetToNetworkTimeOffset ( ) const
protectedvirtual

Returns the number of microseconds that should be added to a GetRunTime64() value to turn it into a GetNetworkTime64() value, or subtracted to do the inverse operation.

Note that this value will vary from one moment to the next!

Implements INetworkTimeProvider.

bool IsPeerOnline ( const ZGPeerID pid) const
protected

Returns true iff the peer with the specified ID is currently on line.

Parameters
pidThe ID of the peer we are interested in. If we have no ZGDatabasePeerSession then this will always return false.
virtual status_t JuniorUpdate ( const ConstMessageRef &  juniorDoMsg)
pure virtual

Should update this object's state using the passed-in junior-do-Messsage (that was previously returned by a call to SeniorUpdate() on the senior peer's instance of this object)

Parameters
juniorDoMsgA Message containing instrutions on how to update this object's state.
Returns
B_NO_ERROR on success, or B_ERROR on failure.

Implemented in MusicSheet, NoteAssignmentsMap, and PlaybackState.

virtual status_t SaveToArchive ( const MessageRef &  archive) const
pure virtual

Should be implemented to save this object's entire state into (archive).

Parameters
archiveAn empty Message into which to save all of our state information.
Returns
B_NO_ERROR on success, or B_ERROR on failure.

Implemented in MusicSheet, NoteAssignmentsMap, and PlaybackState.

virtual ConstMessageRef SeniorUpdate ( const ConstMessageRef &  seniorDoMsg)
pure virtual

Should update this object's state using the passed-in senior-do-Message (whose semantics are left up to the subclass to define), and then return a reference to a Message that can be used later to update the junior copies of this database to the same final state that this object is now in.

Parameters
seniorDoMsga Message containing instructions on how to update this object's state.
Returns
on Success, a reference to a Message that can be used to update the junior peers' instances of this database to the same state that this object is now in, or a NULL reference on failure.

Implemented in MusicSheet, NoteAssignmentsMap, and PlaybackState.

virtual status_t SetFromArchive ( const ConstMessageRef &  archive)
pure virtual

Should be implemented to replace this object's entire state with the state contained in (archive)

Parameters
archivea Message containing state information, that was previously created by calling SaveToArchive()
Returns
B_NO_ERROR on success, or B_ERROR on failure.

Implemented in MusicSheet, NoteAssignmentsMap, and PlaybackState.

virtual void SetToDefaultState ( )
pure virtual

Should be implemented to set this object to its default/just-default-constructed state.

Implemented in MusicSheet, NoteAssignmentsMap, and PlaybackState.

virtual String ToString ( ) const
pure virtual

Should return this object's state as a human-readable string.

This method is only used for debugging purposes (e.g. printing out the state of the database before and after the database is repaired, so the two printouts can be diff'd to see where the error was)

Implemented in PlaybackState, MusicSheet, and NoteAssignmentsMap.

Friends And Related Function Documentation

friend class ZGDatabasePeerSession
friend

Definition at line 128 of file IDatabaseObject.h.


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