Planeshift
|
This is part of the BaseMusicalScore API. More...
#include <basemusicscore.h>
Public Member Functions | |
bool | Advance (bool ignoreEndOfMeasure) |
Move the cursor to the next element. | |
const MeasureElementType * | GetCurrentElement () const |
MeasureElementType * | GetCurrentElement () |
Get the element currently pointed by the cursor. | |
MeasureType< MeasureElementType > * | GetCurrentMeasure () |
Get the measure currently pointed by the cursor. | |
const MeasureType < MeasureElementType > * | GetCurrentMeasure () const |
bool | HasNext (bool ignoreEndOfMeasure) const |
Check if the element after the current one is the end-of-score element. | |
void | InsertElementAfter (const MeasureElementType &element) |
Insert a copy of the given element before the current one. | |
void | InsertElementBefore (const MeasureElementType &element) |
Insert a copy of the given element before the current one. | |
void | InsertMeasureAfter (const MeasureType< MeasureElementType > &measure) |
Insert a copy of the given measure after the current one. | |
void | InsertMeasureBefore (const MeasureType< MeasureElementType > &measure) |
Insert a copy of the given measure before the current one. | |
bool | IsEndOfMeasure () const |
Check that the cursor is on an end-of-measure element. | |
bool | IsEndOfScore () const |
Check that the cursor is on the end-of-score element. | |
bool | IsValid () const |
Check that the cursor is in a valid position which means that it is not on a special element. | |
bool | RemoveCurrentElement () |
Remove the current element. | |
bool | RemoveCurrentMeasure () |
Remove the current measure. | |
void | Validate () |
If the cursor is pointing to a non-existent element, this moves it to the end-of-measure character in the same measure. | |
~Cursor () | |
Destructor. | |
Friends | |
Cursor * | BaseMusicalScore () |
const Cursor * | BaseMusicalScore () |
This is part of the BaseMusicalScore API.
Only a BaseMusicalScore object can create an instance of this object.
In order to grasp how the cursor works, it is useful to understand that, similarly to the end-of-file character in files, musical scores use a couple of special measure elements. The end of a measure is marked by an end-of-measure element. Each measure in the score contains at least that one. Moreover, the last element of the score is a special end-of-score element. This is positioned after the last measure and it does not belong to any of them. An empty measure has only the end-of-measure element. Similarly, an empty score contains only the end-of-score element.
Though the user is free to add and remove elements to an existing measure by using the methods provided by the MeasureType class, it must be noticed that by doing so the cursor is not updated in any way. This may cause undesired effects (e.g. the cursor may point to a non-existent measure). For this reason it is safer to use the methods of this class which clearly state their effect on the cursor. If you still want to use the methods in MeasureType, be sure to call Cursor::Validate() after.
Definition at line 164 of file basemusicscore.h.
BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::~Cursor | ( | ) |
Destructor.
bool BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::Advance | ( | 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.
ignoreEndOfMeasure | Skip end-of-measure elements if true. |
MeasureElementType* BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::GetCurrentElement | ( | ) |
Get the element currently pointed by the cursor.
const MeasureElementType* BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::GetCurrentElement | ( | ) | const |
Get the element currently pointed by the cursor.
MeasureType<MeasureElementType>* BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::GetCurrentMeasure | ( | ) |
Get the measure currently pointed by the cursor.
const MeasureType<MeasureElementType>* BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::GetCurrentMeasure | ( | ) | const |
Get the measure currently pointed by the cursor.
bool BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::HasNext | ( | bool | ignoreEndOfMeasure | ) | const |
Check if the element after the current one is the end-of-score element.
This takes into account repeat sections only if the score is in play mode.
ignoreEndOfMeasure | If this is false, end-of-measure elements are considered valid next elements, otherwise they are ignored. |
void BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::InsertElementAfter | ( | const MeasureElementType & | element | ) |
Insert a copy of the given element before the current one.
The cursor does not change position. If the cursor points to the end-of-score element, a new measure is pushed at the end of the score and the cursor is moved to the element just inserted. If the cursor points to an end-of-measure element, the element is inserted before it and the cursor is moved to the element just inserted.
element | The element to insert. |
void BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::InsertElementBefore | ( | const MeasureElementType & | element | ) |
Insert a copy of the given element before the current one.
The cursor does not change position. If the cursor point to the end-of-score element, a new measure is pushed at the end of the score and the cursor is moved to the end-of-measure element of the new measure.
element | The element to insert. |
void BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::InsertMeasureAfter | ( | const MeasureType< MeasureElementType > & | measure | ) |
Insert a copy of the given measure after the current one.
The cursor does not change position. If the cursor is on the end-of-score element, the measure is pushed at the end of the score and the cursor is moved to the first element of the new measure (which is end-of-measure if the given measure is empty).
measure | The measure to insert. |
void BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::InsertMeasureBefore | ( | const MeasureType< MeasureElementType > & | measure | ) |
Insert a copy of the given measure before the current one.
The cursor does not change position. If the cursor is on the end-of-score element, the measure is pushed at the end of the score and the cursor is kept on end-of-score.
measure | The measure to insert. |
bool BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::IsEndOfMeasure | ( | ) | const |
Check that the cursor is on an end-of-measure element.
bool BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::IsEndOfScore | ( | ) | const |
Check that the cursor is on the end-of-score element.
Notice that this is different than checking if the current element is the last one of the score. You can use Cursor::HasNext()for that.
bool BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::IsValid | ( | ) | const |
Check that the cursor is in a valid position which means that it is not on a special element.
bool BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::RemoveCurrentElement | ( | ) |
Remove the current element.
The cursor is moved to the previous element within the same measure. If the removed element is the first one of the measure, the cursor is moved to the next element. If the cursor is on a end-of-measure or the end-of-score element, nothing happens and false is returned.
bool BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::RemoveCurrentMeasure | ( | ) |
Remove the current measure.
The cursor is moved to the first element of the previous measure. If the removed measure is the first one of the score, the cursor is moved to the first element of the next measure or to the end-of-score element in case the removed measure was the only one in the score. If the cursor is already on the end-of-score element, nothing happens and false is returned.
void BaseMusicalScore< MeasureType, MeasureElementType >::Cursor::Validate | ( | ) |
If the cursor is pointing to a non-existent element, this moves it to the end-of-measure character in the same measure.
You have no reason to use this method unless you modify add/remove elements in a MeasureType by using its methods.
Cursor* BaseMusicalScore | ( | ) | [friend] |
const Cursor* BaseMusicalScore | ( | ) | [friend] |