Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/parser/preferences/preferences.h @ 9884

Last change on this file since 9884 was 9884, checked in by bensch, 18 years ago

some movements

File size: 2.1 KB
Line 
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"
11#include <list>
12
13// FORWARD DECLARATION
14
15class IniFilePrefsReader;
16
17//! A default singleton class.
18class Preferences : public BaseObject
19{
20  ObjectListDeclaration(Preferences);
21public:
22  virtual ~Preferences(void);
23  /** @returns a Pointer to the only object of this Class */
24  inline static Preferences* getInstance(void) { if (!singletonRef) singletonRef = new Preferences();  return singletonRef; };
25
26  //check if this entry exists
27  bool sectionExists(const std::string& section );
28  bool exists(const std::string& section, const std::string& name);
29
30  void setString(const std::string& section, const std::string& name, const std::string& value, bool dontSetModified = false);
31  void setInt(const std::string& section, const std::string& name, int value, bool dontSetModified = false);
32  void setFloat(const std::string& section, const std::string& name, float value, bool dontSetModified = false);
33  void setMultiType(const std::string& section, const std::string& name, const MultiType& value, bool dontSetModified = false);
34
35  std::string getString(const std::string& section, const std::string& name, const std::string& defaultValue);
36  int getInt(const std::string& section, const std::string& name, int defaultValue);
37  float getFloat(const std::string& section, const std::string& name, float defaultValue);
38  MultiType getMultiType(const std::string& section, const std::string& name, const MultiType& defaultValue);
39
40  void setUserIni(const std::string& fileName);
41
42  bool save();
43
44  void debug();
45
46  std::list<std::string> listKeys( const std::string section );
47
48private:
49  typedef struct
50  {
51    std::string name;
52    MultiType value;
53    bool modified;
54  }
55  prefItem;
56
57  typedef struct
58  {
59    std::string sectionName;
60    std::list<prefItem> items;
61  }
62  prefSection ;
63
64
65private:
66  Preferences(void);
67
68private:
69  static Preferences* singletonRef;
70
71  std::list<prefSection> data;
72
73  std::list<IniFilePrefsReader*> iniFilePrefsReaders;
74
75  std::string fileName;
76
77};
78
79#endif /* _PREFERENCES_H */
Note: See TracBrowser for help on using the repository browser.