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:80
Assigns an articulation to an entry.
Definition Details.h:110
Contains the baseline offsets for chords.
Definition Details.h:285
Contains the baseline offsets for expressions above the staff.
Definition Details.h:300
Contains the baseline offsets for expressions below the staff.
Definition Details.h:315
Contains the baseline offsets for fretboards.
Definition Details.h:330
Contains the baseline offsets for lyrics chorus records.
Definition Details.h:345
Contains the baseline offsets for lyrics section records.
Definition Details.h:361
Contains the baseline offsets for lyrics verse records.
Definition Details.h:377
Contains the baseline offsets for chords.
Definition Details.h:199
Contains the baseline offsets for expressions above the staff.
Definition Details.h:211
Contains the baseline offsets for expressions below the staff.
Definition Details.h:223
Contains the baseline offsets for fretboards.
Definition Details.h:235
Contains the baseline offsets for lyrics chorus records.
Definition Details.h:247
Contains the baseline offsets for lyrics section records.
Definition Details.h:259
Contains the baseline offsets for lyrics verse records.
Definition Details.h:271
Beam alteration for downstem primary beams.
Definition Details.h:450
Beam alteration for upstem primary beams.
Definition Details.h:472
Beam extension for downstem beams.
Definition Details.h:525
Beam extension for upstem beams.
Definition Details.h:537
Specifies the direction for beam stubs (if they are manually overridden.)
Definition Details.h:553
Represents a bracket, used in two different contexts:
Definition Details.h:585
Represents a center shape for a others::SmartShape that spans three or more measures.
Definition SmartShape.h:588
Represents chord symbol assignment for a staff and measure.
Definition Details.h:634
Defines the octaves in which each clef should display flats in key signatures. Only linear key signat...
Definition Details.h:728
Defines the octaves in which each clef should display sharps in key signatures.
Definition Details.h:757
Represents a cross-staff assignment for the note, if any.
Definition Details.h:776
Custom stem for downstem context.
Definition Details.h:836
Custom stem for upstem context.
Definition Details.h:850
Represents display offsets and spacing adjustments for augmentation dots on a specific note.
Definition Details.h:866
Specifies a custom size for an entry. It scales the entire entry, including the stem and all notehead...
Definition Details.h:894
FretboardDiagram diagram for chord symbols.
Definition Details.h:925
Represents the attributes of a Finale frame holder.
Definition Details.h:1018
Represents independent time and key signature overrides for a staff.
Definition Details.h:1081
Represents a single element in a Finale accidental symbol list.
Definition Details.h:1140
Contains the syllable assignments for lyrics chorus blocks.
Definition Details.h:1213
Contains the syllable assignments for lyrics section blocks.
Definition Details.h:1231
Contains the syllable assignments for lyrics verse blocks.
Definition Details.h:1249
Specifies lyric alignment and justification for a single entry. This affects all lyric assignments on...
Definition Details.h:1268
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:1299
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:1354
Represents graphical and notational alterations applied to a note.
Definition Details.h:1396
Represents a percussion note code override for a single note.
Definition Details.h:1430
Beam alteration for downstem secondary beams.
Definition Details.h:1454
Beam alteration for downstem secondary beams.
Definition Details.h:1487
Specifies which secondary beams break and restart on the associated entry.
Definition Details.h:1522
Shape Note settings for staff styles.
Definition Details.h:1645
Shape Note settings for staves.
Definition Details.h:1630
Assigns a smart shape to an entry.
Definition SmartShape.h:631
Represents the attributes of a Finale staff group that brackets staves.
Definition Details.h:1658
Represents a per-staff-size override for a specific staff in a system.
Definition Details.h:1826
Specifies horizontal and vertical adjustments for stems under beam.
Definition Details.h:1886
Specifies horizontal and vertical stem adjustments for upstem and downstem contexts.
Definition Details.h:1860
Specifies the TAB string a note appears on. Finale automatically figures out the fret number from the...
Definition Details.h:1903
Alterations for tie ends.
Definition Details.h:1978
Alterations for tie starts. (Tie starts are normal ties.)
Definition Details.h:1995
Options controlling the appearance of tuplets.
Definition Details.h:2012
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:97
Lists the aleration values of each nth sharp in a custom key signature. Normally these values are all...
Definition Others.h:130
Lists the order of flats by pitch class index (0..6 = C..B) in a custom key signature....
Definition Others.h:156
Lists the order of sharps by pitch class index (0..6 = C..B) in a custom key signature....
Definition Others.h:187
Stores the properties and behaviors of articulation definitions.
Definition Others.h:207
A single beat chart element from Finale's music spacing system.
Definition Others.h:343
Represents a single element in a chord suffix (e.g., a symbol like "1" or "+").
Definition Others.h:405
Represents a list of repeat ending numbers for a RepeatEndingStart instance.
Definition Others.h:452
Represents an element in multimeasure clef list with its positioning and percentage values.
Definition Others.h:472
Identifies the percussion map ("drum library") for a staff style with percussion notation.
Definition Others.h:523
Identifies the percussion map ("drum library") for a staff with percussion notation.
Definition Others.h:503
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:539
Represents the attributes of a TGF entry frame.
Definition Others.h:609
Describes a fretted instrument (strings, frets, name, clef). It is used for both TAB notation and Fre...
Definition Others.h:749
A named group of fretboard diagrams associated with a specific fretboard instrument.
Definition Others.h:661
Fretboard diagram style: shapes, spacing, fonts, and offsets.
Definition Others.h:691
Represents the attributes associated with a Finale key signature.
Definition Others.h:861
An array of step elements from which one can create a key map.
Definition Others.h:823
Represents the attributes of a Finale "layer".
Definition Others.h:893
Represents the name associated with a MarkingCategory.
Definition Others.h:1094
Represents a category of markings used.
Definition Others.h:1016
Assigns a TextExpressionDef or ShapeExpressionDef to a measure.
Definition Others.h:1258
Represents the Measure Number Region with detailed font and enclosure settings for score and part dat...
Definition Others.h:1350
Represents the attributes of a measure.
Definition Others.h:1107
Represents a group ID for a multi-staff setup.
Definition Others.h:1521
Represents a group of instruments spanning multiple staves.
Definition Others.h:1539
Represents the attributes of a multimeasure rest in the page layout.
Definition Others.h:1475
Overrides abbreviated name positioning for Staff.
Definition Others.h:1592
Overrides full name positioning for Staff.
Definition Others.h:1620
Overrides abbreviated name positioning for StaffStyle.
Definition Others.h:1606
Overrides full name positioning for StaffStyle.
Definition Others.h:1634
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:1704
Represents the attributes of a page in the page layout.
Definition Others.h:1647
Represents the attributes of a Finale "partDef".
Definition Others.h:1817
Represents global values that can vary by part.
Definition Others.h:1885
Defines voicing options for linked parts, either by selection rules or by assigning a layer.
Definition Others.h:1918
Represents percussion notehead and staff position info for a given percussion note type.
Definition Others.h:1971
Per-instance positioning overrides for RepeatBack.
Definition Others.h:2242
Represents a repeat-backward marker with positioning and behavior properties.
Definition Others.h:2045
Per-instance positioning overrides for the line positioning of RepeatEndingStart.
Definition Others.h:2258
Represents a repeat ending start marker in the document.
Definition Others.h:2091
Per-instance positioning overrides for text positioning of RepeatEndingStart.
Definition Others.h:2274
Represents the text associated with a RepeatEndingStart.
Definition Others.h:2168
Represents a list of repeat ending numbers for a RepeatEndingStart instance.
Definition Others.h:2189
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:2302
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:390
Assigns a smart shape or center shape to a measure.
Definition SmartShape.h:552
Represents a Finale smart shape.
Definition SmartShape.h:181
Defines the split point(s) where a measure may be divided between two systems. A measure can only spl...
Definition Others.h:2363
This class specified the name of a staff list used by @ ref MarkingCategory.
Definition Others.h:2402
This class is used by MarkingCategory to define the staves for parts in a staff list.
Definition Others.h:2416
This class is used by MarkingCategory to define the staves for parts in a staff list.
Definition Others.h:2432
This class specified the name of a staff list used by RepeatEndingStart, RepeatBack,...
Definition Others.h:2448
This class is used by repeat classes to define the forced staves for parts in a staff list....
Definition Others.h:2479
This class is used by repeat classes to define the staves for parts in a staff list.
Definition Others.h:2462
This class is used by repeat classes to define the forced staves for the score in a staff list....
Definition Others.h:2512
This class is used by repeat classes to define the staves for the score in a staff list.
Definition Others.h:2495
Represents an assignment.
Definition Staff.h:621
Represents a Finale staff style.
Definition Staff.h:487
Represents the attributes of a staff system in the page layout.
Definition Others.h:2554
An array of StaffUsed defines a set of staves in a staff system or in Scroll View.
Definition Others.h:2631
Represents the definition of a Finale staff.
Definition Staff.h:52
Locks a span of one or more measures so that they always appear in a StaffSystem together.
Definition Others.h:2664
A single tempo change value entered with Finale's Tempo tool.
Definition Others.h:2695
Represents the attributes of a Finale "textBlock".
Definition Others.h:2731
Stores the properties and behaviors of text expressions.
Definition Others.h:2792
The enclosure for a text expression (if it exists)
Definition Others.h:2850
Represents a text repeat assignment with positioning and behavior properties.
Definition Others.h:2867
Defines text repeat elements with font styling and justification.
Definition Others.h:2918
The enclosure for a text expression (if it exists)
Definition Others.h:2960
Per-instance positioning overrides for TextRepeatDef.
Definition Others.h:2289
Represents the text associated with a TextRepeatDef.
Definition Others.h:2977
Represents the lower composite time signature array.
Definition Others.h:3000
Represents the upper composite time signature structure.
Definition Others.h:3035
Maps the number of flats to a tonal center for a linear custom key. If there are zero flats or sharps...
Definition Others.h:3079
Maps number of sharps (0..7) to a tonal center for a linear custom key. Also maps 0 sharps or flats....
Definition Others.h:3101
Contains block text (Finale Text Tool, both page- and measure-attached)
Definition Texts.h:194
Contains bookmark description text.
Definition Texts.h:241
Contains text blocks associated with text expressions.
Definition Texts.h:224
Contains File Info text (from Finale's Score Manager)
Definition Texts.h:51
Contains chorus text for lyrics.
Definition Texts.h:164
Contains section text for lyrics.
Definition Texts.h:179
Contains verse text for lyrics.
Definition Texts.h:149
Contains text blocks associated with custom line smart shapes.
Definition Texts.h:209
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