29#include "musx/dom/BaseClasses.h"
30#include "musx/dom/CommonClasses.h"
31#include "musx/dom/Options.h"
32#include "musx/dom/Others.h"
33#include "musx/dom/Details.h"
34#include "musx/dom/SmartShape.h"
35#include "musx/dom/Entries.h"
36#include "musx/dom/Texts.h"
37#include "musx/xml/XmlInterface.h"
38#include "FieldPopulatorsOptions.h"
39#include "FieldPopulatorsOthers.h"
40#include "FieldPopulatorsDetails.h"
41#include "FieldPopulatorsTexts.h"
45# pragma warning(disable : 4244)
59template <
typename... Types>
63 using VariantType = std::variant<Types*...>;
72 static inline const auto registry = []() {
73 return std::unordered_map<std::string_view, VariantType>{
74 {Types::XmlNodeName, VariantType(
static_cast<Types*
>(
nullptr))}...
86 static std::optional<VariantType> findRegisteredType(std::string_view nodeName)
88 const auto it = registry.find(nodeName);
89 if (it == registry.end()) {
96 template <
typename T,
typename PoolPtr,
typename... Args>
97 static auto getScoreValue(
const PoolPtr& pool, Args&&... args)
99 if constexpr (std::is_same_v<PoolPtr, ::musx::dom::OthersPoolPtr> || std::is_same_v<PoolPtr, ::musx::dom::DetailsPoolPtr>) {
100 return pool->template get<T>(
SCORE_PARTID, std::forward<Args>(args)...);
102 return pool->template get<T>(std::forward<Args>(args)...);
121 template <
typename PoolPtr,
typename... Args>
124 auto typePtr = TypeRegistry::findRegisteredType(node->getTagName());
125 if (!typePtr.has_value()) {
130 [&](
auto const& ptr) -> std::shared_ptr<Base> {
131 using T = std::remove_pointer_t<std::remove_reference_t<
decltype(ptr)>>;
134 auto partAttr = node->findAttribute(
"part");
137 if (
auto shareAttr = node->findAttribute(
"shared")) {
140 auto instance = std::make_shared<T>(document, partId, shareMode, std::forward<Args>(args)...);
141 if constexpr (!std::is_same_v<PoolPtr, ::musx::dom::EntryPoolPtr>) {
143 for (
auto child = node->getFirstChildElement(); child; child = child->getNextSibling()) {
144 instance->addUnlinkedNode(child->getTagName());
146 auto scoreValue = getScoreValue<T>(pool, std::forward<Args>(args)...);
148 *instance = *scoreValue;
150 throw std::invalid_argument(
"Score instance not found for partially linked part instance");
154 factory::FieldPopulator<T>::populate(instance, node, elementLinker);
158 throw std::logic_error(
"Type for " + node->getTagName() +
" is not constructible with given arguments");
Base class to enforce polymorphism across all DOM classes.
Definition BaseClasses.h:60
ShareMode
Describes how this instance is shared between part and score.
Definition BaseClasses.h:68
Represents an entry containing metadata and notes.
Definition Entries.h:166
Represents display alterations to an accidental for a specific note.
Definition Details.h:70
Assigns an articulation to an entry.
Definition Details.h:100
Contains the baseline offsets for lyrics chorus records.
Definition Details.h:159
Contains the baseline offsets for lyrics chorus records.
Definition Details.h:173
Contains the baseline offsets for lyrics verse records.
Definition Details.h:186
Beam alteration for downstem primary beams.
Definition Details.h:258
Beam alteration for upstem primary beams.
Definition Details.h:280
Beam extension for downstem beams.
Definition Details.h:333
Beam extension for upstem beams.
Definition Details.h:347
Specifies the direction for beam stubs (if they are manually overridden.)
Definition Details.h:363
Represents a center shape for a others::SmartShape that spans three or more measures.
Definition SmartShape.h:388
Represents chord symbol assignment for a staff and measure.
Definition Details.h:390
Represents a cross-staff assignment for the note, if any.
Definition Details.h:456
Custom stem for downstem context.
Definition Details.h:516
Custom stem for upstem context.
Definition Details.h:530
Represents display offsets and spacing adjustments for augmentation dots on a specific note.
Definition Details.h:546
Specifies a custom size for an entry. It scales the entire entry, including the stem and all notehead...
Definition Details.h:574
Represents the attributes of a Finale frame holder.
Definition Details.h:600
Represents independent time and key signature overrides for a staff.
Definition Details.h:733
Contains the syllable assignments for lyrics chorus blocks.
Definition Details.h:821
Contains the syllable assignments for lyrics section blocks.
Definition Details.h:836
Contains the syllable assignments for lyrics verse blocks.
Definition Details.h:851
Specifies lyric alignment and justification for a single entry. This affects all lyric assignments on...
Definition Details.h:867
Represents a text block assignment for a staff and measure.
Definition Details.h:906
Represents graphical and notational alterations applied to a note.
Definition Details.h:942
Represents a percussion note code override for a single note.
Definition Details.h:976
Beam alteration for downstem secondary beams.
Definition Details.h:1000
Beam alteration for downstem secondary beams.
Definition Details.h:1033
Specifies which secondary beams break and restart on the associated entry.
Definition Details.h:1068
Assigns a smart shape to an entry.
Definition SmartShape.h:428
Represents the attributes of a Finale staff group that brackets staves.
Definition Details.h:1122
Represents a per-staff-size override for a specific staff in a system.
Definition Details.h:1298
Specifies horizontal and vertical adjustments for stems under beam.
Definition Details.h:1354
Specifies horizontal and vertical stem adjustments for upstem and downstem contexts.
Definition Details.h:1328
Alterations for tie ends.
Definition Details.h:1417
Alterations for tie starts. (Tie starts are normal ties.)
Definition Details.h:1434
Options controlling the appearance of tuplets.
Definition Details.h:1451
Options controlling the appearance and positioning of accidentals.
Definition Options.h:49
Options controlling the appearance of alternate notation.
Definition Options.h:72
Options controlling the appearance of augmentation dots.
Definition Options.h:96
Options controlling the appearance of barlines.
Definition Options.h:129
Options controlling the appearance of beams.
Definition Options.h:160
Options controlling chord symbol and fretboard rendering.
Definition Options.h:200
Options for configuring clefs in a musical context.
Definition Options.h:251
Options controlling the appearance and adjustments of flags.
Definition Options.h:315
An unordered map of default font settings for the document.
Definition Options.h:353
Options controlling the appearance and behavior of grace notes.
Definition Options.h:458
Options controlling the appearance and behavior of key signatures.
Definition Options.h:481
Options controlling the appearance of line and curve elements.
Definition Options.h:510
Options controlling lyric rendering in the musx file.
Definition Options.h:540
Options controlling miscellaneous settings.
Definition Options.h:656
Options controlling the appearance and behavior of multimeasure rests.
Definition Options.h:680
Options controlling music spacing.
Definition Options.h:708
Options specifying the charactes for musical symbols.
Definition Options.h:782
Options for page formatting in the document.
Definition Options.h:867
Options controlling the appearance of piano braces and brackets.
Definition Options.h:966
Options controlling the appearance of repeats.
Definition Options.h:995
Options controlling the appearance of smart shapes in the musx file.
Definition Options.h:1054
Options controlling the appearance and layout of staves.
Definition Options.h:1249
Options controlling the appearance of stems.
Definition Options.h:1276
Options controlling the appearance of ties.
Definition Options.h:1301
Options controlling the appearance and behavior of time signatures.
Definition Options.h:1434
Options controlling the appearance of tuplets.
Definition Options.h:1465
Lists the aleration values of each nth flat in a custom key signature. Normally these values are all ...
Definition Others.h:75
Lists the aleration values of each nth sharp in a custom key signature. Normally these values are all...
Definition Others.h:107
Lists the order of flats by pitch class index (0..6 = C..B) in a custom key signature....
Definition Others.h:133
Lists the order of sharps by pitch class index (0..6 = C..B) in a custom key signature....
Definition Others.h:164
Stores the properties and behaviors of articulation definitions.
Definition Others.h:184
A single beat chart element from Finale's music spacing system.
Definition Others.h:315
Represents a single element in a chord suffix (e.g., a symbol like "1" or "+").
Definition Others.h:377
Represents a list of repeat ending numbers for a RepeatEndingStart instance.
Definition Others.h:424
Represents an element in multimeasure clef list with its positioning and percentage values.
Definition Others.h:444
Identifies the percussion map ("drum library") for a staff style with percussion notations.
Definition Others.h:493
Identifies the percussion map ("drum library") for a staff with percussion notations.
Definition Others.h:473
The name and font characteristics of fonts contained.
Definition Others.h:509
Represents the attributes of a TGF entry frame.
Definition Others.h:577
An array of InstrumentUsed defines a set of staves in a staff system or in Scroll View.
Definition Others.h:623
An array of step elements from which one can create a key map.
Definition Others.h:675
Represents the attributes of a Finale "layer".
Definition Others.h:715
Represents the name associated with a MarkingCategory.
Definition Others.h:913
Represents a category of markings used.
Definition Others.h:838
Assigns a TextExpressionDef or ShapeExpressionDef to a measure.
Definition Others.h:1074
Represents the Measure Number Region with detailed font and enclosure settings for score and part dat...
Definition Others.h:1125
Represents the attributes of a measure.
Definition Others.h:931
Represents a group ID for a multi-staff setup.
Definition Others.h:1294
Represents a group of instruments spanning multiple staves.
Definition Others.h:1312
Represents the attributes of a multimeasure rest in the page layout.
Definition Others.h:1248
Overrides abbreviated name positioning for Staff.
Definition Others.h:1361
Overrides full name positioning for Staff.
Definition Others.h:1389
Overrides abbreviated name positioning for StaffStyle.
Definition Others.h:1375
Overrides full name positioning for StaffStyle.
Definition Others.h:1403
Represents a page text assignment with positioning and page range properties.
Definition Others.h:1459
Represents the attributes of a page in the page layout.
Definition Others.h:1416
Represents the attributes of a Finale "partDef".
Definition Others.h:1513
Represents global values that can vary by part.
Definition Others.h:1564
Represents percussion notehead and staff position info for a given percussion note type.
Definition Others.h:1595
Represents a repeat-backward marker with positioning and behavior properties.
Definition Others.h:1653
Represents a repeat ending start marker in the document.
Definition Others.h:1688
Represents the text associated with a RepeatEndingStart.
Definition Others.h:1745
Represents a list of repeat ending numbers for a RepeatEndingStart instance.
Definition Others.h:1766
Represents the data for instruction associated with a ShapeDef.
Definition Others.h:1783
Represents a shape created in Finale's Shape Designer.
Definition Others.h:1801
Stores the properties and behaviors of shape expressions.
Definition Others.h:1880
Represents the data for instruction associated with a ShapeDef.
Definition Others.h:1924
Represents a Finale smart shape custom line style.
Definition SmartShape.h:223
Assigns a smart shape or center shape to a measure.
Definition SmartShape.h:352
Represents a Finale smart shape.
Definition SmartShape.h:45
Represents an assignment.
Definition Others.h:2365
Represents a Finale staff style.
Definition Others.h:2256
Represents the attributes of a staff system in the page layout.
Definition Others.h:2438
Represents the definition of a Finale staff.
Definition Others.h:1957
Locks a span of one or more measures so that they always appear in a StaffSystem together.
Definition Others.h:2497
A single tempo change value entered with Finale's Tempo tool.
Definition Others.h:2526
Represents the attributes of a Finale "textBlock".
Definition Others.h:2564
Stores the properties and behaviors of text expressions.
Definition Others.h:2614
The enclosure for a text expression (if it exists)
Definition Others.h:2665
Represents a text repeat assignment with positioning and behavior properties.
Definition Others.h:2682
Defines text repeat elements with font styling and justification.
Definition Others.h:2722
The enclosure for a text expression (if it exists)
Definition Others.h:2761
Represents the text associated with a TextRepeatDef.
Definition Others.h:2778
Represents the lower composite time signature array.
Definition Others.h:2801
Represents the upper composite time signature structure.
Definition Others.h:2836
Maps the number of flats to a tonal center for a linear custom key. If there are zero flats or sharps...
Definition Others.h:2880
Maps number of sharps (0..7) to a tonal center for a linear custom key. Also maps 0 sharps or flats....
Definition Others.h:2902
Contains block text (Finale Text Tool, both page- and measure-attached)
Definition Texts.h:178
Contains bookmark description text.
Definition Texts.h:223
Contains text blocks associated with text expressions.
Definition Texts.h:208
Contains File Info text (from Finale's Score Manager)
Definition Texts.h:48
Contains chorus text for lyrics.
Definition Texts.h:148
Contains section text for lyrics.
Definition Texts.h:163
Contains verse text for lyrics.
Definition Texts.h:133
Contains text blocks associated with custom line smart shapes.
Definition Texts.h:193
A utility class for managing deferred relationships between elements during document construction.
Definition FactoryBase.h:71
A registry of types for mapping XML node names to types.
Definition TypeRegistry.h:61
static std::shared_ptr< Base > createInstance(const PoolPtr &pool, const XmlElementPtr &node, ElementLinker &elementLinker, const DocumentPtr &document, Args &&... args)
Creates an instance of the registered type corresponding to the provided node name.
Definition TypeRegistry.h:122
constexpr Cmper SCORE_PARTID
The part id of the score.
Definition Fundamentals.h:80
uint16_t Cmper
Enigma "comperator" key type.
Definition Fundamentals.h:55
std::shared_ptr< Document > DocumentPtr
Shared Document pointer.
Definition BaseClasses.h:51
std::shared_ptr< IXmlElement > XmlElementPtr
shared pointer to IXmlElement
Definition XmlInterface.h:121
object model for musx file (enigmaxml)
Definition BaseClasses.h:32