MNX Document Model
Loading...
Searching...
No Matches
Score.h
1/*
2 * Copyright (C) 2025, Robert Patterson
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22#pragma once
23
24#include "BaseTypes.h"
25#include "CommonClasses.h"
26
27namespace mnx {
28
33namespace score {
34
40{
41public:
43 MultimeasureRest(const std::shared_ptr<json>& root, json_pointer pointer)
45 {
46 }
47
53 MultimeasureRest(Base& parent, const std::string_view& key, int startMeasure, int numMeasures)
55 {
56 set_start(startMeasure);
57 set_duration(numMeasures);
58 }
59
60 MNX_REQUIRED_PROPERTY(int, duration);
61 MNX_OPTIONAL_PROPERTY(std::string, label);
63};
64
70{
71public:
73 LayoutChange(const std::shared_ptr<json>& root, json_pointer pointer)
75 {
76 }
77
84 LayoutChange(Base& parent, const std::string_view& key, const std::string& layoutId,
85 int measureId, const Fraction::Initializer& position)
87 {
88 set_layout(layoutId);
89 create_location(measureId, position);
90 }
91
92 MNX_REQUIRED_PROPERTY(std::string, layout);
94};
95
101{
102public:
104 System(const std::shared_ptr<json>& root, json_pointer pointer)
106 {
107 }
108
113 System(Base& parent, const std::string_view& key, int startMeasure)
115 {
116 set_measure(startMeasure);
117 }
118
119 MNX_OPTIONAL_PROPERTY(std::string, layout);
121 MNX_REQUIRED_PROPERTY(int, measure);
122};
123
129{
130public:
131 using ArrayElementObject::ArrayElementObject;
132
136 Page(Base& parent, const std::string_view& key)
138 {
139 // required children
140 create_systems();
141 }
142
143 MNX_OPTIONAL_PROPERTY(std::string, layout);
145};
146
147} // namespace score
148
154{
155public:
157 Score(const std::shared_ptr<json>& root, json_pointer pointer)
159 {
160 }
161
166 Score(Base& parent, const std::string_view& key, const std::string& scoreName)
168 {
169 set_name(scoreName);
170 }
171
172 MNX_OPTIONAL_PROPERTY(std::string, layout);
174 MNX_REQUIRED_PROPERTY(std::string, name);
176};
177
178} // namespace mnx
Represents an MNX object that is included as an array element.
Definition BaseTypes.h:615
Represents an MNX array, encapsulating property access.
Definition BaseTypes.h:483
Base class wrapper for all MNX JSON nodes.
Definition BaseTypes.h:210
json_pointer pointer() const
Returns the json_pointer for this node.
Definition BaseTypes.h:271
T parent() const
Returns the parent object for this node.
Definition BaseTypes.h:258
const std::shared_ptr< json > & root() const
Returns the root.
Definition BaseTypes.h:288
std::pair< NumType, NumType > Initializer
initializer for Fraction class (numerator, denominator)
Definition CommonClasses.h:43
Represents a system on a page in a score.
Definition CommonClasses.h:133
Represents an element in the scores section of an MNX document.
Definition Score.h:154
MNX_REQUIRED_PROPERTY(std::string, name)
Required name, such as "Flute 1" or "Full Score".
Score(Base &parent, const std::string_view &key, const std::string &scoreName)
Creates a new Score class as a child of a JSON element.
Definition Score.h:166
MNX_OPTIONAL_CHILD(Array< score::Page >, pages)
An optional list of pages.
MNX_OPTIONAL_PROPERTY(std::string, layout)
Layout id, referring to an element in the root-level layouts array.
MNX_OPTIONAL_CHILD(Array< score::MultimeasureRest >, multimeasureRests)
List of multimeasure rests in the score.
Score(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing system layouts.
Definition Score.h:157
Represents a system layout change in a score.
Definition Score.h:70
MNX_REQUIRED_PROPERTY(std::string, layout)
Layout id, referring to an element in the root-level layouts array.
MNX_REQUIRED_CHILD(MeasureRhythmicPosition, location)
location where the new layout takes effect.
LayoutChange(Base &parent, const std::string_view &key, const std::string &layoutId, int measureId, const Fraction::Initializer &position)
Creates a new LayoutChange class as a child of a JSON element.
Definition Score.h:84
LayoutChange(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing system layouts.
Definition Score.h:73
Represents a multimeasure rest in a score.
Definition Score.h:40
MultimeasureRest(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing mm rests.
Definition Score.h:43
MultimeasureRest(Base &parent, const std::string_view &key, int startMeasure, int numMeasures)
Creates a new MultimeasureRest class as a child of a JSON element.
Definition Score.h:53
MNX_REQUIRED_PROPERTY(int, duration)
the number of measures in the multimeasure rest
MNX_OPTIONAL_PROPERTY(std::string, label)
the label to place on the multimeasure rest, if provided.
MNX_REQUIRED_PROPERTY(int, start)
the start measure of the multimeasure rest
Represents a page in a score.
Definition Score.h:129
MNX_OPTIONAL_PROPERTY(std::string, layout)
Layout id, referring to an element in the root-level layouts array.
Page(Base &parent, const std::string_view &key)
Creates a new Page class as a child of a JSON element.
Definition Score.h:136
MNX_REQUIRED_CHILD(Array< System >, systems)
and array systems on the page.
Represents a system on a page in a score.
Definition Score.h:101
System(Base &parent, const std::string_view &key, int startMeasure)
Creates a new System class as a child of a JSON element.
Definition Score.h:113
MNX_REQUIRED_PROPERTY(int, measure)
The first measure in the system.
System(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing system layouts.
Definition Score.h:104
MNX_OPTIONAL_PROPERTY(std::string, layout)
Layout id, referring to an element in the root-level layouts array.
MNX_OPTIONAL_CHILD(Array< LayoutChange >, layoutChanges)
layout changes in the system (e.g., for changes in stem direction)
object model for MNX format
json::json_pointer json_pointer
JSON pointer class for MNX.
Definition BaseTypes.h:197