eVaf
config.h
Go to the documentation of this file.
1 
20 #ifndef __COMMON_CONFIG_H
21 # define __COMMON_CONFIG_H
22 
23 #include "iconfig.h"
24 
25 #include <QObject>
26 #include <QString>
27 #include <QVariant>
28 #include <QHash>
29 #include <QQueue>
30 
31 namespace eVaf {
32 namespace Common {
33  class IniFile;
34 namespace Internal {
35 
40 {
41  NameValuePair(QString const & n, QVariant const & v)
42  : name(n)
43  , value(v)
44  {}
45 
46  QString name;
47  QVariant value;
48 };
49 
55 class Config : public iConfig
56 {
57  Q_OBJECT
58 
59 public:
60 
61  Config();
62 
63  virtual ~Config();
64 
68  iConfig * _interface() const;
69 
74  bool init();
75 
79  void done();
80 
81  /*
82  iConfig interface
83  */
84 
85  virtual QVariant getValue(QString const & paramName, QVariant const & defaultValue) const;
86 
87  virtual bool setValue(QString const & paramName, QVariant const & value, bool commit);
88 
89 
90 private: // Members
91 
93  mutable QHash<QString, IniFile *> mIniFiles;
94 
96  QQueue<NameValuePair> mCommitQueue;
97 
98 
99 private: // Methods
100 
102  bool commitValues();
103 
105  bool writeValue(QString const & paramName, QVariant const & value);
106 
108  inline bool writeValue(NameValuePair const & param)
109  {
110  return writeValue(param.name, param.value);
111  }
112 
113 };
114 
115 } // namespace eVaf::Common::Internal
116 } // namespace eVaf::Common
117 } // namespace eVaf
118 
119 #endif // config.h
eVaf configuration interface
eVaf configuration interface.
Definition: iconfig.h:62
Default implementation of the iConfig interface.
Definition: config.h:55
bool COMMON_EXPORT init()
eVaf common library initialized
NameValuePair(QString const &n, QVariant const &v)
Definition: config.h:41
Global eVaf namespace.
Definition: engine.h:37
Structure for queued write operations.
Definition: config.h:39