LibMusicXML  3.18
oahOah.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 ___oahOah___
14 #define ___oahOah___
15 
16 #include <set>
17 
18 #include "exports.h"
19 
20 #include "oahBasicTypes.h"
21 
22 
23 namespace MusicXML2
24 {
25 
26 //______________________________________________________________________________
28 {
29  public:
30 
31  // creation
32  // ------------------------------------------------------
33 
35  string shortName,
36  string longName,
37  string description,
38  string valueSpecification,
39  string variableName,
40  oahOptionalValuesStyleKind&
41  oahOptionalValuesStyleKindVariable);
42 
43  protected:
44 
45  // constructors/destructor
46  // ------------------------------------------------------
47 
49  string shortName,
50  string longName,
51  string description,
52  string valueSpecification,
53  string variableName,
54  oahOptionalValuesStyleKind&
55  oahOptionalValuesStyleKindVariable);
56 
58 
59  public:
60 
61  // set and get
62  // ------------------------------------------------------
63 
64  void setOahOptionalValuesStyleKindVariable (
65  oahOptionalValuesStyleKind value)
66  {
67  fOahOptionalValuesStyleKindVariable = value;
68  }
69 
70  public:
71 
72  // services
73  // ------------------------------------------------------
74 
75  S_oahValuedAtom handleOptionUnderName (
76  string optionName,
77  ostream& os);
78 
79  void handleValue (
80  string theString,
81  ostream& os);
82 
83  public:
84 
85  // visitors
86  // ------------------------------------------------------
87 
88  virtual void acceptIn (basevisitor* v);
89  virtual void acceptOut (basevisitor* v);
90 
91  virtual void browseData (basevisitor* v);
92 
93  public:
94 
95  // print
96  // ------------------------------------------------------
97 
98  string asShortNamedOptionString () const;
99  string asActualLongNamedOptionString () const;
100 
101  void print (ostream& os) const;
102 
103  private:
104 
105  // fields
106  // ------------------------------------------------------
107 
108  oahOptionalValuesStyleKind&
109  fOahOptionalValuesStyleKindVariable;
110 };
112 EXP ostream& operator<< (ostream& os, const S_oahOptionalValuesStyleKindAtom& elt);
113 
114 //______________________________________________________________________________
115 class oahOah : public oahGroup
116 {
117  public:
118 
119  static SMARTP<oahOah> create (
120  string executableName,
121  S_oahHandler handlerUpLink);
122 
123  SMARTP<oahOah> createCloneWithTrueValues (); // JMI
124 
125  public:
126 
127  // initialisation
128  // ------------------------------------------------------
129 
130  void initializeOahOah (
131  bool boolOptionsInitialValue);
132 
133  protected:
134 
135  // constructors/destructor
136  // ------------------------------------------------------
137 
138  oahOah (
139  string executableName,
140  S_oahHandler handlerUpLink);
141 
142  virtual ~oahOah ();
143 
144  public:
145 
146  // quiet mode
147  // ------------------------------------------------------
148 
149  void enforceQuietness ();
150 
151  public:
152 
153  // consistency check
154  // ------------------------------------------------------
155 
156  virtual void checkOptionsConsistency ();
157 
158  public:
159 
160  // set and get
161  // ------------------------------------------------------
162 
163  public:
164 
165  // public services
166  // ------------------------------------------------------
167 
168  private:
169 
170  // private services
171  // ------------------------------------------------------
172 
173  void initializeOahBasicHelpOptions (
174  bool boolOptionsInitialValue);
175 
176  void initializeOahOahAndArgumentsOptions (
177  bool boolOptionsInitialValue);
178 
179 #ifdef TRACE_OAH
180  void initializeOahTraceOah (
181  bool boolOptionsInitialValue);
182 #endif
183 
184  public:
185 
186  // visitors
187  // ------------------------------------------------------
188 
189  virtual void acceptIn (basevisitor* v);
190  virtual void acceptOut (basevisitor* v);
191 
192  virtual void browseData (basevisitor* v);
193 
194  public:
195 
196  // print
197  // ------------------------------------------------------
198 
199  void printOahOahHelp ();
200 
201  void printOahOahValues (int valueFieldWidth);
202 
203  void printAtomOptionsValues (
204  ostream& os,
205  int valueFieldWidth) const;
206 
207  public:
208 
209  // command line
210  // --------------------------------------
211 
212  string fHandlerExecutableName;
213 
214  string fInputSourceName;
215 
216  // options and arguments
217  // --------------------------------------
218 
219  bool fShowOptionsAndArguments;
220 
221  string fCommandLineAsSupplied;
222  string fCommandLineWithShortOptionsNames;
223  string fCommandLineWithLongOptionsNames;
224 
225  // option name
226  // --------------------------------------
227 
228  string fOptionName; // JMI
229 
230  // trace
231  // --------------------------------------
232 
233  bool fTraceOahVisitors;
234 
235  // display
236  // --------------------------------------
237 
238  bool fDisplayOahValues;
239  bool fDisplayOptionsHandler;
240 };
241 typedef SMARTP<oahOah> S_oahOah;
242 EXP ostream& operator<< (ostream& os, const S_oahOah& elt);
243 
244 EXP extern S_oahOah gOahOah;
245 EXP extern S_oahOah gOahOahUserChoices;
246 EXP extern S_oahOah gOahOahWithDetailedTrace;
247 
248 //______________________________________________________________________________
249 void initializeOahOahHandling (
250  string executableName,
251  S_oahHandler handler);
252 
253 
254 }
255 
256 
257 #endif
MusicXML2::oahGroup
Definition: oahBasicTypes.h:2854
MusicXML2::oahOptionalValuesStyleKindAtom
Definition: oahOah.h:28
MusicXML2::SMARTP
the smart pointer implementation
Definition: smartpointer.h:58
MusicXML2::basevisitor
Definition: basevisitor.h:25
MusicXML2::oahValuedAtom
Definition: oahBasicTypes.h:964
MusicXML2::oahOah
Definition: oahOah.h:116