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

This object is the in-memory representation of a song, as a collection of notes over time. More...

#include <MusicSheet.h>

Inheritance diagram for MusicSheet:
Inheritance graph
[legend]

Public Member Functions

 MusicSheet ()
 Constructor. More...
 
 MusicSheet (const MusicSheet &rhs)
 Constructor. More...
 
 ~MusicSheet ()
 Destructor. More...
 
MusicSheetoperator= (const MusicSheet &rhs)
 Assignment operator. More...
 
virtual void SetToDefaultState ()
 Clears our state to the state of a just-constructed MusicSheet object. More...
 
virtual status_t SetFromArchive (const ConstMessageRef &archive)
 Replaces this sheet's current contents with the contents from (archive) More...
 
virtual status_t SaveToArchive (const MessageRef &archive) const
 Saves this sheet's current contents into (archive) More...
 
status_t UpdateFromArchive (const ConstMessageRef &archive)
 Incrementally updates this sheet's contents, based on the information in the Message. More...
 
void SetSongFilePath (const String &songFilePath)
 Set the user-visible file-path string for this piece of music. More...
 
const String & GetSongFilePath () const
 Returns the current user-visible file-path string for this piece of music. More...
 
const OrderedKeysHashtable
< uint32, uint64 > & 
GetChordsTable () const
 Read-only access to our current table of chords. More...
 
uint64 GetChordAtIndex (uint32 whichChord, bool useLoopingLogic) const
 Convenience method – returns the chord at the specified chord-index, or 0 if there are no notes at that index. More...
 
status_t PutChord (uint32 whichChord, uint64 chordValue)
 Places the specified chord into our chords-set. More...
 
void RemoveChord (uint32 whichChord)
 Convenience method; removes the given chord from the chords-set, if it exists. More...
 
void InsertChordAt (uint32 whichChord)
 Inserts space for a new chord at the given index. More...
 
void DeleteChordAt (uint32 whichChord)
 Deletes the chord at the given index (if any). More...
 
uint32 GetSongLengthInChords (bool useLoopingLogic) const
 Returns the length of this song, in chords (i.e. More...
 
uint64 GetAllUsedNotesChord () const
 Returns a bit-chord that describes the full set of all the notes that are currently used anywhere in this song. 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
 Calculates our current 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...
 
virtual String ToString () const
 Returns a string representation of this object, for debugging purposes. 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 is the in-memory representation of a song, as a collection of notes over time.

Definition at line 9 of file MusicSheet.h.

Constructor & Destructor Documentation

Constructor.

MusicSheet ( const MusicSheet rhs)

Constructor.

~MusicSheet ( )

Destructor.

Member Function Documentation

virtual uint32 CalculateChecksum ( ) const
virtual

Calculates our current checksum from scratch (expensive!)

Implements IDatabaseObject.

void DeleteChordAt ( uint32  whichChord)

Deletes the chord at the given index (if any).

Any other chords after that index are moved one column to the left.

uint64 GetAllUsedNotesChord ( ) const
inline

Returns a bit-chord that describes the full set of all the notes that are currently used anywhere in this song.

Definition at line 71 of file MusicSheet.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.

uint64 GetChordAtIndex ( uint32  whichChord,
bool  useLoopingLogic 
) const
inline

Convenience method – returns the chord at the specified chord-index, or 0 if there are no notes at that index.

Definition at line 46 of file MusicSheet.h.

References MusicSheet::GetSongLengthInChords().

const OrderedKeysHashtable<uint32, uint64>& GetChordsTable ( ) const
inline

Read-only access to our current table of chords.

Definition at line 43 of file MusicSheet.h.

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 74 of file MusicSheet.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, 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.

const String& GetSongFilePath ( ) const
inline

Returns the current user-visible file-path string for this piece of music.

Definition at line 40 of file MusicSheet.h.

uint32 GetSongLengthInChords ( bool  useLoopingLogic) const
inline

Returns the length of this song, in chords (i.e.

the largest key in the chords Hashtable, plus one)

Definition at line 68 of file MusicSheet.h.

Referenced by MusicSheet::GetChordAtIndex().

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.

void InsertChordAt ( uint32  whichChord)

Inserts space for a new chord at the given index.

Any other chords at or after that indexed are moved one column to the right.

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.

MusicSheet& operator= ( const MusicSheet rhs)

Assignment operator.

status_t PutChord ( uint32  whichChord,
uint64  chordValue 
)

Places the specified chord into our chords-set.

Parameters
whichChordThe temporal index of the chord to set.
chordValuethe notes to be present in the chord (0x00==silence, 0x01==lowest note, etc)
Returns
B_NO_ERROR on success, or B_ERROR on failure (out of memory?)

Referenced by MusicSheet::RemoveChord().

void RemoveChord ( uint32  whichChord)
inline

Convenience method; removes the given chord from the chords-set, if it exists.

This is equivalent to calling PutChord(whichChord, 0);

Parameters
whichChordThe temporal index of the chord to remove (0=first, 1=second, etc)

Definition at line 59 of file MusicSheet.h.

References MusicSheet::PutChord().

virtual status_t SaveToArchive ( const MessageRef &  archive) const
virtual

Saves this sheet'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.

virtual status_t SetFromArchive ( const ConstMessageRef &  archive)
virtual

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

Implements IDatabaseObject.

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.
void SetSongFilePath ( const String &  songFilePath)

Set the user-visible file-path string for this piece of music.

virtual void SetToDefaultState ( )
virtual

Clears our state to the state of a just-constructed MusicSheet object.

Implements IDatabaseObject.

virtual String ToString ( ) const
virtual

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

Implements IDatabaseObject.

status_t UpdateFromArchive ( const ConstMessageRef &  archive)

Incrementally updates this sheet's contents, based on the information in the Message.


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