31#include <unordered_map>
35#include "Instrument.h"
36#include "ObjectPool.h"
37#include "MusxInstance.h"
55using namespace header;
58class MeasureExprAssign;
228 MUSX_ASSERT_IF(!m_instruments.has_value()) {
229 throw std::logic_error(
"Attempted to retrieve instrument map before it was constructed.");
231 return m_instruments.value();
240 return m_instruments;
245 const std::optional<std::filesystem::path>&
getSourcePath()
const {
return m_sourcePath; }
325 int m_maxBlankPages{};
327 std::optional<InstrumentMap> m_instruments = std::nullopt;
332 void createRehearsalMarkMap();
335 std::optional<double> m_scoreDurationSeconds;
337 std::optional<std::filesystem::path> m_sourcePath;
339 mutable std::unordered_map<Cmper, KnownShapeDefType> m_shapeRecognitionCache;
340 mutable std::unordered_map<Cmper, bool> m_isSmuflFontCache;
350std::optional<Cmper> importTextInto(
const DocumentPtr& target,
353 static_assert(is_pool_type_v<TextsPool, T>,
"Type T is not registered in TextsPool");
354 MUSX_ASSERT_IF(!target) {
355 throw std::invalid_argument(
"importTextInto received a null target document");
357 MUSX_ASSERT_IF(!source) {
358 throw std::invalid_argument(
"importTextInto received null text");
361 std::optional<Cmper> importedId;
362 if constexpr (std::is_same_v<T, FileInfoText>) {
363 importedId = source->getTextNumber();
364 if (target->getTexts()->get<FileInfoText>(*importedId)) {
368 importedId = target->getTexts()->nextFreeCmper<T>();
373 auto imported = std::make_shared<T>(
376 target->getTexts()->add(T::XmlNodeName, imported);
378 onImported(*imported);
380 if constexpr (std::is_base_of_v<LyricsTextBase, T>) {
381 imported->createSyllableInfo(imported);
388std::optional<Cmper> importTextInto(
const DocumentPtr& target,
389 const MusxInstance<T>& source)
391 return importTextInto(target, source, {});
Represents a document object that encapsulates the entire EnigmaXML structure.
Definition Document.h:111
std::optional< double > getScoreDurationSeconds() const
Returns the score playback duration in seconds, if provided by NotationMetadata.xml.
Definition Document.h:161
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<o...
Definition Document.cpp:499
const TextsPoolPtr & getTexts() const
Retrieves the const texts pool.
Definition Document.h:153
OthersPoolPtr & getOthers()
Retrieves the others pool.
Definition Document.h:129
MusxInstance< others::Page > calcPageFromMeasure(Cmper partId, MeasCmper measureId) const
Searches pages to find the page that contains the measure.
Definition Document.cpp:185
bool isScrollViewCmper(Cmper partId, Cmper systemCmper) const noexcept
Returns true if systemCmper identifies the Scroll View staff list for the given partId.
Definition Document.h:179
std::optional< KnownShapeDefType > getCachedShapeRecognition(Cmper shapeCmper) const
Retrieves a cached shape recognition result, if available.
Definition Document.cpp:157
const HeaderPtr & getHeader() const
Retrieves the const header.
Definition Document.h:118
MusxInstance< others::StaffSystem > calcSystemFromMeasure(Cmper partId, MeasCmper measureId) const
Searches systems to find the system that contains the measure.
Definition Document.cpp:208
const InstrumentInfo & getInstrumentForStaff(StaffCmper staffId) const
Get the instrument info for the given staffId.
Definition Document.cpp:342
int getMaxBlankPages() const
Returns the maximum number of blank pages in any part. This is calculated by factory::DocumentFactory...
Definition Document.h:222
PartVoicingPolicy getPartVoicingPolicy() const
Retrieves the document's part voicing policy.
Definition Document.h:157
const InstrumentMap & getInstruments() const
Returns the instrument map for this document. It is computed by the factory.
Definition Document.h:226
std::optional< bool > getCachedFontIsSMuFL(Cmper fontId) const
Retrieves a cached SMuFL font recognition result, if available.
Definition Document.cpp:171
std::optional< std::filesystem::path > resolveExternalGraphicPath(Cmper fileDescId) const
Resolve an external graphic path using SCORE_PARTID.
Definition Document.cpp:508
MusxInstanceList< others::StaffUsed > getStudioViewStaves(Cmper partId) const
Returns the Studio View staves for the given partId. Normally this is only one staff and is invariant...
Definition Document.cpp:146
const std::optional< std::filesystem::path > & getSourcePath() const
Returns the path to the musx (or EnigmaXML) file used to create this document, if provided.
Definition Document.h:245
std::vector< MeasCmper > calcJumpFromMeasures(Cmper partId, MeasCmper currentMeasure) const
Calculates the measures from which playback jumped into currentMeasure.
Definition Document.cpp:429
const std::optional< InstrumentMap > & getInstrumentsIfAvailable() const noexcept
Returns the optional instrument map, which is empty until the map has been constructed.
Definition Document.h:238
const DetailsPoolPtr & getDetails() const
Retrieves the const others pool.
Definition Document.h:139
HeaderPtr & getHeader()
Retrieves the header.
Definition Document.h:115
std::optional< RehearsalMarkInfo > getRehearsalMarkInfo(MeasCmper measureId, Cmper textExpressionId) const
Returns the rehearsal mark info for a rehearsal mark text expression assignment.
Definition Document.cpp:396
MusxInstanceList< others::StaffUsed > getScrollViewStaves(Cmper partId) const
Returns the Scroll View staves for the given partId.
Definition Document.cpp:141
bool calcHasVaryingSystemStaves(Cmper forPartId) const
Calculate if the current score/part has staves that differ from system to system.
Definition Document.cpp:411
const OptionsPoolPtr & getOptions() const
Retrieves the const options pool.
Definition Document.h:125
const EmbeddedGraphicsMap & getEmbeddedGraphics() const
Returns all embedded graphics keyed by graphic cmper.
Definition Document.h:165
TextsPoolPtr & getTexts()
Retrieves the texts pool.
Definition Document.h:150
void setCachedShapeRecognition(Cmper shapeCmper, KnownShapeDefType type) const
Stores a shape recognition result in the cache.
Definition Document.cpp:166
void setCachedFontIsSMuFL(Cmper fontId, bool isSmufl) const
Stores a SMuFL font recognition result in the cache.
Definition Document.cpp:180
Cmper calcScrollViewCmper(Cmper partId) const noexcept
Returns the Scroll View Cmper for the given partId.
Definition Document.cpp:133
const OthersPoolPtr & getOthers() const
Retrieves the const others pool.
Definition Document.h:132
InstrumentMap createInstrumentMap(Cmper forPartId) const
Builds an instrument map for the specified linked part ID.
Definition Document.cpp:229
MusicRange calcEntireDocument() const
Calcuate a MusicRange instance for the entire document.
Definition Document.cpp:405
const EntryPoolPtr & getEntries() const
Retrieves the entry others pool.
Definition Document.h:146
DetailsPoolPtr & getDetails()
Retrieves the details pool.
Definition Document.h:136
OptionsPoolPtr & getOptions()
Retrieves the options pool.
Definition Document.h:122
EntryPoolPtr & getEntries()
Retrieves the entry pool.
Definition Document.h:143
Wraps a frame of shared_ptr<const EntryInfo> and an index for per entry access. This class manages ow...
Definition Entries.h:555
Derived description of a logical instrument in a document.
Definition Instrument.h:83
A list of instruments, which may be single- or multi-staff.
Definition Instrument.h:146
Utility class that represents of a range of musical time.
Definition CommonClasses.h:643
Provides optional per-type extension methods for MusxInstanceList.
Definition MusxInstance.h:118
Creates and finalizes musxdom documents from XML or client-provided data.
Definition DocumentFactory.h:48
std::map< RehearsalMarkKey, RehearsalMarkInfo > RehearsalMarkMap
Maps each occurrence of a rehearsal mark to its sequence number for that measure.
Definition Document.h:105
KnownShapeDefType
Enumerates the shape types we can recognize semantically.
Definition ShapeDesigner.h:41
std::shared_ptr< OthersPool > OthersPoolPtr
Shared OthersPool pointer.
Definition ObjectPool.h:674
int16_t MeasCmper
Enigma meas Cmper (may be negative when not applicable)
Definition Fundamentals.h:66
std::shared_ptr< const T > MusxInstance
Defines the type of a musx instance stored in a pool.
Definition MusxInstance.h:40
constexpr Cmper SCORE_PARTID
The part id of the score.
Definition Fundamentals.h:81
std::shared_ptr< DetailsPool > DetailsPoolPtr
Shared DetailsPool pointer.
Definition ObjectPool.h:797
uint16_t Cmper
Enigma "comperator" key type.
Definition Fundamentals.h:57
std::shared_ptr< TextsPool > TextsPoolPtr
Shared OthersPool pointer.
Definition ObjectPool.h:914
PartVoicingPolicy
Controls whether Finale-style part voicing is applied when iterating entries via musx::dom::details::...
Definition Document.h:82
std::shared_ptr< OptionsPool > OptionsPoolPtr
Shared OptionsPool pointer.
Definition ObjectPool.h:570
std::pair< MeasCmper, Cmper > RehearsalMarkKey
Key identifying a rehearsal mark by measure number and others::TextExpressionDef Cmper.
Definition Document.h:96
std::weak_ptr< Document > DocumentWeakPtr
Shared weak Document pointer.
Definition DocumentElement.h:37
std::function< void(const EnigmaBase &)> ImportObjectCallback
Receives each document-pool object newly created by an import helper.
Definition BaseClasses.h:150
std::vector< uint8_t > EmbeddedGraphicBlob
Raw bytes for one embedded graphic payload from a musx archive.
Definition Document.h:67
std::unordered_map< Cmper, EmbeddedGraphicData > EmbeddedGraphicsMap
Embedded graphics keyed by cmper (filename stem in musx archive).
Definition Document.h:76
std::shared_ptr< Document > DocumentPtr
Shared Document pointer.
Definition DocumentElement.h:35
int16_t StaffCmper
Enigma staff (staffId) Cmper (may be negative when not applicable)
Definition Fundamentals.h:67
std::shared_ptr< EntryPool > EntryPoolPtr
Shared EntryPool pointer.
Definition ObjectPool.h:851
object model for musx file (enigmaxml)
Definition BaseClasses.h:38
Embedded graphic payload from a musx archive entry.
Definition Document.h:71
EmbeddedGraphicBlob bytes
Raw file bytes.
Definition Document.h:73
std::string extension
File extension without the leading dot (e.g. "png", "jpg", "svg").
Definition Document.h:72
Information associated with a rehearsal mark.
Definition Document.h:100
int rehearsalSequence
1-based rehearsal mark sequence number for this measure.
Definition Document.h:101