Planeshift
Classes | Public Member Functions

BaseMusicalScore< MeasureType, MeasureElementType > Class Template Reference

Implements a musical score. More...

#include <basemusicscore.h>

List of all members.

Classes

class  Cursor
 This is part of the BaseMusicalScore API. More...

Public Member Functions

bool AdvanceCursor (bool ignoreEndOfMeasure)
 BaseMusicalScore ()
 Create an empty score in edit mode.
CursorGetEditCursor ()
 Return the cursor if the score is in edit mode.
const MeasureType
< MeasureElementType > * 
GetMeasure (size_t n) const
 Return the n-th measure in the score.
size_t GetNMeasures () const
 Return the number of measures in the score.
const CursorGetPlayCursor () const
 Return the cursor if the score is in play mode.
CursorSetEditMode ()
 Set the mode to edit.
const CursorSetPlayMode ()
 Set the mode to play.
 ~BaseMusicalScore ()
 Destructor.

Detailed Description

template<template< typename > class MeasureType = Measure, typename MeasureElementType = MeasureElement>
class BaseMusicalScore< MeasureType, MeasureElementType >

Implements a musical score.

Central object of this class is the cursor which is part of BaseMusicalScore's interface to all intent and purposes. The score can be in edit or in play mode. When in play mode, it is read-only.

Though the content of the score can be read with BaseMusicalScore::GetMeasure(), using the cursor is the only way to modify it. After you set the score mode through BaseMusicalScore::SetEditMode() and BaseMusicalScore::SetPlayMode(), a reference of the score can be retrieved by using the methods BaseMusicalScore::GetEditCursor() and BaseMusicalScore::GetPlayCursor().

The read-only property of the score in play mode is enforced by exploiting the Cursor class const-correctness. The drawback of this design is that you will not be able to move the cursor by calling its methods in play mode. To circumvent this, work-around methods are provided in BaseMusicalScore. You can use BaseMusicalScore::AdvanceCursor() instead of BaseMusicalScore::Cursor::Advance() for example.

Definition at line 59 of file basemusicscore.h.


Constructor & Destructor Documentation

template<template< typename > class MeasureType = Measure, typename MeasureElementType = MeasureElement>
BaseMusicalScore< MeasureType, MeasureElementType >::BaseMusicalScore ( )

Create an empty score in edit mode.

template<template< typename > class MeasureType = Measure, typename MeasureElementType = MeasureElement>
BaseMusicalScore< MeasureType, MeasureElementType >::~BaseMusicalScore ( )

Destructor.


Member Function Documentation

template<template< typename > class MeasureType = Measure, typename MeasureElementType = MeasureElement>
bool BaseMusicalScore< MeasureType, MeasureElementType >::AdvanceCursor ( bool  ignoreEndOfMeasure)

Move the cursor to the next element.

This takes into account repeat sections only if the score is in play mode. If the current element is the last one of the score, false is returned and the cursor is moved to the end-of-score element. Any subsequent call will not affect the cursor and return false.

Parameters:
ignoreEndOfMeasureSkip end-of-measure elements if true.
Returns:
False if the score is in edit mode and there is no element written after the current one or if the score is in play mode and there is no element to play after the current one, true otherwise.
template<template< typename > class MeasureType = Measure, typename MeasureElementType = MeasureElement>
Cursor* BaseMusicalScore< MeasureType, MeasureElementType >::GetEditCursor ( )

Return the cursor if the score is in edit mode.

Returns:
The cursor if the score is in edit mode, 0 otherwise.
template<template< typename > class MeasureType = Measure, typename MeasureElementType = MeasureElement>
const MeasureType<MeasureElementType>* BaseMusicalScore< MeasureType, MeasureElementType >::GetMeasure ( size_t  n) const

Return the n-th measure in the score.

Parameters:
nThe index of the measure to retrieve. Must be valid.
Returns:
The n-th measure in the score.
template<template< typename > class MeasureType = Measure, typename MeasureElementType = MeasureElement>
size_t BaseMusicalScore< MeasureType, MeasureElementType >::GetNMeasures ( ) const [inline]

Return the number of measures in the score.

Returns:
The number of measures in the score.

Definition at line 101 of file basemusicscore.h.

template<template< typename > class MeasureType = Measure, typename MeasureElementType = MeasureElement>
const Cursor* BaseMusicalScore< MeasureType, MeasureElementType >::GetPlayCursor ( ) const

Return the cursor if the score is in play mode.

The cursor if the score is in play mode, 0 otherwise.

template<template< typename > class MeasureType = Measure, typename MeasureElementType = MeasureElement>
Cursor* BaseMusicalScore< MeasureType, MeasureElementType >::SetEditMode ( )

Set the mode to edit.

If the score is in play mode, the previous cursor is invalidated and the new one starts from the beginning of the score.

Returns:
The cursor of the score.
template<template< typename > class MeasureType = Measure, typename MeasureElementType = MeasureElement>
const Cursor* BaseMusicalScore< MeasureType, MeasureElementType >::SetPlayMode ( )

Set the mode to play.

If the score is in edit mode, the previous cursor is invalidated and the new one starts from the beginning of the score.

Returns:
The cursor of the score.

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