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

A context wrapper for GFrameHold associated with a specific part and location. More...

#include <Details.h>

Public Member Functions

 GFrameHoldContext (const DocumentPtr &document, Cmper partId, Cmper inst, Cmper meas)
 Constructs a context-aware GFrameHold wrapper.
 
Cmper getRequestedPartId () const
 Returns the requested part ID associated with this context.
 
const GFrameHoldoperator-> () const
 Provides const pointer-style access to the underlying GFrameHold.
 
 operator bool () const
 Returns true if the internal GFrameHold is valid.
 
ClefIndex calcClefIndexAt (Edu position) const
 Returns the clef index in effect for at the specified Edu position. This function does not take into account transposing clefs. Those are addressed in createEntryFrame.
 
ClefIndex calcClefIndexAt (util::Fraction position) const
 Returns the clef index in effect for at the specified util::Fraction position (as a fraction of whole notes). This function does not take into account transposing clefs. Those are addressed in createEntryFrame.
 
std::shared_ptr< const EntryFramecreateEntryFrame (LayerIndex layerIndex, bool forWrittenPitch=false) const
 Returns the EntryFrame for all entries in the given layer.
 
bool iterateEntries (LayerIndex layerIndex, std::function< bool(const EntryInfoPtr &)> iterator)
 iterates the entries for the specified layer in this GFrameHold from left to right
 
bool iterateEntries (std::function< bool(const EntryInfoPtr &)> iterator)
 iterates the entries for this GFrameHold from left to right for each layer in order
 

Detailed Description

A context wrapper for GFrameHold associated with a specific part and location.

This class retrieves the appropriate GFrameHold from a Document using part, instrument, and measure IDs, and enables part-aware operations like iterating over EntryFrame objects.

Constructor & Destructor Documentation

◆ GFrameHoldContext()

musx::dom::details::GFrameHoldContext::GFrameHoldContext ( const DocumentPtr document,
Cmper  partId,
Cmper  inst,
Cmper  meas 
)

Constructs a context-aware GFrameHold wrapper.

Parameters
documentWeak pointer to the owning Document.
partIdThe requested part ID.
instThe instrument ID for.
measThe measure ID for.

Member Function Documentation

◆ createEntryFrame()

std::shared_ptr< const EntryFrame > musx::dom::details::GFrameHoldContext::createEntryFrame ( LayerIndex  layerIndex,
bool  forWrittenPitch = false 
) const

Returns the EntryFrame for all entries in the given layer.

Parameters
layerIndexThe layer index (0..3) to iterate.
forWrittenPitchIf true, the key and clef for each entry are calculated for written pitch rather than concert pitch.
Returns
EntryFrame for layer or nullptr if none.

◆ getRequestedPartId()

Cmper musx::dom::details::GFrameHoldContext::getRequestedPartId ( ) const
inline

Returns the requested part ID associated with this context.

Returns
The requested part ID.

◆ iterateEntries() [1/2]

bool musx::dom::details::GFrameHoldContext::iterateEntries ( LayerIndex  layerIndex,
std::function< bool(const EntryInfoPtr &)>  iterator 
)

iterates the entries for the specified layer in this GFrameHold from left to right

Parameters
layerIndexThe layer index (0..3) to iterate.
iteratorThe callback function for each iteration.
Returns
true if higher-level iteration should continue. false if it should halt.
Exceptions
std::invalid_argumentif the layer index is out of range

◆ iterateEntries() [2/2]

bool musx::dom::details::GFrameHoldContext::iterateEntries ( std::function< bool(const EntryInfoPtr &)>  iterator)

iterates the entries for this GFrameHold from left to right for each layer in order

Parameters
iteratorThe callback function for each iteration.
Returns
true if higher-level iteration should continue. false if it should halt.

◆ operator bool()

musx::dom::details::GFrameHoldContext::operator bool ( ) const
inlineexplicit

Returns true if the internal GFrameHold is valid.

Returns
True if the GFrameHold was successfully retrieved; false otherwise.

◆ operator->()

const GFrameHold * musx::dom::details::GFrameHoldContext::operator-> ( ) const
inline

Provides const pointer-style access to the underlying GFrameHold.

Returns
A const pointer to GFrameHold.