2
* WengoPhone, a voice over Internet phone
3
* Copyright (C) 2004-2006 Wengo
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#ifndef OWAUTOMATICSETTINGS_H
21
#define OWAUTOMATICSETTINGS_H
23
#include <settings/Settings.h>
25
#include <util/String.h>
26
#include <util/StringList.h>
29
* High level component above Settings, tries to make it impossible to make a mistake.
31
* Implements a default value for keys.
33
* FIXME merge with settings? I don't remember why this code is not inside Settings
34
* probably because of the default value implementation + the serialization inside Settings -> problem?
37
* @author Tanguy Krotoff
38
* @author Philippe Bernery
40
class AutomaticSettings : public Settings {
43
OWSETTINGS_API AutomaticSettings();
45
OWSETTINGS_API ~AutomaticSettings();
48
* @see Settings::getAllKeys()
50
OWSETTINGS_API StringList getAllKeys() const;
53
* @see Settings::getAny()
55
OWSETTINGS_API boost::any getAny(const std::string & key) const;
60
OWSETTINGS_API boost::any getDefaultValue(const std::string & key) const;
64
* Resets to key to its default value.
66
* @param key key to reset
68
OWSETTINGS_API void resetToDefaultValue(const std::string & key);
71
* Makes it impossible to use set() with a wrong value type.
73
* @see Settings::set()
75
OWSETTINGS_API void set(const std::string & key, const std::string & value);
80
OWSETTINGS_API void set(const std::string & key, const StringList & value);
85
OWSETTINGS_API void set(const std::string & key, bool value);
90
OWSETTINGS_API void set(const std::string & key, int value);
95
* Makes it impossible to use get() directly.
97
* @see Settings::get()
99
OWSETTINGS_API std::string get(const std::string &, const std::string &) const {
106
OWSETTINGS_API StringList get(const std::string &, const StringList &) const {
107
static const StringList empty;
114
OWSETTINGS_API bool get(const std::string &, bool) const {
121
OWSETTINGS_API int get(const std::string &, int) const {
128
OWSETTINGS_API boost::any getAny(const std::string &, const boost::any &) const {
129
static const boost::any empty;
136
OWSETTINGS_API bool getBooleanKeyValue(const std::string & key) const;
141
OWSETTINGS_API int getIntegerKeyValue(const std::string & key) const;
146
OWSETTINGS_API std::string getStringKeyValue(const std::string & key) const;
151
OWSETTINGS_API StringList getStringListKeyValue(const std::string & key) const;
153
/** Associates a key to a default value. */
154
Keys _keyDefaultValueMap;
157
#endif //OWAUTOMATICSETTINGS_H