LibMusicXML  3.18
msrPartGroups.h
1 /*
2  MusicXML Library
3  Copyright (C) Grame 2006-2013
4 
5  This Source Code Form is subject to the terms of the Mozilla Public
6  License, v. 2.0. If a copy of the MPL was not distributed with this
7  file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
10  research@grame.fr
11 */
12 
13 #ifndef ___msrPartGroups___
14 #define ___msrPartGroups___
15 
16 #include "msrPartGroupElements.h"
17 
18 #include "msrMutualDependencies.h"
19 
20 
21 namespace MusicXML2
22 {
23 
24 //______________________________________________________________________________
25 class msrPart;
26 typedef SMARTP<msrPart> S_msrPart;
27 
28 class msrPartGroup;
29 typedef SMARTP<msrPartGroup> S_msrPartGroup;
30 
31 class msrScore;
32 typedef SMARTP<msrScore> S_msrScore;
33 
34 //______________________________________________________________________________
36 {
37  public:
38 
39  /*
40  There is no hierarchy implied in part-group elements.
41  All that matters is the sequence of part-group elements relative to score-part elements.
42  The sequencing of two consecutive part-group elements does not matter.
43  It is the default-x attribute that indicates the left-to-right ordering of the group symbols.
44 
45  <part-group number="1" type="start">
46  <group-name>Trombones</group-name>
47  <group-abbreviation>Trb.</group-abbreviation>
48  <group-symbol default-x="-12">brace</group-symbol>
49  <group-barline>yes</group-barline>
50  </part-group>
51  */
52 
53  // data types
54  // ------------------------------------------------------
55 
56  enum msrPartGroupImplicitKind {
57  kPartGroupImplicitYes, kPartGroupImplicitNo};
58 
59  static string partGroupImplicitKindAsString (
60  msrPartGroupImplicitKind partGroupImplicitKind);
61 
62  enum msrPartGroupTypeKind {
63  kPartGroupTypeNone,
64  kPartGroupTypeStart, kPartGroupTypeStop };
65 
66  static string partGroupTypeKindAsString (
67  msrPartGroupTypeKind partGroupTypeKind);
68 
69  enum msrPartGroupSymbolKind {
70  kPartGroupSymbolNone,
71  kPartGroupSymbolBrace, kPartGroupSymbolBracket,
72  kPartGroupSymbolLine, kPartGroupSymbolSquare};
73 
74  static string partGroupSymbolKindAsString (
75  msrPartGroupSymbolKind partGroupSymbolKind);
76 
77  enum msrPartGroupBarlineKind {
78  kPartGroupBarlineYes, kPartGroupBarlineNo};
79 
80  static string partGroupBarlineKindAsString (
81  msrPartGroupBarlineKind partGroupBarlineKind);
82 
83  // creation from MusicXML
84  // ------------------------------------------------------
85 
86  static SMARTP<msrPartGroup> create (
87  int inputLineNumber,
88  int partGroupNumber,
89  int partGroupAbsoluteNumber,
90  string partGroupName,
91  string partGroupNameDisplayText,
92  string partGroupAccidentalText,
93  string partGroupAbbreviation,
94  msrPartGroupSymbolKind partGroupSymbolKind,
95  int partGroupSymbolDefaultX,
96  msrPartGroupBarlineKind partGroupBarlineKind,
97  S_msrPartGroup partGroupPartGroupUpLink,
98  S_msrScore partGroupScoreUpLink);
99 
100  static SMARTP<msrPartGroup> createImplicitPartGroup (
101  int partGroupNumber,
102  int partGroupAbsoluteNumber,
103  string partGroupName,
104  string partGroupNameDisplayText,
105  string partGroupAccidentalText,
106  string partGroupAbbreviation,
107  msrPartGroupBarlineKind partGroupBarlineKind,
108  S_msrScore partGroupScoreUpLink);
109 
110  SMARTP<msrPartGroup> createPartGroupNewbornClone (
111  S_msrPartGroup partGroupClone, // the upLink for embeddeed part groups
112  S_msrScore scoreClone);
113 
114  protected:
115 
116  // constructors/destructor
117  // ------------------------------------------------------
118 
119  msrPartGroup (
120  int inputLineNumber,
121  int partGroupNumber,
122  int partGroupAbsoluteNumber,
123  string partGroupName,
124  string partGroupNameDisplayText,
125  string partGroupAccidentalText,
126  string partGroupAbbreviation,
127  msrPartGroupSymbolKind partGroupSymbolKind,
128  int partGroupSymbolDefaultX,
129  msrPartGroupImplicitKind partGroupImplicitKind,
130  msrPartGroupBarlineKind partGroupBarlineKind,
131  S_msrPartGroup partGroupPartGroupUpLink,
132  S_msrScore partGroupScoreUpLink);
133 
134  virtual ~msrPartGroup ();
135 
136  public:
137 
138  // set and get
139  // ------------------------------------------------------
140 
141  // upLinks
142  void setPartGroupPartGroupUpLink (
144  {
145  fPartGroupPartGroupUpLink =
146  partGroup;
147  }
148 
149  S_msrPartGroup getPartGroupPartGroupUpLink () const
150  { return fPartGroupPartGroupUpLink; }
151 
152  S_msrScore getPartGroupScoreUpLink () const
153  { return fPartGroupScoreUpLink; }
154 
155  // numbers
156  int getPartGroupAbsoluteNumber () const
157  { return fPartGroupAbsoluteNumber; }
158 
159  int getPartGroupNumber () const
160  { return fPartGroupNumber; }
161 
162  // names
163 
164  string getPartGroupCombinedName () const;
165 
166  string getPartGroupCombinedNameWithoutEndOfLines () const;
167  // for comments in LilyPond code
168 
169  // miscellaneous
170 
171  string getPartGroupNameDisplayText () const
172  { return fPartGroupNameDisplayText; }
173 
174  string getPartGroupAccidentalText () const
175  { return fPartGroupAccidentalText; }
176 
177  string getPartGroupName () const
178  { return fPartGroupName; }
179 
180  string getPartGroupAbbreviation () const
181  { return fPartGroupAbbreviation; }
182 
183  msrPartGroupSymbolKind
184  getPartGroupSymbolKind () const
185  { return fPartGroupSymbolKind; }
186 
187  int getPartGroupSymbolDefaultX () const
188  { return fPartGroupSymbolDefaultX; }
189 
190  msrPartGroupImplicitKind
191  getPartGroupImplicitKind () const
192  { return fPartGroupImplicitKind; }
193 
194  msrPartGroupBarlineKind
195  getPartGroupBarlineKind () const
196  { return fPartGroupBarlineKind; }
197 
198  void setPartGroupInstrumentName (string name);
199 
200  string getPartGroupInstrumentName () const
201  { return fPartGroupInstrumentName; }
202 
203  const list<S_msrPartGroupElement>&
204  getPartGroupElements () const
205  { return fPartGroupElements; }
206 
207  // services
208  // ------------------------------------------------------
209 
210  S_msrPart appendPartToPartGroupByItsPartID ( // JMI superflous
211  int inputLineNumber,
212  string partID);
213 
214  void appendPartToPartGroup (S_msrPart part);
215 
216  void removePartFromPartGroup (
217  int inputLineNumber,
218  S_msrPart partToBeRemoved);
219 
220  void prependSubPartGroupToPartGroup (
222 
223  void appendSubPartGroupToPartGroup (
225 
226  S_msrPart fetchPartFromPartGroupByItsPartID (
227  int inputLineNumber,
228  string partID);
229 
230  void collectPartGroupPartsList (
231  int inputLineNumber,
232  list<S_msrPart>& partsList);
233 
234  public:
235 
236  // visitors
237  // ------------------------------------------------------
238 
239  virtual void acceptIn (basevisitor* v);
240  virtual void acceptOut (basevisitor* v);
241 
242  virtual void browseData (basevisitor* v);
243 
244  public:
245 
246  // print
247  // ------------------------------------------------------
248 
249  string partGroupSymbolKindAsString () const
250  {
251  return
252  partGroupSymbolKindAsString (
253  fPartGroupSymbolKind);
254  }
255 
256  void printPartGroupParts (
257  int inputLineNumber,
258  ostream& os);
259 
260  string partGroupImplicitKindAsString () const;
261 
262  string partGroupBarlineKindAsString () const;
263 
264  virtual string asString () const;
265 
266  virtual void print (ostream& os) const;
267 
268  virtual void printSummary (ostream& os);
269 
270  private:
271 
272  // fields
273  // ------------------------------------------------------
274 
275  // upLinks
276 
277  S_msrPartGroup fPartGroupPartGroupUpLink;
278  // part groups can be nested
279 
280  S_msrScore fPartGroupScoreUpLink;
281 
282  // numbers
283 
284  int fPartGroupNumber;
285  int fPartGroupAbsoluteNumber;
286 
287  // name
288 
289  string fPartGroupName;
290  string fPartGroupNameDisplayText;
291 
292  string fPartGroupAccidentalText;
293 
294  string fPartGroupAbbreviation;
295 
296  // symbol kind
297 
298  msrPartGroupSymbolKind
299  fPartGroupSymbolKind;
300 
301  // default X
302 
303  int fPartGroupSymbolDefaultX;
304 
305  // implicit
306 
307  msrPartGroupImplicitKind
308  fPartGroupImplicitKind;
309 
310  // bar line
311 
312  msrPartGroupBarlineKind
313  fPartGroupBarlineKind;
314 
315  // instrument name
316 
317  string fPartGroupInstrumentName; // JMI
318 
319  // accessing parts by name
320  map<string, S_msrPart>
321  fPartGroupPartsMap;
322 
323  // allowing for both parts and (sub-)part groups as elements
324  list<S_msrPartGroupElement>
325  fPartGroupElements;
326 };
328 EXP ostream& operator<< (ostream& os, const S_msrPartGroup& elt);
329 
330 
331 }
332 
333 #endif
Definition: basevisitor.h:25
Definition: msrPartGroupElements.h:27
Definition: msrPartGroups.h:36
Definition: partlistvisitor.h:29
Definition: msrParts_MUT_DEP.h:8