Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7142 was 6388, checked in by rennerc, 19 years ago

reading and writing inifiles now works

File size: 1.8 KB
RevLine 
[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"
[6388]11#include "lib/parser/ini_parser/ini_parser.h"
[6380]12
13// FORWARD DECLARATION
14
[6388]15class IniFilePrefsReader;
[6380]16
17typedef struct {
18  char* name;
19  MultiType value;
[6388]20  bool modified;
[6380]21} prefItem;
22
23typedef struct {
24  char* sectionName;
25  std::list<prefItem> items;
26} prefSection ;
27
28
29//! A default singleton class.
30class 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
38   bool exists(const char* section, const char* name);
39
[6388]40   void setString(const char* section, const char* name, const char* value, bool dontSetModified = false);
41   void setInt(const char* section, const char* name, int value, bool dontSetModified = false);
42   void setFloat(const char* section, const char* name, float value, bool dontSetModified = false);
43   void setMultiType(const char* section, const char* name, MultiType& value, bool dontSetModified = false);
[6380]44
45   const char* getString(const char* section, const char* name, const char* defaultValue);
46   int getInt(const char* section, const char* name, int defaultValue);
47   float getFloat(const char* section, const char* name, float defaultValue);
48   MultiType getMultiType(const char* section, const char* name, const MultiType& defaultValue);
49
[6388]50   void setUserIni(const char* fileName);
[6380]51
[6388]52   bool save();
53
54
[6381]55   void debug();
56
57
[6380]58 private:
59   Preferences(void);
60   static Preferences* singletonRef;
61
62   std::list<prefSection> data;
[6388]63
64   std::list<IniFilePrefsReader*> iniFilePrefsReaders;
65
66   char* fileName;
67
[6380]68};
69
70#endif /* _PREFERENCES_H */
Note: See TracBrowser for help on using the repository browser.