2
* Copyright © 2010 Canonical Ltd.
4
* Permission to use, copy, modify, distribute, and sell this software
5
* and its documentation for any purpose is hereby granted without
6
* fee, provided that the above copyright notice appear in all copies
7
* and that both that copyright notice and this permission notice
8
* appear in supporting documentation, and that the name of
9
* Canonical Ltd. not be used in advertising or publicity pertaining to
10
* distribution of the software without specific, written prior permission.
11
* Canonical Ltd. makes no representations about the suitability of this
12
* software for any purpose. It is provided "as is" without express or
15
* CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17
* NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
* Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
26
#include <core/valueholder.h>
31
static ValueHolder *gDefault;
34
class PrivateValueHolder
38
std::map<CompString, CompPrivate> valueMap;
41
ValueHolder::ValueHolder () :
42
priv (new PrivateValueHolder)
47
ValueHolder::Default ()
53
ValueHolder::SetDefault (ValueHolder *v)
59
ValueHolder::storeValue (CompString key, CompPrivate value)
61
std::map<CompString,CompPrivate>::iterator it;
63
it = priv->valueMap.find (key);
65
if (it != priv->valueMap.end ())
71
priv->valueMap.insert (std::pair<CompString,CompPrivate> (key, value));
76
ValueHolder::eraseValue (CompString key)
78
std::map<CompString,CompPrivate>::iterator it;
79
it = priv->valueMap.find (key);
81
if (it != priv->valueMap.end ())
83
priv->valueMap.erase (key);
88
ValueHolder::hasValue (CompString key)
90
return (priv->valueMap.find (key) != priv->valueMap.end ());
94
ValueHolder::getValue (CompString key)
98
std::map<CompString,CompPrivate>::iterator it;
99
it = priv->valueMap.find (key);
101
if (it != priv->valueMap.end ())