LibMusicXML  3.18
bsrElements.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 ___bsrElements___
14 #define ___bsrElements___
15 
16 #include "msrElements.h"
17 
18 
19 namespace MusicXML2
20 {
21 
22 //______________________________________________________________________________
23 class bsrElement : public msrElement
24 {
25  public:
26 
27  // creation
28  // ------------------------------------------------------
29 
30  static SMARTP<bsrElement> create (
31  int inputLineNumber);
32 
33  protected:
34 
35  // constructors/destructor
36  // ------------------------------------------------------
37 
38  bsrElement (
39  int inputLineNumber);
40 
41  virtual ~bsrElement ();
42 
43  public:
44 
45  // set and get
46  // ------------------------------------------------------
47 
48  public:
49 
50  // services
51  // ------------------------------------------------------
52 
53  public:
54 
55  // visitors
56  // ------------------------------------------------------
57 
58  virtual void acceptIn (basevisitor* v);
59  virtual void acceptOut (basevisitor* v);
60 
61  virtual void browseData (basevisitor* v);
62 
63  public:
64 
65  // print
66  // ------------------------------------------------------
67 
68  virtual std::string asString () const;
69 
70  virtual std::string asShortString () const;
71 
72  virtual void print (ostream& os) const;
73 
74 };
76 EXP ostream& operator<< (ostream& os, const S_bsrElement& elt);
77 
78 //______________________________________________________________________________
79 template <typename T> class bsrBrowser : public browser<T>
80 {
81  protected:
82 
83  basevisitor* fVisitor;
84 
85  virtual void enter (T& t) { t.acceptIn (fVisitor); }
86  virtual void leave (T& t) { t.acceptOut (fVisitor); }
87 
88  public:
89 
90  bsrBrowser (basevisitor* v) : fVisitor (v)
91  {}
92 
93  virtual ~bsrBrowser ()
94  {}
95 
96  virtual void set (basevisitor* v)
97  { fVisitor = v; }
98 
99  virtual void browse (T& t)
100  {
101  enter (t);
102 
103  t.browseData (fVisitor);
104 
105  leave (t);
106  }
107 };
108 
109 
110 }
111 
112 
113 #endif
MusicXML2::bsrBrowser
Definition: bsrElements.h:80
MusicXML2::bsrElement
Definition: bsrElements.h:24
MusicXML2::SMARTP
the smart pointer implementation
Definition: smartpointer.h:58
MusicXML2::basevisitor
Definition: basevisitor.h:25
MusicXML2::browser
Definition: browser.h:22
MusicXML2::msrElement
Definition: msrElements.h:26