LibMusicXML  3.18
unrolled_xml_tree_browser.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 __unrolled_xml_tree_browser__
14 #define __unrolled_xml_tree_browser__
15 
16 #include <map>
17 #include "visitor.h"
18 #include "xml.h"
19 #include "browser.h"
20 #include "typedefs.h"
21 
22 namespace MusicXML2
23 {
24 
30 //______________________________________________________________________________
50 class EXP unrolled_xml_tree_browser : public browser<xmlelement>,
51  public visitor<Sxmlelement>,
52  public visitor<S_measure>,
53  public visitor<S_ending>,
54  public visitor<S_repeat>,
55  public visitor<S_part>,
56  public visitor<S_sound>
57 {
58  private:
59  typedef struct { int current; int next; } state;
60  std::map<S_repeat,int> fRepeatMap; // used to avoid loops in miswritten scores
61 
62  enum { kUndefined=-1, kNoInstruction=0 };
63  enum { kNoJump, kDaCapo, kDalSegno, kToCoda };
64 
65  bool fForward;
66  state fJump;
67  state fRound;
68  state fExpectedRound;
69  int fSectionIndex;
70 
71  void reset();
72 
73  protected:
74  basevisitor* fVisitor;
75 
84 
85  public:
86  unrolled_xml_tree_browser(basevisitor* v) : fForward(true), fVisitor(v) {}
87  virtual ~unrolled_xml_tree_browser() {}
88 
89  virtual void visitStart( Sxmlelement& elt);
90  virtual void visitStart( S_measure& elt);
91  virtual void visitStart( S_ending& elt);
92  virtual void visitStart( S_repeat& elt);
93  virtual void visitStart( S_part& elt);
94  virtual void visitStart( S_sound& elt);
95 
96  virtual void browse (xmlelement& t);
97  virtual void forwardBrowse (xmlelement& t);
98  virtual void enter (xmlelement& t) { t.acceptIn(*fVisitor); }
99  virtual void leave (xmlelement& t) { t.acceptOut(*fVisitor); }
100 };
101 
104 } // namespace MusicXML2
105 
106 
107 #endif
MusicXML2::ctree
a simple tree representation
Definition: ctree.h:124
MusicXML2::unrolled_xml_tree_browser::fFirstMeasure
ctree< xmlelement >::literator fFirstMeasure
the first measure iterator
Definition: unrolled_xml_tree_browser.h:76
MusicXML2::unrolled_xml_tree_browser::fStoreDelay
int fStoreDelay
an iterations counter for delayed store
Definition: unrolled_xml_tree_browser.h:83
MusicXML2::unrolled_xml_tree_browser::fSegnoIterator
ctree< xmlelement >::literator fSegnoIterator
the segno location
Definition: unrolled_xml_tree_browser.h:80
MusicXML2::unrolled_xml_tree_browser::fNextIterator
ctree< xmlelement >::literator fNextIterator
indicates the next elt to visit
Definition: unrolled_xml_tree_browser.h:79
MusicXML2::unrolled_xml_tree_browser::fCodaIterator
ctree< xmlelement >::literator fCodaIterator
the segno location
Definition: unrolled_xml_tree_browser.h:81
MusicXML2::unrolled_xml_tree_browser
An xml tree browser that "unroll" the score.
Definition: unrolled_xml_tree_browser.h:57
MusicXML2::unrolled_xml_tree_browser::fEndIterator
ctree< xmlelement >::literator fEndIterator
indicates the end of to visit
Definition: unrolled_xml_tree_browser.h:78
MusicXML2::visitor
Definition: visitor.h:27
MusicXML2::basevisitor
Definition: basevisitor.h:25
MusicXML2::unrolled_xml_tree_browser::fStoreIterator
ctree< xmlelement >::literator * fStoreIterator
a pointer to store the current iterator
Definition: unrolled_xml_tree_browser.h:82
MusicXML2::browser
Definition: browser.h:22
MusicXML2::unrolled_xml_tree_browser::fForwardRepeat
ctree< xmlelement >::literator fForwardRepeat
the forward repeat location
Definition: unrolled_xml_tree_browser.h:77