]> vaikene.ee Git - evaf/blob - src/libs/Common/prop.h
Added the eVaf::Common::iProp interface for global properties and variables.
[evaf] / src / libs / Common / prop.h
1 /**
2 * @file Common/prop.h
3 * @brief Implementation of the iProp interface
4 * @author Enar Vaikene
5 *
6 * Copyright (c) 2011 Enar Vaikene
7 *
8 * This file is part of the eVaf C++ cross-platform application development framework.
9 *
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
15 *
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
18 */
19
20 #ifndef __COMMON_PROP_H
21 # define __COMMON_PROP_H
22
23 #include "iprop.h"
24
25 #include <QHash>
26
27 class QSettings;
28
29 namespace eVaf {
30 namespace Common {
31 namespace Internal {
32
33 /**
34 * Implementation of the iProp interface.
35 *
36 * This class implements the iProp interface for global properties and variables.
37 * Persistent properties are stored in the file '.\<appname\>.dat' in the directory
38 * returned with the eVaf::Common::iApp::dataRootDir() function. The file is in the
39 * QSettings::IniFormat format.
40 */
41 class Prop : public iProp
42 {
43 Q_OBJECT
44
45 public:
46
47 Prop();
48
49 virtual ~Prop();
50
51 /**
52 * Returns the current implementation of the iProp interface
53 */
54 iProp * interface() const;
55
56 /**
57 * Initializes the iProp interface implementation
58 * @return True if succeeded; false if not
59 */
60 bool init();
61
62 /**
63 * Finalizes the iProp interface implementation
64 */
65 void done();
66
67 /*
68 iProp interface
69 */
70
71 virtual QVariant getValue(QString const & name, QVariant const & defaultValue) const;
72
73 virtual void setValue(QString const & name, QVariant const & value, bool persistent = false);
74
75
76 private: // Members
77
78 /// List of properties
79 QHash<QString, QVariant> mProps;
80
81 /// Persistent property values
82 QSettings * mPersistentProps;
83
84 };
85
86 } // namespace eVaf::Common::Internal
87 } // namespace eVaf::Common
88 } // namespace eVaf
89
90 #endif // prop.h