BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 // $Id: options.h,v 1.26.14.1 2007/03/25 21:23:40 oliver Exp $ 00005 // 00006 00007 #ifndef BALL_DATATYPE_OPTIONS_H 00008 #define BALL_DATATYPE_OPTIONS_H 00009 00010 #ifndef BALL_COMMON_H 00011 # include <BALL/common.h> 00012 #endif 00013 00014 #ifndef BALL_DATATYPE_STRING_H 00015 # include <BALL/DATATYPE/string.h> 00016 #endif 00017 00018 #ifndef BALL_DATATYPE_STRINGHASHMAP_H 00019 # include <BALL/DATATYPE/stringHashMap.h> 00020 #endif 00021 00022 #ifndef BALL_MATHS_VECTOR3_H 00023 # include <BALL/MATHS/vector3.h> 00024 #endif 00025 00026 #ifndef BALL_CONCEPT_PERSISTENTOBJECT_H 00027 # include <BALL/CONCEPT/persistentObject.h> 00028 #endif 00029 00030 namespace BALL 00031 { 00044 class BALL_EXPORT Options 00045 : public StringHashMap<String> 00046 { 00047 00048 public: 00049 00050 BALL_CREATE(Options) 00051 00052 00055 00059 static const Size MAX_ENTRY_LENGTH; 00060 00062 00065 00068 Options(); 00069 00074 Options(const Options& options); 00075 00081 virtual ~Options(); 00082 00084 00087 00090 const Options& operator = (const Options& options); 00091 00094 virtual void clear(); 00095 00097 00100 00106 bool isInteger(const String& key) const; 00107 00115 bool isBool(const String& key) const; 00116 00122 bool isReal(const String& key) const; 00123 00132 bool isVector(const String& key) const; 00133 00138 bool isSet(const String& key) const; 00139 00141 00144 00147 void setName(const String& name); 00148 00151 const String& getName() const; 00152 00158 String get(const String& key) const; 00159 00170 bool getBool(const String& key) const; 00171 00180 double getReal(const String& key) const; 00181 00194 Vector3 getVector(const String& key) const; 00195 00204 long getInteger(const String& key) const; 00205 00212 void set(const String& key, const String& value); 00213 00221 void setReal(const String& key, const double value); 00222 00232 void setVector(const String& key, const Vector3& value); 00233 00241 void setInteger(const String& key, const long value); 00242 00250 void setBool(const String& key, const bool value); 00251 00259 String setDefault(const String& key, const String& value); 00260 00269 long setDefaultInteger(const String& key, const long value); 00270 00279 double setDefaultReal(const String& key, const double value); 00280 00289 bool setDefaultBool(const String& key, const bool value); 00290 00309 bool readOptionFile(const String& filename); 00310 00322 bool writeOptionFile(const String& filename) const; 00323 00329 void write(PersistenceManager& pm) const; 00330 00337 bool read(PersistenceManager& pm); 00338 00340 bool operator == (const Options& option) const; 00341 00343 bool operator != (const Options& option) const; 00344 00345 00347 00350 00353 virtual void dump (std::ostream& s = std::cout, Size depth = 0) const; 00354 00356 00357 protected: 00358 00359 /*_ The option table's name */ 00360 String name_; 00361 00362 }; 00363 } // namespace BALL 00364 00365 #endif // BALL_DATATYPE_OPTIONS_H