| [6380] | 1 | /*! | 
|---|
|  | 2 | * @file proto_singleton.h | 
|---|
|  | 3 | * @brief Definition of the ... singleton Class | 
|---|
|  | 4 | */ | 
|---|
|  | 5 |  | 
|---|
|  | 6 | #ifndef _PREFERENCES_H | 
|---|
|  | 7 | #define _PREFERENCES_H | 
|---|
|  | 8 |  | 
|---|
|  | 9 | #include "base_object.h" | 
|---|
|  | 10 | #include "multi_type.h" | 
|---|
| [8362] | 11 | #include <list> | 
|---|
| [6380] | 12 |  | 
|---|
|  | 13 | // FORWARD DECLARATION | 
|---|
|  | 14 |  | 
|---|
| [6388] | 15 | class IniFilePrefsReader; | 
|---|
| [6380] | 16 |  | 
|---|
|  | 17 | typedef struct { | 
|---|
| [7236] | 18 | std::string name; | 
|---|
| [6380] | 19 | MultiType value; | 
|---|
| [6388] | 20 | bool modified; | 
|---|
| [6380] | 21 | } prefItem; | 
|---|
|  | 22 |  | 
|---|
|  | 23 | typedef struct { | 
|---|
| [7236] | 24 | std::string sectionName; | 
|---|
| [6380] | 25 | std::list<prefItem> items; | 
|---|
|  | 26 | } prefSection ; | 
|---|
|  | 27 |  | 
|---|
|  | 28 |  | 
|---|
|  | 29 | //! A default singleton class. | 
|---|
|  | 30 | class Preferences : public BaseObject { | 
|---|
|  | 31 |  | 
|---|
|  | 32 | public: | 
|---|
|  | 33 | virtual ~Preferences(void); | 
|---|
|  | 34 | /** @returns a Pointer to the only object of this Class */ | 
|---|
|  | 35 | inline static Preferences* getInstance(void) { if (!singletonRef) singletonRef = new Preferences();  return singletonRef; }; | 
|---|
|  | 36 |  | 
|---|
|  | 37 | //check if this entry exists | 
|---|
| [7248] | 38 | bool sectionExists(const std::string& section ); | 
|---|
| [7236] | 39 | bool exists(const std::string& section, const std::string& name); | 
|---|
| [6380] | 40 |  | 
|---|
| [7236] | 41 | void setString(const std::string& section, const std::string& name, const std::string& value, bool dontSetModified = false); | 
|---|
|  | 42 | void setInt(const std::string& section, const std::string& name, int value, bool dontSetModified = false); | 
|---|
|  | 43 | void setFloat(const std::string& section, const std::string& name, float value, bool dontSetModified = false); | 
|---|
| [7243] | 44 | void setMultiType(const std::string& section, const std::string& name, const MultiType& value, bool dontSetModified = false); | 
|---|
| [6380] | 45 |  | 
|---|
| [7661] | 46 | std::string getString(const std::string& section, const std::string& name, const std::string& defaultValue); | 
|---|
| [7236] | 47 | int getInt(const std::string& section, const std::string& name, int defaultValue); | 
|---|
|  | 48 | float getFloat(const std::string& section, const std::string& name, float defaultValue); | 
|---|
|  | 49 | MultiType getMultiType(const std::string& section, const std::string& name, const MultiType& defaultValue); | 
|---|
| [6380] | 50 |  | 
|---|
| [7236] | 51 | void setUserIni(const std::string& fileName); | 
|---|
| [6380] | 52 |  | 
|---|
| [6388] | 53 | bool save(); | 
|---|
|  | 54 |  | 
|---|
| [6381] | 55 | void debug(); | 
|---|
| [7661] | 56 |  | 
|---|
| [7248] | 57 | std::list<std::string> listKeys( const std::string section ); | 
|---|
| [6381] | 58 |  | 
|---|
|  | 59 |  | 
|---|
| [6380] | 60 | private: | 
|---|
|  | 61 | Preferences(void); | 
|---|
|  | 62 | static Preferences* singletonRef; | 
|---|
|  | 63 |  | 
|---|
|  | 64 | std::list<prefSection> data; | 
|---|
| [6388] | 65 |  | 
|---|
|  | 66 | std::list<IniFilePrefsReader*> iniFilePrefsReaders; | 
|---|
|  | 67 |  | 
|---|
| [7244] | 68 | std::string fileName; | 
|---|
| [6388] | 69 |  | 
|---|
| [6380] | 70 | }; | 
|---|
|  | 71 |  | 
|---|
|  | 72 | #endif /* _PREFERENCES_H */ | 
|---|