]>
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-2019 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
62 * Destroys the iConfig interface instance.
64 static void destroyInstance();
71 * Returns the current implementation of the iConfig interface
73 iConfig
* _interface() const;
76 * Initializes the iConfig interface implementation.
77 * @return True if succeeded; false if not
82 * Finalizes the iConfig interface implementation.
90 virtual QVariant
getValue(QString
const & paramName
, QVariant
const & defaultValue
) const;
92 virtual bool setValue(QString
const & paramName
, QVariant
const & value
, bool commit
);
97 /// List of already opened INI files
98 mutable QHash
<QString
, IniFile
*> mIniFiles
;
101 QQueue
<NameValuePair
> mCommitQueue
;
106 /// Commits queued parameters
109 /// Writes a parameter value to the INI file
110 bool writeValue(QString
const & paramName
, QVariant
const & value
);
112 /// Writes a name/value pair to the INI file
113 inline bool writeValue(NameValuePair
const & param
)
115 return writeValue(param
.name
, param
.value
);
120 } // namespace eVaf::Common::Internal
121 } // namespace eVaf::Common