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

A slight specialization of the IDatabaseObject class, just so I can add some application-specific helper methods for my various subclasses to all use. More...

#include <MusicData.h>

Inheritance diagram for MusicDatabaseObject:
Inheritance graph
[legend]

Public Member Functions

 MusicDatabaseObject ()
 Default constructor. 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

ChoirSessionGetChoirSession ()
 Returns a pointer to the ChoirSession object that created this object. More...
 
const ChoirSessionGetChoirSession () const
 Returns a read-only pointer to the ChoirSession object that created this object. More...
 
ConstMessageRef SendFullStateToGUI (bool allowReviewTrigger)
 Saves the state of this object into a Message and sends that Message to the GUI thread. More...
 
void SendMessageToGUI (const ConstMessageRef &msg, bool allowReviewTrigger)
 Sends the specified Message to the GUI thread. More...
 
void SetReviewResults (uint64 allNotesUsedChord)
 Convenience method; calls SetReviewResults(allNotesUsedChord) on our ChoirSession object. More...
 
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...
 

Detailed Description

A slight specialization of the IDatabaseObject class, just so I can add some application-specific helper methods for my various subclasses to all use.

Definition at line 74 of file MusicData.h.

Constructor & Destructor Documentation

MusicDatabaseObject ( )
inline

Default constructor.

Definition at line 78 of file MusicData.h.

Member Function Documentation

virtual uint32 CalculateChecksum ( ) const
pure virtualinherited

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.

ChoirSession* GetChoirSession ( )
protected

Returns a pointer to the ChoirSession object that created this object.

const ChoirSession* GetChoirSession ( ) const
protected

Returns a read-only pointer to the ChoirSession object that created this object.

virtual uint32 GetCurrentChecksum ( ) const
pure virtualinherited

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
protectedinherited

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 ( )
inlineinherited

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
inlineinherited

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

Definition at line 88 of file IDatabaseObject.h.

virtual uint64 GetNetworkTime64 ( ) const
protectedvirtualinherited

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

Implements INetworkTimeProvider.

virtual uint64 GetNetworkTime64ForRunTime64 ( uint64  runTime64TimeStamp) const
protectedvirtualinherited

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
protectedinherited

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
protectedvirtualinherited

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
protectedvirtualinherited

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
protectedinherited

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 virtualinherited

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 virtualinherited

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.

ConstMessageRef SendFullStateToGUI ( bool  allowReviewTrigger)
protected

Saves the state of this object into a Message and sends that Message to the GUI thread.

Parameters
allowReviewTriggerif true, this method may also trigger a review of the current bell-assignments to see if they need updating.
Returns
a read-only reference to the Message we sent, on success, or a NULL reference on failure.
void SendMessageToGUI ( const ConstMessageRef &  msg,
bool  allowReviewTrigger 
)
protected

Sends the specified Message to the GUI thread.

Parameters
msgThe Message to send to the GUI thread.
allowReviewTriggerif true, this method may also trigger a review of the current bell-assignments to see if they need updating.
virtual ConstMessageRef SeniorUpdate ( const ConstMessageRef &  seniorDoMsg)
pure virtualinherited

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 virtualinherited

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.

void SetReviewResults ( uint64  allNotesUsedChord)
protected

Convenience method; calls SetReviewResults(allNotesUsedChord) on our ChoirSession object.

Parameters
allNotesUsedChorda bit-chord of CHOIR_NOTE_* values indicating which notes are present in our current song.
virtual void SetToDefaultState ( )
pure virtualinherited

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 virtualinherited

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.


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