BALL 1.5.0
options.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4// $Id: options.h,v 1.26.14.1 2007/03/25 21:23:40 oliver Exp $
5//
6
7#ifndef BALL_DATATYPE_OPTIONS_H
8#define BALL_DATATYPE_OPTIONS_H
9
10#ifndef BALL_COMMON_H
11# include <BALL/common.h>
12#endif
13
14#ifndef BALL_DATATYPE_STRING_H
15# include <BALL/DATATYPE/string.h>
16#endif
17
18#ifndef BALL_DATATYPE_STRINGHASHMAP_H
20#endif
21
23
24#ifndef BALL_MATHS_VECTOR3_H
25# include <BALL/MATHS/vector3.h>
26#endif
27
28#ifndef BALL_CONCEPT_PERSISTENTOBJECT_H
30#endif
31
32namespace BALL
33{
47 : public StringHashMap<String>
48 {
49
50 public:
51
53
54
57
58
61 static const Size MAX_ENTRY_LENGTH;
62
64
67
71
76 Options(const Options& options);
77
83 virtual ~Options();
84
86
89
92 const Options& operator = (const Options& options);
93
96 virtual void clear();
97
99
102
108 bool isInteger(const String& key) const;
109
117 bool isBool(const String& key) const;
118
124 bool isReal(const String& key) const;
125
134 bool isVector(const String& key) const;
135
140 bool isSet(const String& key) const;
141
143
146
147
148 void addParameterDescription(const String& key, String description, ParamFile::ParameterType type, list<String>* allowed_values = NULL);
149
150 /* Return the description that was registered for the parameter identified by the given key */
151 const ParamFile::ParameterDescription* getParameterDescription(const String& key) const;
152
155 Options* createSubcategory(String name);
156
159 Options* getSubcategory(String name);
160
163 beginSubcategories();
164
167 endSubcategories();
168
171 void setName(const String& name);
172
175 const String& getName() const;
176
182 String get(const String& key) const;
183
194 bool getBool(const String& key) const;
195
204 double getReal(const String& key) const;
205
218 Vector3 getVector(const String& key) const;
219
228 long getInteger(const String& key) const;
229
236 void set(const String& key, const String& value);
237
245 void setReal(const String& key, const double value);
246
256 void setVector(const String& key, const Vector3& value);
257
265 void setInteger(const String& key, const long value);
266
274 void setBool(const String& key, const bool value);
275
283 String setDefault(const String& key, const String& value);
284
293 long setDefaultInteger(const String& key, const long value);
294
303 double setDefaultReal(const String& key, const double value);
304
313 bool setDefaultBool(const String& key, const bool value);
314
333 bool readOptionFile(const String& filename);
334
346 bool writeOptionFile(const String& filename) const;
347
353 void write(PersistenceManager& pm) const;
354
361 bool read(PersistenceManager& pm);
362
364 bool operator == (const Options& option) const;
365
367 bool operator != (const Options& option) const;
368
369
371
374
377 virtual void dump (std::ostream& s = std::cout, Size depth = 0) const;
378
380
381 protected:
382
383 /*_ The option table's name */
384 String name_;
385 StringHashMap<ParamFile::ParameterDescription> descriptions_;
386 StringHashMap<Options*> subcategories_;
387 };
388} // namespace BALL
389
390#endif // BALL_DATATYPE_OPTIONS_H
#define BALL_CREATE(name)
Definition: create.h:62
STL namespace.
Definition: constants.h:13
const char * getName()
Definition: rtti.h:97
#define BALL_EXPORT
Definition: COMMON/global.h:50