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

Represents a document object that encapsulates the entire EnigmaXML structure. More...

#include <Document.h>

Public Member Functions

HeaderPtrgetHeader ()
 Retrieves the header.
 
const HeaderPtrgetHeader () const
 Retrieves the const header.
 
OptionsPoolPtrgetOptions ()
 Retrieves the options pool.
 
const OptionsPoolPtrgetOptions () const
 Retrieves the const options pool.
 
OthersPoolPtrgetOthers ()
 Retrieves the others pool.
 
const OthersPoolPtrgetOthers () const
 Retrieves the const others pool.
 
DetailsPoolPtrgetDetails ()
 Retrieves the details pool.
 
const DetailsPoolPtrgetDetails () const
 Retrieves the const others pool.
 
EntryPoolPtrgetEntries ()
 Retrieves the entry pool.
 
const EntryPoolPtrgetEntries () const
 Retrieves the entry others pool.
 
TextsPoolPtrgetTexts ()
 Retrieves the texts pool.
 
const TextsPoolPtrgetTexts () const
 Retrieves the const texts pool.
 
PartVoicingPolicy getPartVoicingPolicy () const
 Retrieves the document's part voicing policy.
 
constexpr Cmper calcScrollViewCmper (Cmper partId) const noexcept
 Returns the Scroll View Cmper for the given partId.
 
MusxInstanceList< others::StaffUsedgetScrollViewStaves (Cmper partId) const
 Returns the Scroll View staves for the given partId.
 
MusxInstanceList< others::StaffUsedgetStudioViewStaves (Cmper partId) const
 Returns the Studio View staves for the given partId. Normally this is only one staff and is invariant between parts.
 
std::optional< KnownShapeDefTypegetCachedShapeRecognition (Cmper shapeCmper) const
 Retrieves a cached shape recognition result, if available.
 
void setCachedShapeRecognition (Cmper shapeCmper, KnownShapeDefType type) const
 Stores a shape recognition result in the cache.
 
MusxInstance< others::PagecalcPageFromMeasure (Cmper partId, MeasCmper measureId) const
 Searches pages to find the page that contains the measure.
 
MusxInstance< others::StaffSystemcalcSystemFromMeasure (Cmper partId, MeasCmper measureId) const
 Searches systems to find the page that contains the measure.
 
int getMaxBlankPages () const
 Returns the maximum number of blank pages in any part. This is calculated by factory::DocumentFactory::create.
 
const InstrumentMapgetInstruments () const
 Returns the instrument map for this document. It is computed by the factory.
 
const InstrumentInfogetInstrumentForStaff (StaffCmper staffId) const
 Get the instrument info for the given staffId.
 
InstrumentMap createInstrumentMap (Cmper forPartId) const
 Builds an instrument map for the specified linked part ID.
 
bool calcHasVaryingSystemStaves (Cmper forPartId) const
 Calculate if the current score/part has staves that differ from system to system.
 
MusicRange calcEntireDocument () const
 Calcuate a MusicRange instance for the entire document.
 
std::vector< MeasCmpercalcJumpFromMeasures (Cmper partId, MeasCmper currentMeasure) const
 Calculates the measures from which playback jumped into currentMeasure.
 
bool iterateEntries (Cmper partId, std::function< bool(const EntryInfoPtr &)> iterator) const
 Iterate all entries in the document by staff and then measure. This function wraps MusxInstanceList<others::StaffUsed>::iterateEntries.
 

Friends

class musx::factory::DocumentFactory
 

Detailed Description

Represents a document object that encapsulates the entire EnigmaXML structure.

Member Function Documentation

◆ calcHasVaryingSystemStaves()

bool musx::dom::Document::calcHasVaryingSystemStaves ( Cmper  forPartId) const

Calculate if the current score/part has staves that differ from system to system.

Parameters
forPartIdThe linked score or part ID to check.

◆ calcJumpFromMeasures()

std::vector< MeasCmper > musx::dom::Document::calcJumpFromMeasures ( Cmper  partId,
MeasCmper  currentMeasure 
) const

Calculates the measures from which playback jumped into currentMeasure.

This function inspects repeat endings and text repeats to detect jumps that land on the specified measure. The result is the measure immediately preceding the jump origin, when determinable. It is intended for jump-aware tie continuation logic.

Parameters
partIdThe linked part to inspect (use SCORE_PARTID for score).
currentMeasureThe measure that playback has jumped into.
Returns
A list of measures immediately preceding jump origins, ordered by preference (forward jump origins first in ascending order, then backward origins in descending order).

◆ calcPageFromMeasure()

MusxInstance< others::Page > musx::dom::Document::calcPageFromMeasure ( Cmper  partId,
MeasCmper  measureId 
) const

Searches pages to find the page that contains the measure.

Parameters
partIdthe linked part to search
measureIdthe measure to find

◆ calcScrollViewCmper()

constexpr Cmper musx::dom::Document::calcScrollViewCmper ( Cmper  partId) const
inlineconstexprnoexcept

Returns the Scroll View Cmper for the given partId.

Parameters
partIdThe linked part to check.

◆ calcSystemFromMeasure()

MusxInstance< others::StaffSystem > musx::dom::Document::calcSystemFromMeasure ( Cmper  partId,
MeasCmper  measureId 
) const

Searches systems to find the page that contains the measure.

Parameters
partIdthe linked part to search
measureIdthe measure to find

◆ createInstrumentMap()

InstrumentMap musx::dom::Document::createInstrumentMap ( Cmper  forPartId) const

Builds an instrument map for the specified linked part ID.

This routine detects instrument groupings in three stages:

  1. Defined multi-staff instruments (via multiStaffInstId).
  2. Visually bracketed staves with matching instrument UUIDs.
  3. Remaining single staves as individual instruments.

This is especially important for supporting legacy .musx files created before multi-staff instruments were defined explicitly.

Parameters
forPartIdThe linked part for which to create the map.

◆ getInstrumentForStaff()

const InstrumentInfo & musx::dom::Document::getInstrumentForStaff ( StaffCmper  staffId) const

Get the instrument info for the given staffId.

Parameters
staffIdThe staffId to find.

◆ getScrollViewStaves()

MusxInstanceList< others::StaffUsed > musx::dom::Document::getScrollViewStaves ( Cmper  partId) const

Returns the Scroll View staves for the given partId.

Parameters
partIdThe linked part to check.

◆ getStudioViewStaves()

MusxInstanceList< others::StaffUsed > musx::dom::Document::getStudioViewStaves ( Cmper  partId) const

Returns the Studio View staves for the given partId. Normally this is only one staff and is invariant between parts.

Parameters
partIdThe linked part to check.

◆ iterateEntries()

bool musx::dom::Document::iterateEntries ( Cmper  partId,
std::function< bool(const EntryInfoPtr &)>  iterator 
) const

Iterate all entries in the document by staff and then measure. This function wraps MusxInstanceList<others::StaffUsed>::iterateEntries.

Parameters
partIdThe linked part id to iterate. (Use SCORE_PARTID to iterate the score.)
iteratorThe callback function.
Returns
True if iteration completed. False if the iterator returned false and exited early.