]>
vaikene.ee Git - evaf/blob - src/libs/Common/config.h
2 * @file Common/config.h
3 * @brief eVaf configuration interface implementation
6 * Copyright (c) 2011 Enar Vaikene
8 * This file is part of the eVaf C++ cross-platform application development framework.
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.
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
20 #ifndef __COMMON_CONFIG_H
21 # define __COMMON_CONFIG_H
37 * Structure for queued write operations
41 NameValuePair(QString
const & n
, QVariant
const & v
)
51 * Default implementation of the iConfig interface.
53 * This class implements the iConfig interface using INI files in the eVaf::Common::iApp::instance()->etcDir() directory.
55 class Config
: public iConfig
66 * Returns the current implementation of the iConfig interface
68 iConfig
* interface() const;
71 * Initializes the iConfig interface implementation.
72 * @return True if succeeded; false if not
77 * Finalizes the iConfig interface implementation.
85 virtual QVariant
getValue(QString
const & paramName
, QVariant
const & defaultValue
) const;
87 virtual bool setValue(QString
const & paramName
, QVariant
const & value
, bool commit
);
92 /// List of already opened INI files
93 mutable QHash
<QString
, IniFile
*> mIniFiles
;
96 QQueue
<NameValuePair
> mCommitQueue
;
101 /// Commits queued parameters
104 /// Writes a parameter value to the INI file
105 bool writeValue(QString
const & paramName
, QVariant
const & value
);
107 /// Writes a name/value pair to the INI file
108 inline bool writeValue(NameValuePair
const & param
)
110 return writeValue(param
.name
, param
.value
);
115 } // namespace eVaf::Common::Internal
116 } // namespace eVaf::Common