1 //
2 //  partlistvisitor.hpp
3 //  libmusicxml2
4 //
5 //  Created by Arshia Cont on 05/01/17.
6 //
7 //
8 
9 #ifndef partlistvisitor_h
10 #define partlistvisitor_h
11 
12 #include <map>
13 #include <vector>
14 #include <iostream>
15 #include <sstream>
16 #include <string>
17 
18 #include "exports.h"
19 #include "guido.h"
20 #include "typedefs.h"
21 #include "visitor.h"
22 #include "xml.h"
23 
24 #include "smartlist.h"
25 
26 namespace MusicXML2
27 {
28 
29     class EXP partGroup {
30     public:
partGroup()31         partGroup(): bracket(false), barlineGrouping(false), visited(false) {};
~partGroup()32         virtual ~partGroup() {};
33 
34         std::vector<std::string> partIDs;
35         std::string guidoRange;
36         int guidoRangeStart, guidoRangeStop;
37         bool bracket;
38         bool barlineGrouping;
39         std::string fGroupName;             // optional name of the group
40         std::string fGroupNameDisplay;     // overrides the previous
41         bool visited;
42         int xmlGroupNumber;
43     };
44 
45     class EXP partHeader {
46     public:
partHeader()47         partHeader(): visited(false) {};
partHeader(std::string name,std::string nameabbr)48         partHeader(std::string name, std::string nameabbr):
49             fPartName(name), fPartNameAbbr(nameabbr), visited(false)
50         {};
~partHeader()51         virtual ~partHeader()
52         {
53             fPartNameAbbr.clear(); fPartName.clear();
54         };
55 
56         std::string		fPartName;
57         std::string     fPartNameAbbr;
58         bool visited;
59     };
60 
61     /*!
62      \addtogroup visitors
63   @{
64      */
65 
66     /*!
67      \brief Produces a summary of a MusicXML parts for groupings.
68      */
69     class EXP partlistvisitor :
70     public visitor<S_score_part>,
71     public visitor<S_part_group>
72     {
73     public:
74         partlistvisitor();
~partlistvisitor()75         virtual	~partlistvisitor() {};
76 
77         std::map<int, partGroup> fPartGroups;
78 
79         std::map<std::string, partHeader> fPartHeaders;
80 
81         /*!
82          \brief Returns the part group with first occurence of partID (string)
83          */
84         partGroup* find_first_of_partID_inGroup(std::string partID);
85 
86         /*!
87          \brief Converts XML Part ID list to Guido's Staff range string
88          */
89         void partID2range(partGroup &pGroup);
90 
91         /*!
92          \brief Checks if current staff is lonely in terms of BarFormat definition
93          */
94         bool checkLonelyBarFormat(int staffID);
95 
96     protected:
97 
98         void visitStart( S_score_part& elt);
99         void visitStart( S_part_group& elt);
100 
101         int fPartGroupIncrementer;
102         std::vector<int>  fCurrentPartGroupIndex;
103 
104         std::map<std::string, int> part2staffmap;
105         int staffCreatorCounter;
106     };
107 
108 }   // NAMESPACE MUSICXML2
109 #endif /* partlistvisitor_hpp */
110