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

This object specifies which peers should be playing which notes. More...

#include <NoteAssignmentsMap.h>

Inheritance diagram for NoteAssignmentsMap:
Inheritance graph
[legend]

Public Member Functions

 NoteAssignmentsMap ()
 Constructor. More...
 
 ~NoteAssignmentsMap ()
 Destructor. More...
 
virtual void SetToDefaultState ()
 Sets this object to its just-constructed state. More...
 
virtual status_t SetFromArchive (const ConstMessageRef &archive)
 Replaces this map's current contents with the contents from (archive) More...
 
virtual status_t SaveToArchive (const MessageRef &archive) const
 Saves this map's current contents into (archive) More...
 
const Hashtable< ZGPeerID,
uint64 > & 
GetNoteAssignments () const
 For a given peer, returns the chord of notes that peer should play. More...
 
uint64 GetNoteAssignmentsForPeerID (const ZGPeerID &peerID) const
 Returns the note-assignments currently specified for the given peer. More...
 
status_t SetNoteAssignmentsForPeerID (const ZGPeerID &peerID, uint64 newNotes)
 Sets the notes-chord for the given peer ID to the given value. More...
 
void UnassignNote (uint32 noteIdx)
 Un-assigns the specified note from everybody. More...
 
uint64 GetAllAssignedNotesChord () const
 Returns a bit-chord showing which notes are currently assigned to at least one peer. More...
 
void SetAssignmentStrategy (uint32 strategy)
 Set the assignment strategy we want the system to use for bell-assignments. More...
 
uint32 GetAssignmentStrategy () const
 Returns the assignment strategy the system is using for bell-assignments. More...
 
virtual uint32 GetCurrentChecksum () const
 Returns the checksum of this object (which is updated whenever this object's contents change) More...
 
virtual uint32 CalculateChecksum () const
 Recalculates our checksum from scratch (expensive!) More...
 
virtual ConstMessageRef SeniorUpdate (const ConstMessageRef &seniorDoMsg)
 Updates our state as specified in the (seniorDoMsg). More...
 
virtual status_t JuniorUpdate (const ConstMessageRef &juniorDoMsg)
 Updates our state as specified in the (juniorDoMsg). More...
 
status_t HandleToggleAssignmentMessage (const Message &msg)
 Updates this object based on the given CHOIR_COMMAND_TOGGLE_ASSIGNMENT Message's contents. More...
 
void PrintToStream () const
 For debugging purposes. More...
 
virtual String ToString () const
 Returns a string representation of this object, for debugging purposes. More...
 
const Hashtable< uint8, uint32 > & GetNoteHistogram () const
 Returns a table that shows for each note currently in use, how many peers are currently assigned to play that note. 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

This object specifies which peers should be playing which notes.

Definition at line 9 of file NoteAssignmentsMap.h.

Constructor & Destructor Documentation

Constructor.

Destructor.

Member Function Documentation

virtual uint32 CalculateChecksum ( ) const
virtual

Recalculates our checksum from scratch (expensive!)

Implements IDatabaseObject.

uint64 GetAllAssignedNotesChord ( ) const
inline

Returns a bit-chord showing which notes are currently assigned to at least one peer.

Definition at line 40 of file NoteAssignmentsMap.h.

uint32 GetAssignmentStrategy ( ) const
inline

Returns the assignment strategy the system is using for bell-assignments.

Default value is ASSIGNMENT_STRATEGY_AUTOMATIC.

Definition at line 48 of file NoteAssignmentsMap.h.

ChoirSession* GetChoirSession ( )
protectedinherited

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

const ChoirSession* GetChoirSession ( ) const
protectedinherited

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

virtual uint32 GetCurrentChecksum ( ) const
inlinevirtual

Returns the checksum of this object (which is updated whenever this object's contents change)

Implements IDatabaseObject.

Definition at line 51 of file NoteAssignmentsMap.h.

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, uint64>& GetNoteAssignments ( ) const
inline

For a given peer, returns the chord of notes that peer should play.

Definition at line 28 of file NoteAssignmentsMap.h.

uint64 GetNoteAssignmentsForPeerID ( const ZGPeerID peerID) const
inline

Returns the note-assignments currently specified for the given peer.

Definition at line 31 of file NoteAssignmentsMap.h.

const Hashtable<uint8, uint32>& GetNoteHistogram ( ) const
inline

Returns a table that shows for each note currently in use, how many peers are currently assigned to play that note.

(Keys are CHOIR_NOTE_* values, Values are assignment-counts, unassigned notes are not included in the table)

Definition at line 81 of file NoteAssignmentsMap.h.

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.

status_t HandleToggleAssignmentMessage ( const Message &  msg)

Updates this object based on the given CHOIR_COMMAND_TOGGLE_ASSIGNMENT Message's contents.

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)
virtual

Updates our state as specified in the (juniorDoMsg).

Will only be called on the instance running on the senior peer.

Parameters
juniorDoMsgA Message containing instructions for how to update our state on a junior peer.
Returns
B_NO_ERROR on success, or B_ERROR on failure.

Implements IDatabaseObject.

void PrintToStream ( ) const

For debugging purposes.

virtual status_t SaveToArchive ( const MessageRef &  archive) const
virtual

Saves this map's current contents into (archive)

Implements IDatabaseObject.

ConstMessageRef SendFullStateToGUI ( bool  allowReviewTrigger)
protectedinherited

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 
)
protectedinherited

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)
virtual

Updates our state as specified in the (seniorDoMsg).

Will only be called on the instance running on the senior peer.

Parameters
seniorDoMsgA Message containing instructions for how to update our state on the senior peer.
Returns
a Message to send to the JuniorUpdate() method on the junior peers on success, or a NULL reference on failure.

Implements IDatabaseObject.

void SetAssignmentStrategy ( uint32  strategy)

Set the assignment strategy we want the system to use for bell-assignments.

Parameters
strategya ASSIGNMENT_STRATEGY_* value
virtual status_t SetFromArchive ( const ConstMessageRef &  archive)
virtual

Replaces this map's current contents with the contents from (archive)

Implements IDatabaseObject.

status_t SetNoteAssignmentsForPeerID ( const ZGPeerID peerID,
uint64  newNotes 
)

Sets the notes-chord for the given peer ID to the given value.

void SetReviewResults ( uint64  allNotesUsedChord)
protectedinherited

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

Sets this object to its just-constructed state.

Implements IDatabaseObject.

virtual String ToString ( ) const
virtual

Returns a string representation of this object, for debugging purposes.

Implements IDatabaseObject.

void UnassignNote ( uint32  noteIdx)

Un-assigns the specified note from everybody.


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