1 #ifndef NoteAssignmentsMap_h
2 #define NoteAssignmentsMap_h
25 virtual status_t
SaveToArchive(
const MessageRef & archive)
const;
60 virtual ConstMessageRef
SeniorUpdate(
const ConstMessageRef & seniorDoMsg);
66 virtual status_t
JuniorUpdate(
const ConstMessageRef & juniorDoMsg);
84 uint32 CalculateChecksumForPeer(
const ZGPeerID & peerID, uint64 chordValue)
const {
return peerID.
CalculateChecksum()+CalculateChecksumForUint64(chordValue);}
85 const ZGPeerID & GetLightestPeer(
const Hashtable<ZGPeerID, ConstMessageRef> & onlinePeers, uint32 & retCount)
const;
86 const ZGPeerID & GetHeaviestPeer(
const Hashtable<ZGPeerID, ConstMessageRef> & onlinePeers, uint32 & retCount)
const;
87 void SetToDefaultStateAux();
88 void VerifyRunningChecksum(
const char * desc)
const;
89 status_t SeniorAutoUpdateAssignments(uint64 allNotesChord,
bool & retChangedAnything);
92 Hashtable<ZGPeerID, uint64> _noteAssignments;
93 uint32 _assignmentStrategy;
96 Hashtable<uint8, uint32> _noteHistogram;
97 uint64 _assignedNotes;
status_t HandleToggleAssignmentMessage(const Message &msg)
Updates this object based on the given CHOIR_COMMAND_TOGGLE_ASSIGNMENT Message's contents.
NoteAssignmentsMap()
Constructor.
A slight specialization of the IDatabaseObject class, just so I can add some application-specific hel...
uint32 GetAssignmentStrategy() const
Returns the assignment strategy the system is using for bell-assignments.
const Hashtable< uint8, uint32 > & GetNoteHistogram() const
Returns a table that shows for each note currently in use, how many peers are currently assigned to p...
virtual String ToString() const
Returns a string representation of this object, for debugging purposes.
uint64 GetAllAssignedNotesChord() const
Returns a bit-chord showing which notes are currently assigned to at least one peer.
void PrintToStream() const
For debugging purposes.
status_t SetNoteAssignmentsForPeerID(const ZGPeerID &peerID, uint64 newNotes)
Sets the notes-chord for the given peer ID to the given value.
virtual ConstMessageRef SeniorUpdate(const ConstMessageRef &seniorDoMsg)
Updates our state as specified in the (seniorDoMsg).
void SetAssignmentStrategy(uint32 strategy)
Set the assignment strategy we want the system to use for bell-assignments.
~NoteAssignmentsMap()
Destructor.
void UnassignNote(uint32 noteIdx)
Un-assigns the specified note from everybody.
A ZGPeerID is a 128-bit integer that uniquely represents a particular peer in a ZG system...
virtual status_t SaveToArchive(const MessageRef &archive) const
Saves this map's current contents into (archive)
virtual uint32 CalculateChecksum() const
Recalculates our checksum from scratch (expensive!)
virtual status_t SetFromArchive(const ConstMessageRef &archive)
Replaces this map's current contents with the contents from (archive)
virtual status_t JuniorUpdate(const ConstMessageRef &juniorDoMsg)
Updates our state as specified in the (juniorDoMsg).
The choir namespace contains the code specific to the ZGChoir demonstration application.
const Hashtable< ZGPeerID, uint64 > & GetNoteAssignments() const
For a given peer, returns the chord of notes that peer should play.
virtual void SetToDefaultState()
Sets this object to its just-constructed state.
uint64 GetNoteAssignmentsForPeerID(const ZGPeerID &peerID) const
Returns the note-assignments currently specified for the given peer.
This object specifies which peers should be playing which notes.
virtual uint32 GetCurrentChecksum() const
Returns the checksum of this object (which is updated whenever this object's contents change) ...
uint32 CalculateChecksum() const
Returns a 32-bit checksum for this object.