MUSX Document Model
Loading...
Searching...
No Matches
musx::dom::MusicRange Class Reference

Utility class that represents of a range of musical time. More...

#include <CommonClasses.h>

+ Inheritance diagram for musx::dom::MusicRange:

Public Member Functions

 MusicRange (const DocumentWeakPtr &document, MeasCmper startMeasId, util::Fraction startPos, MeasCmper endMeasId, util::Fraction endPos)
 Constructs a MusicRange object.
 
 MusicRange (const DocumentWeakPtr &document, MusicPoint startPoint, MusicPoint endPoint)
 Constructs a MusicRange object.
 
bool contains (MeasCmper measId, util::Fraction position) const
 Returns true of the given metric location is contained in this MusicRange instance.
 
bool contains (const MusicPoint &point) const
 Returns true if the given metric location is contained in this MusicRange instance.
 
bool contains (const EntryInfoPtr &entryInfo) const
 Returns true if the metric location of the specified entry is contained in this MusicRange instance.
 
std::optional< MusicPointnextLocation (const std::optional< StaffCmper > &forStaff=std::nullopt) const
 Returns the next metric location following the music range.
 
- Public Member Functions inherited from musx::dom::DocumentElementNoPart
 DocumentElementNoPart (const DocumentWeakPtr &document)
 Constructs the document element (with no meaningful associated part)
 
- Public Member Functions inherited from musx::dom::DocumentElement
virtual ~DocumentElement () noexcept(false)=default
 Virtual destructor for polymorphic behavior.
 
DocumentPtr getDocument () const
 Gets a reference to the Document.
 
Cmper getPartId () const
 Gets the part id associated with this instance.
 

Public Attributes

MusicPoint start
 Starting point in the range.
 
MusicPoint end
 Ending point in the range.
 

Additional Inherited Members

- Protected Member Functions inherited from musx::dom::DocumentElement
 DocumentElement (const DocumentWeakPtr &document, Cmper partId)
 Constructs the document element.
 
 DocumentElement (const DocumentElement &)=default
 explicit default copy constructor
 
 DocumentElement (DocumentElement &&) noexcept=default
 explicit default move constructor
 
DocumentElementoperator= (const DocumentElement &)
 no-op copy assignment operator allows subclasses to copy their values.
 
DocumentElementoperator= (DocumentElement &&) noexcept
 no-op move assignment operator allows subclasses to move their values.
 

Detailed Description

Utility class that represents of a range of musical time.

This class is used to specify start and end points in a musical range using measures and util::Fraction values.

The class is agnostic as to whether the positions are global- or staff-position values. The consuming code makes this determination.

Constructor & Destructor Documentation

◆ MusicRange() [1/2]

musx::dom::MusicRange::MusicRange ( const DocumentWeakPtr document,
MeasCmper  startMeasId,
util::Fraction  startPos,
MeasCmper  endMeasId,
util::Fraction  endPos 
)
inlineexplicit

Constructs a MusicRange object.

Parameters
documentShared pointer to the document.
startMeasIdThe start measure ID.
startPosThe start position. (Caller determines whether position is global- or staff-level.)
endMeasIdThe end measure ID.
endPosThe end position. (Caller determines whether position is global- or staff-level.)

◆ MusicRange() [2/2]

musx::dom::MusicRange::MusicRange ( const DocumentWeakPtr document,
MusicPoint  startPoint,
MusicPoint  endPoint 
)
inlineexplicit

Constructs a MusicRange object.

Parameters
documentShared pointer to the document.
startPointThe starting point of the range.
endPointThe ending point of the range.

Member Function Documentation

◆ contains() [1/3]

bool musx::dom::MusicRange::contains ( const EntryInfoPtr entryInfo) const

Returns true if the metric location of the specified entry is contained in this MusicRange instance.

Parameters
entryInfoThe entry to check.

◆ contains() [2/3]

bool musx::dom::MusicRange::contains ( const MusicPoint point) const
inline

Returns true if the given metric location is contained in this MusicRange instance.

Parameters
pointThe metric location to search for.

◆ contains() [3/3]

bool musx::dom::MusicRange::contains ( MeasCmper  measId,
util::Fraction  position 
) const
inline

Returns true of the given metric location is contained in this MusicRange instance.

Parameters
measIdThe measure ID to search for.
positionThe fractional position within the measure to search for.

◆ nextLocation()

std::optional< MusicPoint > musx::dom::MusicRange::nextLocation ( const std::optional< StaffCmper > &  forStaff = std::nullopt) const

Returns the next metric location following the music range.

Parameters
forStaffIf provided, calculates the next metric location using staff-level Edus.
Returns
The next location, or std::nullopt if it is past the end of the document or cannot be calculated.