29#include "musx/dom/ObjectPool.h"
30#include "musx/dom/BaseClasses.h"
31#include "musx/dom/CommonClasses.h"
32#include "musx/dom/Options.h"
33#include "musx/dom/Others.h"
34#include "musx/dom/Details.h"
35#include "musx/dom/Graphics.h"
36#include "musx/dom/Ossia.h"
37#include "musx/dom/ShapeDesigner.h"
38#include "musx/dom/SmartShape.h"
39#include "musx/dom/Staff.h"
40#include "musx/dom/Entries.h"
41#include "musx/dom/Texts.h"
42#include "musx/xml/XmlInterface.h"
43#include "FieldPopulatorsOptions.h"
44#include "FieldPopulatorsOthers.h"
45#include "FieldPopulatorsDetails.h"
46#include "FieldPopulatorsTexts.h"
50# pragma warning(disable : 4244)
64template <
typename... Types>
68 using VariantType = std::variant<Types*...>;
77 static inline const auto registry = []() {
78 return std::unordered_map<std::string_view, VariantType>{
79 {Types::XmlNodeName, VariantType(
static_cast<Types*
>(
nullptr))}...
91 static std::optional<VariantType> findRegisteredType(std::string_view nodeName)
93 const auto it = registry.find(nodeName);
94 if (it == registry.end()) {
101 template <
typename T,
typename PoolPtr,
typename... Args>
102 static auto getScoreValue(
const PoolPtr& pool, Args&&... args)
104 if constexpr (std::is_same_v<PoolPtr, ::musx::dom::OthersPoolPtr> || std::is_same_v<PoolPtr, ::musx::dom::DetailsPoolPtr>) {
105 return pool->template get<T>(
SCORE_PARTID, std::forward<Args>(args)...);
107 return pool->template get<T>(std::forward<Args>(args)...);
114 template <
typename T>
119 template <
typename T>
148 template <
typename PoolPtr,
typename... Args>
151 auto typePtr = TypeRegistry::findRegisteredType(node->getTagName());
152 if (!typePtr.has_value()) {
158 using T = std::remove_pointer_t<std::remove_reference_t<
decltype(ptr)>>;
161 auto partAttr = node->findAttribute(
"part");
164 if (
auto shareAttr = node->findAttribute(
"shared")) {
167 auto instance = std::make_shared<T>(document, partId, shareMode, std::forward<Args>(args)...);
168 if constexpr (!std::is_same_v<PoolPtr, ::musx::dom::EntryPoolPtr>) {
170 for (
auto child = node->getFirstChildElement(); child; child = child->getNextSibling()) {
171 instance->addUnlinkedNode(child->getTagName());
173 auto scoreValue = getScoreValue<T>(pool, std::forward<Args>(args)...);
175 *instance = *scoreValue;
177 throw std::invalid_argument(
"Score instance not found for partially linked part instance");
181 factory::FieldPopulator<T>::populate(instance, node, elementLinker);
185 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:83
ShareMode
Describes how this instance is shared between part and score.
Definition BaseClasses.h:91
A pool that manages collections of DetailsBase objects, organized by XML node names and Cmper values.
Definition ObjectPool.h:456
Entry pool.
Definition ObjectPool.h:538
Represents an entry containing metadata and notes.
Definition Entries.h:261
A pool that manages collections of OptionsBase objects that have no Cmper value.
Definition ObjectPool.h:358
A pool that manages collections of OthersBase objects.
Definition ObjectPool.h:400
Text pool.
Definition ObjectPool.h:571
Represents display alterations to an accidental for a specific note.
Definition Details.h:79
Assigns an articulation to an entry.
Definition Details.h:109
Contains the baseline offsets for lyrics chorus records.
Definition Details.h:168
Contains the baseline offsets for lyrics chorus records.
Definition Details.h:182
Contains the baseline offsets for lyrics verse records.
Definition Details.h:195
Beam alteration for downstem primary beams.
Definition Details.h:267
Beam alteration for upstem primary beams.
Definition Details.h:289
Beam extension for downstem beams.
Definition Details.h:342
Beam extension for upstem beams.
Definition Details.h:354
Specifies the direction for beam stubs (if they are manually overridden.)
Definition Details.h:370
Represents a bracket, used in two different contexts:
Definition Details.h:402
Represents a center shape for a others::SmartShape that spans three or more measures.
Definition SmartShape.h:587
Represents chord symbol assignment for a staff and measure.
Definition Details.h:451
Defines the octaves in which each clef should display flats in key signatures. Only linear key signat...
Definition Details.h:545
Defines the octaves in which each clef should display sharps in key signatures.
Definition Details.h:574
Represents a cross-staff assignment for the note, if any.
Definition Details.h:593
Custom stem for downstem context.
Definition Details.h:653
Custom stem for upstem context.
Definition Details.h:667
Represents display offsets and spacing adjustments for augmentation dots on a specific note.
Definition Details.h:683
Specifies a custom size for an entry. It scales the entire entry, including the stem and all notehead...
Definition Details.h:711
FretboardDiagram diagram for chord symbols.
Definition Details.h:742
Represents the attributes of a Finale frame holder.
Definition Details.h:835
Represents independent time and key signature overrides for a staff.
Definition Details.h:898
Represents a single element in a Finale accidental symbol list.
Definition Details.h:957
Contains the syllable assignments for lyrics chorus blocks.
Definition Details.h:1029
Contains the syllable assignments for lyrics section blocks.
Definition Details.h:1050
Contains the syllable assignments for lyrics verse blocks.
Definition Details.h:1071
Specifies lyric alignment and justification for a single entry. This affects all lyric assignments on...
Definition Details.h:1093
Represents a graphic assignment anchored to a specific staff and measure.
Definition Graphics.h:335
Per-staff/per-measure overrides for the position and appearance of a measure number.
Definition Details.h:1124
Assigns an ossia passage to a specific staff/measure location.
Definition Ossia.h:179
Represents a text block assignment for a staff and measure.
Definition Details.h:1179
Represents graphical and notational alterations applied to a note.
Definition Details.h:1221
Represents a percussion note code override for a single note.
Definition Details.h:1255
Beam alteration for downstem secondary beams.
Definition Details.h:1279
Beam alteration for downstem secondary beams.
Definition Details.h:1312
Specifies which secondary beams break and restart on the associated entry.
Definition Details.h:1347
Shape Note settings for staff styles.
Definition Details.h:1470
Shape Note settings for staves.
Definition Details.h:1455
Assigns a smart shape to an entry.
Definition SmartShape.h:630
Represents the attributes of a Finale staff group that brackets staves.
Definition Details.h:1483
Represents a per-staff-size override for a specific staff in a system.
Definition Details.h:1651
Specifies horizontal and vertical adjustments for stems under beam.
Definition Details.h:1711
Specifies horizontal and vertical stem adjustments for upstem and downstem contexts.
Definition Details.h:1685
Specifies the TAB string a note appears on. Finale automatically figures out the fret number from the...
Definition Details.h:1728
Alterations for tie ends.
Definition Details.h:1801
Alterations for tie starts. (Tie starts are normal ties.)
Definition Details.h:1818
Options controlling the appearance of tuplets.
Definition Details.h:1835
Options controlling the appearance and positioning of accidentals.
Definition Options.h:57
Options controlling the appearance of alternate notation.
Definition Options.h:80
Options controlling the appearance of augmentation dots.
Definition Options.h:104
Options controlling the appearance of barlines.
Definition Options.h:137
Options controlling the appearance of beams.
Definition Options.h:168
Options controlling chord symbol and fretboard rendering.
Definition Options.h:209
Options for configuring clefs in a musical context.
Definition Options.h:262
Options controlling the appearance and adjustments of flags.
Definition Options.h:357
An unordered map of default font settings for the document.
Definition Options.h:395
Options controlling the appearance and behavior of grace notes.
Definition Options.h:500
Options controlling the appearance and behavior of key signatures.
Definition Options.h:523
Options controlling the appearance of line and curve elements.
Definition Options.h:552
Options controlling lyric rendering in the musx file.
Definition Options.h:582
Options controlling miscellaneous settings.
Definition Options.h:705
Options controlling the appearance and behavior of multimeasure rests.
Definition Options.h:733
Options controlling music spacing.
Definition Options.h:761
Options specifying the charactes for musical symbols.
Definition Options.h:838
Options controlling note/rest display and positioning.
Definition Options.h:920
Options for page formatting in the document.
Definition Options.h:983
Options controlling the appearance of piano braces and brackets.
Definition Options.h:1092
Options controlling the appearance of repeats.
Definition Options.h:1121
Options controlling the appearance of smart shapes in the musx file.
Definition Options.h:1182
Options controlling the appearance and layout of staves.
Definition Options.h:1384
Options controlling the appearance of stems.
Definition Options.h:1411
Options controlling text rendering in the musx file. Many of these options are default values that ar...
Definition Options.h:1482
Options controlling the appearance of ties.
Definition Options.h:1582
Options controlling the appearance and behavior of time signatures.
Definition Options.h:1742
Options controlling the appearance of tuplets.
Definition Options.h:1773
Lists the aleration values of each nth flat in a custom key signature. Normally these values are all ...
Definition Others.h:80
Lists the aleration values of each nth sharp in a custom key signature. Normally these values are all...
Definition Others.h:113
Lists the order of flats by pitch class index (0..6 = C..B) in a custom key signature....
Definition Others.h:139
Lists the order of sharps by pitch class index (0..6 = C..B) in a custom key signature....
Definition Others.h:170
Stores the properties and behaviors of articulation definitions.
Definition Others.h:190
A single beat chart element from Finale's music spacing system.
Definition Others.h:326
Represents a single element in a chord suffix (e.g., a symbol like "1" or "+").
Definition Others.h:388
Represents a list of repeat ending numbers for a RepeatEndingStart instance.
Definition Others.h:435
Represents an element in multimeasure clef list with its positioning and percentage values.
Definition Others.h:455
Identifies the percussion map ("drum library") for a staff style with percussion notation.
Definition Others.h:506
Identifies the percussion map ("drum library") for a staff with percussion notation.
Definition Others.h:486
Opaque storage for a platform-specific alias handle associated with a graphic.
Definition Graphics.h:41
Describes the locator flavor Finale used for the associated file/graphic.
Definition Graphics.h:69
Stores a human-readable path/leaf name recorded by Finale.
Definition Graphics.h:105
Opaque storage for a platform-specific URL/bookmark blob (e.g., macOS CFURL bookmark).
Definition Graphics.h:124
The name and font characteristics of fonts contained.
Definition Others.h:522
Represents the attributes of a TGF entry frame.
Definition Others.h:592
Describes a fretted instrument (strings, frets, name, clef). It is used for both TAB notation and Fre...
Definition Others.h:732
A named group of fretboard diagrams associated with a specific fretboard instrument.
Definition Others.h:644
Fretboard diagram style: shapes, spacing, fonts, and offsets.
Definition Others.h:674
Represents the attributes associated with a Finale key signature.
Definition Others.h:844
An array of step elements from which one can create a key map.
Definition Others.h:806
Represents the attributes of a Finale "layer".
Definition Others.h:876
Represents the name associated with a MarkingCategory.
Definition Others.h:1077
Represents a category of markings used.
Definition Others.h:999
Assigns a TextExpressionDef or ShapeExpressionDef to a measure.
Definition Others.h:1241
Represents the Measure Number Region with detailed font and enclosure settings for score and part dat...
Definition Others.h:1329
Represents the attributes of a measure.
Definition Others.h:1090
Represents a group ID for a multi-staff setup.
Definition Others.h:1500
Represents a group of instruments spanning multiple staves.
Definition Others.h:1518
Represents the attributes of a multimeasure rest in the page layout.
Definition Others.h:1454
Overrides abbreviated name positioning for Staff.
Definition Others.h:1571
Overrides full name positioning for Staff.
Definition Others.h:1599
Overrides abbreviated name positioning for StaffStyle.
Definition Others.h:1585
Overrides full name positioning for StaffStyle.
Definition Others.h:1613
Stores additional positioning offsets for ossia passages.
Definition Ossia.h:46
Stores display and source options for an ossia passage.
Definition Ossia.h:115
Represents a page graphic assignment with positioning and page-range properties.
Definition Graphics.h:160
Represents the assignment of an ossia passage to a specific page.
Definition Ossia.h:149
Represents a page text assignment with positioning and page range properties.
Definition Others.h:1683
Represents the attributes of a page in the page layout.
Definition Others.h:1626
Represents the attributes of a Finale "partDef".
Definition Others.h:1796
Represents global values that can vary by part.
Definition Others.h:1864
Defines voicing options for linked parts, either by selection rules or by assigning a layer.
Definition Others.h:1897
Represents percussion notehead and staff position info for a given percussion note type.
Definition Others.h:1950
Represents a repeat-backward marker with positioning and behavior properties.
Definition Others.h:2022
Represents a repeat ending start marker in the document.
Definition Others.h:2057
Represents the text associated with a RepeatEndingStart.
Definition Others.h:2114
Represents a list of repeat ending numbers for a RepeatEndingStart instance.
Definition Others.h:2135
Represents the data for instruction associated with a ShapeDef.
Definition ShapeDesigner.h:54
Represents a shape created in Finale's Shape Designer.
Definition ShapeDesigner.h:72
Stores the properties and behaviors of shape expressions.
Definition Others.h:2151
Represents a graphic assignment anchored to a specific staff and measure.
Definition Graphics.h:282
Represents the data for instruction associated with a ShapeDef.
Definition ShapeDesigner.h:297
Represents a Finale smart shape custom line style.
Definition SmartShape.h:389
Assigns a smart shape or center shape to a measure.
Definition SmartShape.h:551
Represents a Finale smart shape.
Definition SmartShape.h:180
Defines the split point(s) where a measure may be divided between two systems. A measure can only spl...
Definition Others.h:2212
This class specified the name of a staff list used by @ ref MarkingCategory.
Definition Others.h:2251
This class is used by MarkingCategory to define the staves for parts in a staff list.
Definition Others.h:2265
This class is used by MarkingCategory to define the staves for parts in a staff list.
Definition Others.h:2281
This class specified the name of a staff list used by RepeatEndingStart, RepeatBack,...
Definition Others.h:2297
This class is used by repeat classes to define the forced staves for parts in a staff list....
Definition Others.h:2328
This class is used by repeat classes to define the staves for parts in a staff list.
Definition Others.h:2311
This class is used by repeat classes to define the forced staves for the score in a staff list....
Definition Others.h:2361
This class is used by repeat classes to define the staves for the score in a staff list.
Definition Others.h:2344
Represents an assignment.
Definition Staff.h:551
Represents a Finale staff style.
Definition Staff.h:441
Represents the attributes of a staff system in the page layout.
Definition Others.h:2377
An array of StaffUsed defines a set of staves in a staff system or in Scroll View.
Definition Others.h:2454
Represents the definition of a Finale staff.
Definition Staff.h:48
Locks a span of one or more measures so that they always appear in a StaffSystem together.
Definition Others.h:2487
A single tempo change value entered with Finale's Tempo tool.
Definition Others.h:2518
Represents the attributes of a Finale "textBlock".
Definition Others.h:2554
Stores the properties and behaviors of text expressions.
Definition Others.h:2615
The enclosure for a text expression (if it exists)
Definition Others.h:2673
Represents a text repeat assignment with positioning and behavior properties.
Definition Others.h:2690
Defines text repeat elements with font styling and justification.
Definition Others.h:2730
The enclosure for a text expression (if it exists)
Definition Others.h:2772
Represents the text associated with a TextRepeatDef.
Definition Others.h:2789
Represents the lower composite time signature array.
Definition Others.h:2812
Represents the upper composite time signature structure.
Definition Others.h:2847
Maps the number of flats to a tonal center for a linear custom key. If there are zero flats or sharps...
Definition Others.h:2891
Maps number of sharps (0..7) to a tonal center for a linear custom key. Also maps 0 sharps or flats....
Definition Others.h:2913
Contains block text (Finale Text Tool, both page- and measure-attached)
Definition Texts.h:182
Contains bookmark description text.
Definition Texts.h:229
Contains text blocks associated with text expressions.
Definition Texts.h:212
Contains File Info text (from Finale's Score Manager)
Definition Texts.h:50
Contains chorus text for lyrics.
Definition Texts.h:152
Contains section text for lyrics.
Definition Texts.h:167
Contains verse text for lyrics.
Definition Texts.h:137
Contains text blocks associated with custom line smart shapes.
Definition Texts.h:197
A utility class for managing deferred relationships between elements during document construction.
Definition FactoryBase.h:72
A registry of types for mapping XML node names to types.
Definition TypeRegistry.h:66
static std::optional< CreatedInstanceInfo > 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:149
static constexpr bool is_registered_type_v
Shorthand to get the value of is_registered_type.
Definition TypeRegistry.h:120
constexpr Cmper SCORE_PARTID
The part id of the score.
Definition Fundamentals.h:79
uint16_t Cmper
Enigma "comperator" key type.
Definition Fundamentals.h:55
std::shared_ptr< Document > DocumentPtr
Shared Document pointer.
Definition BaseClasses.h:55
std::shared_ptr< IXmlElement > XmlElementPtr
shared pointer to IXmlElement
Definition XmlInterface.h:121
object model for musx file (enigmaxml)
Definition BaseClasses.h:36
Type trait to determine if a class in a given pool.
Definition ObjectPool.h:60
Information about a created instance returned by createInstance.
Definition TypeRegistry.h:125
std::shared_ptr< Base > instance
The newly created instance.
Definition TypeRegistry.h:130
std::string_view xmlNodeName
The static std::string_view containing the instance's node name.
Definition TypeRegistry.h:131
CreatedInstanceInfo(std::shared_ptr< Base > inst, std::string_view nodeName)
Constructor.
Definition TypeRegistry.h:127
Determine at compile-time if type T is a class in this registry.
Definition TypeRegistry.h:115