Verovio
Source code documentation
expansionmap.h
1 // Name: expansionmap.h
3 // Author: Werner Goebl
4 // Created: 2019
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_EXPANSION_MAP_H__
9 #define __VRV_EXPANSION_MAP_H__
10 
11 #include <map>
12 
13 //----------------------------------------------------------------------------
14 
15 #include "expansion.h"
16 #include "options.h"
17 
18 namespace vrv {
19 
20 class Score;
21 class Section;
22 
23 class ExpansionMap {
24 
25 public:
31  ExpansionMap();
32  virtual ~ExpansionMap();
34 
35  /*
36  * Clear the content of the expansion map.
37  */
38  virtual void Reset();
39 
44 
48  Object *Expand(Expansion *expansion, xsdAnyURI_List &existingList, Object *prevSection,
49  xsdAnyURI_List &deletionList, bool deleteList);
50 
51  std::vector<std::string> GetExpansionIDsForElement(const std::string &xmlId);
52 
56  void ToJson(std::string &output);
57 
62 
67  void SetProcessed(bool isProcessed) { m_isProcessed = isProcessed; }
68  bool IsProcessed() { return m_isProcessed; }
70 
71  //----------------//
72  // Static methods //
73  //----------------//
74 
79  static bool IsRepeatStart(Measure *measure);
80  static bool IsRepeatEnd(Measure *measure);
81  static bool IsNextRepeatStart(Measure *measure);
82  static bool IsPreviousRepeatEnd(Measure *measure);
84 
85 private:
86  bool UpdateIDs(Object *object);
87 
88  void GetIDList(Object *object, std::vector<std::string> &idList);
89 
90  void GeneratePredictableIDs(Object *source, Object *target);
91 
93  bool AddExpandedIDToExpansionMap(const std::string &origXmlId, std::string newXmlId);
94 
95  std::string CreateSection(
96  Section *section, const ListOfObjects::iterator &first, const ListOfObjects::iterator &last);
97 
98 public:
100  std::map<std::string, std::vector<std::string>> m_map;
101 
102 private:
104  bool m_isProcessed;
105 };
106 
107 } // namespace vrv
108 
109 #endif /* expansionmap_h */
This class represents a MEI expansion.
Definition: expansion.h:26
Definition: expansionmap.h:23
void GenerateExpansionFor(Score *score)
Generate an expan for the score analysing the repeats and endings.
std::map< std::string, std::vector< std::string > > m_map
The expansion map indicates which xmlId has been repeated (expanded) elsewhere.
Definition: expansionmap.h:100
void ToJson(std::string &output)
Write the currentexpansionMap to a JSON string.
Object * Expand(Expansion *expansion, xsdAnyURI_List &existingList, Object *prevSection, xsdAnyURI_List &deletionList, bool deleteList)
Expand expansion recursively.
bool HasExpansionMap()
Check if m_expansionMap has been filled.
This class represents a basic object.
Definition: object.h:64
This class represent a <score> in MEI.
Definition: score.h:30