]> vaikene.ee Git - evaf/blob - src/libs/Common/prop.h
Mac OS changes and switched to c++11.
[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-2019 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 #include <QScopedPointer>
27
28 class QSettings;
29
30 namespace eVaf {
31 namespace Common {
32 namespace Internal {
33
34 /**
35 * Implementation of the iProp interface.
36 *
37 * This class implements the iProp interface for global properties and variables.
38 * Persistent properties are stored in the file '.\<appname\>.dat' in the directory
39 * returned with the eVaf::Common::iApp::dataRootDir() function. The file is in the
40 * QSettings::IniFormat format.
41 */
42 class Prop : public iProp
43 {
44 Q_OBJECT
45
46 public:
47
48 /**
49 * Destroys the iProp interface instance
50 */
51 static void destroyInstance();
52
53 Prop();
54
55 virtual ~Prop();
56
57 /**
58 * Returns the current implementation of the iProp interface
59 */
60 iProp * _interface() const;
61
62 /**
63 * Initializes the iProp interface implementation
64 * @return True if succeeded; false if not
65 */
66 bool init();
67
68 /**
69 * Finalizes the iProp interface implementation
70 */
71 void done();
72
73 /*
74 iProp interface
75 */
76
77 virtual QVariant getValue(QString const & name, QVariant const & defaultValue) const;
78
79 virtual void setValue(QString const & name, QVariant const & value, bool persistent = false);
80
81
82 private: // Members
83
84 /// List of properties
85 QHash<QString, QVariant> mProps;
86
87 /// Persistent property values
88 QScopedPointer<QSettings> mPersistentProps;
89
90 };
91
92 } // namespace eVaf::Common::Internal
93 } // namespace eVaf::Common
94 } // namespace eVaf
95
96 #endif // prop.h