Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/util/preferences.h @ 8105

Last change on this file since 8105 was 7661, checked in by bensch, 19 years ago

orxonox/trunk: merged the QT_GUI back to the trunk
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/qt_gui . -r7607:HEAD

absolutely no conflicts :)

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