~vcs-imports/wengophone/trunk

« back to all changes in this revision

Viewing changes to libs/util/settings/AutomaticSettings.h

  • Committer: tanguy_k
  • Date: 2006-11-15 14:12:35 UTC
  • Revision ID: vcs-imports@canonical.com-20061115141235-6efc6e38eaa40ca0
* (compilation fix) OWBuild: rename portaudio to PORTAUDIO
* Libutil has only one include path now -> faster compilation
* Remove old directories
* (compilation fix) phapi: ph_msession_stopped() was a macro inside phmedia.h, now it is a standard function. Don't know why but it was not compiling under Windows using CMake

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * WengoPhone, a voice over Internet phone
 
3
 * Copyright (C) 2004-2006  Wengo
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 */
 
19
 
 
20
#ifndef OWAUTOMATICSETTINGS_H
 
21
#define OWAUTOMATICSETTINGS_H
 
22
 
 
23
#include <settings/Settings.h>
 
24
 
 
25
#include <util/String.h>
 
26
#include <util/StringList.h>
 
27
 
 
28
/**
 
29
 * High level component above Settings, tries to make it impossible to make a mistake.
 
30
 *
 
31
 * Implements a default value for keys.
 
32
 *
 
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?
 
35
 *
 
36
 * @see Settings
 
37
 * @author Tanguy Krotoff
 
38
 * @author Philippe Bernery
 
39
 */
 
40
class AutomaticSettings : public Settings {
 
41
public:
 
42
 
 
43
        OWSETTINGS_API AutomaticSettings();
 
44
 
 
45
        OWSETTINGS_API ~AutomaticSettings();
 
46
 
 
47
        /**
 
48
         * @see Settings::getAllKeys()
 
49
         */
 
50
        OWSETTINGS_API StringList getAllKeys() const;
 
51
 
 
52
        /**
 
53
         * @see Settings::getAny()
 
54
         */
 
55
        OWSETTINGS_API boost::any getAny(const std::string & key) const;
 
56
 
 
57
        /**
 
58
         * @see getAny()
 
59
         */
 
60
        OWSETTINGS_API boost::any getDefaultValue(const std::string & key) const;
 
61
 
 
62
 
 
63
        /**
 
64
         * Resets to key to its default value.
 
65
         *
 
66
         * @param key key to reset
 
67
         */
 
68
        OWSETTINGS_API void resetToDefaultValue(const std::string & key);
 
69
 
 
70
        /**
 
71
         * Makes it impossible to use set() with a wrong value type.
 
72
         *
 
73
         * @see Settings::set()
 
74
         */
 
75
        OWSETTINGS_API void set(const std::string & key, const std::string & value);
 
76
 
 
77
        /**
 
78
         * @see set()
 
79
         */
 
80
        OWSETTINGS_API void set(const std::string & key, const StringList & value);
 
81
 
 
82
        /**
 
83
         * @see set()
 
84
         */
 
85
        OWSETTINGS_API void set(const std::string & key, bool value);
 
86
 
 
87
        /**
 
88
         * @see set()
 
89
         */
 
90
        OWSETTINGS_API void set(const std::string & key, int value);
 
91
 
 
92
protected:
 
93
 
 
94
        /**
 
95
         * Makes it impossible to use get() directly.
 
96
         *
 
97
         * @see Settings::get()
 
98
         */
 
99
        OWSETTINGS_API std::string get(const std::string &, const std::string &) const {
 
100
                return String::null;
 
101
        }
 
102
 
 
103
        /**
 
104
         * @see get()
 
105
         */
 
106
        OWSETTINGS_API StringList get(const std::string &, const StringList &) const {
 
107
                static const StringList empty;
 
108
                return empty;
 
109
        }
 
110
 
 
111
        /**
 
112
         * @see get()
 
113
         */
 
114
        OWSETTINGS_API bool get(const std::string &, bool) const {
 
115
                return false;
 
116
        }
 
117
 
 
118
        /**
 
119
         * @see get()
 
120
         */
 
121
        OWSETTINGS_API int get(const std::string &, int) const {
 
122
                return 0;
 
123
        }
 
124
 
 
125
        /**
 
126
         * @see get()
 
127
         */
 
128
        OWSETTINGS_API boost::any getAny(const std::string &, const boost::any &) const {
 
129
                static const boost::any empty;
 
130
                return empty;
 
131
        }
 
132
 
 
133
        /**
 
134
         * @see get()
 
135
         */
 
136
        OWSETTINGS_API bool getBooleanKeyValue(const std::string & key) const;
 
137
 
 
138
        /**
 
139
         * @see get()
 
140
         */
 
141
        OWSETTINGS_API int getIntegerKeyValue(const std::string & key) const;
 
142
 
 
143
        /**
 
144
         * @see get()
 
145
         */
 
146
        OWSETTINGS_API std::string getStringKeyValue(const std::string & key) const;
 
147
 
 
148
        /**
 
149
         * @see get()
 
150
         */
 
151
        OWSETTINGS_API StringList getStringListKeyValue(const std::string & key) const;
 
152
 
 
153
        /** Associates a key to a default value. */
 
154
        Keys _keyDefaultValueMap;
 
155
};
 
156
 
 
157
#endif  //OWAUTOMATICSETTINGS_H