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 "FieldPopulatorsEntries.h"
47#include "FieldPopulatorsTexts.h"
51# pragma warning(disable : 4244)
65template <
typename... Types>
69 using VariantType = std::variant<Types*...>;
78 static inline const auto registry = []() {
79 return std::unordered_map<std::string_view, VariantType>{
80 {Types::XmlNodeName, VariantType(
static_cast<Types*
>(
nullptr))}...
92 static std::optional<VariantType> findRegisteredType(std::string_view nodeName)
94 const auto it = registry.find(nodeName);
95 if (it == registry.end()) {
102 template <
typename T,
typename PoolPtr,
typename... Args>
103 static auto getScoreValue(
const PoolPtr& pool, Args&&... args)
105 if constexpr (std::is_same_v<PoolPtr, ::musx::dom::OthersPoolPtr> || std::is_same_v<PoolPtr, ::musx::dom::DetailsPoolPtr>) {
106 return pool->template get<T>(
SCORE_PARTID, std::forward<Args>(args)...);
108 return pool->template get<T>(std::forward<Args>(args)...);
115 template <
typename T>
120 template <
typename T>
149 template <
typename PoolPtr,
typename... Args>
152 auto typePtr = TypeRegistry::findRegisteredType(node->getTagName());
153 if (!typePtr.has_value()) {
159 using T = std::remove_pointer_t<std::remove_reference_t<
decltype(ptr)>>;
162 auto partAttr = node->findAttribute(
"part");
164 auto shareMode = EnigmaBase::ShareMode::All;
165 if (
auto shareAttr = node->findAttribute(
"shared")) {
166 shareMode = shareAttr->getValueAs<
bool>() ? EnigmaBase::ShareMode::Partial : EnigmaBase::ShareMode::None;
168 auto instance = std::make_shared<T>(document, partId, shareMode, std::forward<Args>(args)...);
169 if constexpr (!std::is_same_v<PoolPtr, ::musx::dom::EntryPoolPtr>) {
170 if (instance->getShareMode() == EnigmaBase::ShareMode::Partial) {
171 for (
auto child = node->getFirstChildElement(); child; child = child->getNextSibling()) {
172 instance->addUnlinkedNode(child->getTagName());
174 auto scoreValue = getScoreValue<T>(pool, std::forward<Args>(args)...);
176 *instance = *scoreValue;
178 throw std::invalid_argument(
"Score instance not found for partially linked part instance");
182 factory::FieldPopulator<T>::populate(instance, node, elementLinker);
186 throw std::logic_error(
"Type for " + node->getTagName() +
" is not constructible with given arguments");
287 dom::others::ShapeData,
288 dom::others::ShapeDef,
289 dom::others::ShapeInstructionList,
A pool that manages collections of DetailsBase objects, organized by XML node names and Cmper values.
Definition ObjectPool.h:509
Base for DOM classes that are represented in EnigmaData.
Definition BaseClasses.h:81
ShareMode
Describes how this instance is shared between part and score.
Definition BaseClasses.h:91
Entry pool.
Definition ObjectPool.h:591
Represents an entry containing metadata and notes.
Definition Entries.h:357
A pool that manages collections of OptionsBase objects that have no Cmper value.
Definition ObjectPool.h:411
A pool that manages collections of OthersBase objects.
Definition ObjectPool.h:453
Text pool.
Definition ObjectPool.h:626
Represents display alterations to an accidental for a specific note.
Definition Details.h:81
Assigns an articulation to an entry.
Definition Details.h:111
Contains the baseline offsets for chords.
Definition Details.h:335
Contains the baseline offsets for expressions above the staff.
Definition Details.h:350
Contains the baseline offsets for expressions below the staff.
Definition Details.h:365
Contains the baseline offsets for fretboards.
Definition Details.h:380
Contains the baseline offsets for lyrics chorus records.
Definition Details.h:395
Contains the baseline offsets for lyrics section records.
Definition Details.h:411
Contains the baseline offsets for lyrics verse records.
Definition Details.h:427
Contains the baseline offsets for chords.
Definition Details.h:249
Contains the baseline offsets for expressions above the staff.
Definition Details.h:261
Contains the baseline offsets for expressions below the staff.
Definition Details.h:273
Contains the baseline offsets for fretboards.
Definition Details.h:285
Contains the baseline offsets for lyrics chorus records.
Definition Details.h:297
Contains the baseline offsets for lyrics section records.
Definition Details.h:309
Contains the baseline offsets for lyrics verse records.
Definition Details.h:321
Beam alteration for downstem primary beams.
Definition Details.h:515
Beam alteration for upstem primary beams.
Definition Details.h:537
Beam extension for downstem beams.
Definition Details.h:599
Beam extension for upstem beams.
Definition Details.h:611
Specifies the direction for beam stubs (if they are manually overridden.)
Definition Details.h:627
Represents a bracket, used in two different contexts:
Definition Details.h:659
Represents a center shape for a others::SmartShape that spans three or more measures.
Definition SmartShape.h:656
Represents chord symbol assignment for a staff and measure.
Definition Details.h:708
Defines the octaves in which each clef should display flats in key signatures. Only linear key signat...
Definition Details.h:802
Defines the octaves in which each clef should display sharps in key signatures.
Definition Details.h:831
Represents a cross-staff assignment for the note, if any.
Definition Details.h:850
Custom stem for downstem context.
Definition Details.h:915
Custom stem for upstem context.
Definition Details.h:929
Represents display offsets and spacing adjustments for augmentation dots on a specific note.
Definition Details.h:945
Per-part overrides for entry properties such as manual position and stem direction.
Definition Details.h:975
Specifies a custom size for an entry. It scales the entire entry, including the stem and all notehead...
Definition Details.h:1004
FretboardDiagram diagram for chord symbols.
Definition Details.h:1035
Represents the attributes of a Finale frame holder.
Definition Details.h:1128
Represents independent time and key signature overrides for a staff.
Definition Details.h:1201
Represents a single element in a Finale accidental symbol list.
Definition Details.h:1260
Contains the syllable assignments for lyrics chorus blocks.
Definition Details.h:1341
Contains the syllable assignments for lyrics section blocks.
Definition Details.h:1360
Contains the syllable assignments for lyrics verse blocks.
Definition Details.h:1379
Specifies lyric alignment and justification for a single entry. This affects all lyric assignments on...
Definition Details.h:1399
Represents a graphic assignment anchored to a specific staff and measure.
Definition Graphics.h:336
Per-staff/per-measure overrides for the position and appearance of a measure number.
Definition Details.h:1427
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:1482
Represents graphical and notational alterations applied to a note.
Definition Details.h:1524
Represents a percussion note code override for a single note.
Definition Details.h:1558
Beam alteration for downstem secondary beams.
Definition Details.h:1582
Beam alteration for downstem secondary beams.
Definition Details.h:1615
Specifies which secondary beams break and restart on the associated entry.
Definition Details.h:1650
Shape Note settings for staff styles.
Definition Details.h:1773
Shape Note settings for staves.
Definition Details.h:1758
Assigns a smart shape to an entry.
Definition SmartShape.h:699
Represents the attributes of a Finale staff group that brackets staves.
Definition Details.h:1786
Represents a per-staff-size override for a specific staff in a system.
Definition Details.h:1970
Specifies horizontal and vertical adjustments for stems under beam.
Definition Details.h:2030
Specifies horizontal and vertical stem adjustments for upstem and downstem contexts.
Definition Details.h:2004
Specifies the TAB string a note appears on. Finale automatically figures out the fret number from the...
Definition Details.h:2047
Alterations for tie ends.
Definition Details.h:2172
Alterations for tie starts. (Tie starts are normal ties.)
Definition Details.h:2189
Options controlling the appearance of tuplets.
Definition Details.h:2206
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:700
Options controlling the appearance and behavior of multimeasure rests.
Definition Options.h:731
Options controlling music spacing.
Definition Options.h:760
Specifies font-specific glyphs used to render common musical symbols.
Definition Options.h:845
Options controlling note/rest display and positioning.
Definition Options.h:927
Options for page formatting in the document.
Definition Options.h:990
Options controlling the appearance of piano braces and brackets.
Definition Options.h:1099
Options controlling the appearance of repeats.
Definition Options.h:1128
Options controlling the appearance of smart shapes in the musx file.
Definition Options.h:1189
Options controlling the appearance and layout of staves.
Definition Options.h:1391
Options controlling the appearance of stems.
Definition Options.h:1418
Options controlling text rendering in the musx file. Many of these options are default values that ar...
Definition Options.h:1489
Options controlling the appearance of ties.
Definition Options.h:1574
Options controlling the appearance and behavior of time signatures.
Definition Options.h:1714
Options controlling the appearance of tuplets.
Definition Options.h:1745
Lists the aleration values of each nth flat in a custom key signature. Normally these values are all ...
Definition Others.h:106
Lists the aleration values of each nth sharp in a custom key signature. Normally these values are all...
Definition Others.h:139
Lists the order of flats by pitch class index (0..6 = C..B) in a custom key signature....
Definition Others.h:165
Lists the order of sharps by pitch class index (0..6 = C..B) in a custom key signature....
Definition Others.h:196
Stores the properties and behaviors of articulation definitions.
Definition Others.h:216
A single beat chart element from Finale's music spacing system.
Definition Others.h:370
Represents a single element in a chord suffix (e.g., a symbol like "1" or "+").
Definition Others.h:432
Represents a list of repeat ending numbers for a RepeatEndingStart instance.
Definition Others.h:479
Represents an element in multimeasure clef list with its positioning and percentage values.
Definition Others.h:499
Identifies the percussion map ("drum library") for a staff style with percussion notation.
Definition Others.h:550
Identifies the percussion map ("drum library") for a staff with percussion notation.
Definition Others.h:530
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:566
Represents the attributes of a TGF entry frame.
Definition Others.h:636
Describes a fretted instrument (strings, frets, name, clef). It is used for both TAB notation and Fre...
Definition Others.h:777
A named group of fretboard diagrams associated with a specific fretboard instrument.
Definition Others.h:689
Fretboard diagram style: shapes, spacing, fonts, and offsets.
Definition Others.h:719
Represents the attributes associated with a Finale key signature.
Definition Others.h:889
An array of step elements from which one can create a key map.
Definition Others.h:851
Represents the attributes of a Finale "layer".
Definition Others.h:921
Represents the name associated with a MarkingCategory.
Definition Others.h:1132
Represents a category of markings used.
Definition Others.h:1033
Assigns a TextExpressionDef or ShapeExpressionDef to a measure.
Definition Others.h:1325
Represents the Measure Number Region with detailed font and enclosure settings for score and part dat...
Definition Others.h:1464
Represents the attributes of a measure.
Definition Others.h:1146
Represents a group ID for a multi-staff setup.
Definition Others.h:1657
Represents a group of instruments spanning multiple staves.
Definition Others.h:1675
Represents the attributes of a multimeasure rest in the page layout.
Definition Others.h:1611
Overrides abbreviated name positioning for Staff.
Definition Others.h:1728
Overrides full name positioning for Staff.
Definition Others.h:1756
Overrides abbreviated name positioning for StaffStyle.
Definition Others.h:1742
Overrides full name positioning for StaffStyle.
Definition Others.h:1770
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:1840
Represents the attributes of a page in the page layout.
Definition Others.h:1783
Represents the attributes of a Finale "partDef".
Definition Others.h:1953
Represents global values that can vary by part.
Definition Others.h:2018
Defines voicing options for linked parts, either by selection rules or by assigning a layer.
Definition Others.h:2067
Represents percussion notehead and staff position info for a given percussion note type.
Definition Others.h:2131
Per-instance positioning overrides for RepeatBack.
Definition Others.h:2415
Represents a repeat-backward marker with positioning and behavior properties.
Definition Others.h:2205
Per-instance positioning overrides for the line positioning of RepeatEndingStart.
Definition Others.h:2431
Represents a repeat ending start marker in the document.
Definition Others.h:2257
Per-instance positioning overrides for text positioning of RepeatEndingStart.
Definition Others.h:2447
Represents the text associated with a RepeatEndingStart.
Definition Others.h:2341
Represents a list of repeat ending numbers for a RepeatEndingStart instance.
Definition Others.h:2362
Stores the properties and behaviors of shape expressions.
Definition Others.h:2476
Represents a graphic used by a specific ShapeDef.
Definition Graphics.h:283
Represents a Finale smart shape custom line style.
Definition SmartShape.h:458
Assigns a smart shape or center shape to a measure.
Definition SmartShape.h:620
Represents a Finale smart shape.
Definition SmartShape.h:217
Defines the split point(s) where a measure may be divided between two systems. A measure can only spl...
Definition Others.h:2541
This class specified the name of a staff list used by @ ref MarkingCategory.
Definition Others.h:2580
This class is used by MarkingCategory to define the staves for parts in a staff list.
Definition Others.h:2594
This class is used by MarkingCategory to define the staves for parts in a staff list.
Definition Others.h:2610
This class specified the name of a staff list used by RepeatEndingStart, RepeatBack,...
Definition Others.h:2626
This class is used by repeat classes to define the forced staves for parts in a staff list....
Definition Others.h:2657
This class is used by repeat classes to define the staves for parts in a staff list.
Definition Others.h:2640
This class is used by repeat classes to define the forced staves for the score in a staff list....
Definition Others.h:2690
This class is used by repeat classes to define the staves for the score in a staff list.
Definition Others.h:2673
Represents an assignment.
Definition Staff.h:652
Represents a Finale staff style.
Definition Staff.h:515
Represents the attributes of a staff system in the page layout.
Definition Others.h:2732
An array of StaffUsed defines a set of staves in a staff system or in Scroll View.
Definition Others.h:2816
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:2849
A single tempo change value entered with Finale's Tempo tool.
Definition Others.h:2880
Represents the attributes of a Finale "textBlock".
Definition Others.h:2916
Stores the properties and behaviors of text expressions.
Definition Others.h:2977
The enclosure for a text expression (if it exists)
Definition Others.h:3035
Represents a text repeat assignment with positioning and behavior properties.
Definition Others.h:3052
Defines text repeat elements with font styling and justification.
Definition Others.h:3110
The enclosure for a text expression (if it exists)
Definition Others.h:3152
Per-instance positioning overrides for TextRepeatDef.
Definition Others.h:2462
Represents the text associated with a TextRepeatDef.
Definition Others.h:3169
Represents the lower composite time signature array.
Definition Others.h:3192
Represents the upper composite time signature structure.
Definition Others.h:3227
Maps the number of flats to a tonal center for a linear custom key. If there are zero flats or sharps...
Definition Others.h:3271
Maps number of sharps (0..7) to a tonal center for a linear custom key. Also maps 0 sharps or flats....
Definition Others.h:3293
Contains block text (Finale Text Tool, both page- and measure-attached)
Definition Texts.h:188
Contains bookmark description text.
Definition Texts.h:235
Contains text blocks associated with text expressions.
Definition Texts.h:218
Contains File Info text (from Finale's Score Manager)
Definition Texts.h:51
Contains chorus text for lyrics.
Definition Texts.h:162
Contains section text for lyrics.
Definition Texts.h:175
Contains verse text for lyrics.
Definition Texts.h:149
Contains text blocks associated with custom line smart shapes.
Definition Texts.h:203
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:67
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:150
static constexpr bool is_registered_type_v
Shorthand to get the value of is_registered_type.
Definition TypeRegistry.h:121
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 DocumentElement.h:35
std::shared_ptr< IXmlElement > XmlElementPtr
shared pointer to IXmlElement
Definition XmlInterface.h:121
object model for musx file (enigmaxml)
Definition BaseClasses.h:38
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:126
std::string_view xmlNodeName
The static std::string_view containing the instance's node name.
Definition TypeRegistry.h:132
std::shared_ptr< EnigmaBase > instance
The newly created instance.
Definition TypeRegistry.h:131
CreatedInstanceInfo(std::shared_ptr< EnigmaBase > inst, std::string_view nodeName)
Constructor.
Definition TypeRegistry.h:128
Determine at compile-time if type T is a class in this registry.
Definition TypeRegistry.h:116