LibMusicXML 3.22
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
22namespace MusicXML2
23{
24
29
30//______________________________________________________________________________
50class 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) {}
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
103
104} // namespace MusicXML2
105
106
107#endif
Definition basevisitor.h:25
Definition browser.h:22
branchs::iterator literator
the current level iterator type
Definition ctree.h:128
An xml tree browser that "unroll" the score.
Definition unrolled_xml_tree_browser.h:57
ctree< xmlelement >::literator fEndIterator
indicates the end of to visit
Definition unrolled_xml_tree_browser.h:78
ctree< xmlelement >::literator fNextIterator
indicates the next elt to visit
Definition unrolled_xml_tree_browser.h:79
ctree< xmlelement >::literator fForwardRepeat
the forward repeat location
Definition unrolled_xml_tree_browser.h:77
int fStoreDelay
an iterations counter for delayed store
Definition unrolled_xml_tree_browser.h:83
ctree< xmlelement >::literator fSegnoIterator
the segno location
Definition unrolled_xml_tree_browser.h:80
ctree< xmlelement >::literator * fStoreIterator
a pointer to store the current iterator
Definition unrolled_xml_tree_browser.h:82
ctree< xmlelement >::literator fFirstMeasure
the first measure iterator
Definition unrolled_xml_tree_browser.h:76
ctree< xmlelement >::literator fCodaIterator
the segno location
Definition unrolled_xml_tree_browser.h:81
Definition visitor.h:27