blob: bf026000699a50f211b9de2b686c344bd1949428 [file] [log] [blame]
mukesh agrawal7a4e4002011-09-06 11:26:05 -07001// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHILL_KEY_VALUE_STORE_
6#define SHILL_KEY_VALUE_STORE_
7
8#include <map>
9#include <string>
10
11#include <base/basictypes.h>
12
13namespace shill {
14
15class KeyValueStore {
16 // A simple store for key-value pairs, which supports (a limited set of)
17 // heterogenous value types.
18 //
19 // Compare to PropertyStore, which enables a class to (selectively)
20 // expose its instance members as properties accessible via
21 // RPC. (RPC support for ProperyStore is implemented in a
22 // protocol-specific adaptor. e.g. dbus_adpator.)
23 //
24 // Implemented separately from PropertyStore, to avoid complicating
25 // the PropertyStore interface. In particular, objects implementing the
26 // PropertyStore interface always provide the storage themselves. In
27 // contrast, users of KeyValueStore expect KeyValueStore to provide
28 // storage.
29 public:
30 KeyValueStore();
31
32 bool ContainsBool(const std::string &name) const;
33 bool ContainsString(const std::string &name) const;
34
35 bool GetBool(const std::string &name) const;
36 const std::string &GetString(const std::string &name) const;
37
38 void SetBool(const std::string &name, bool value);
39 void SetString(const std::string& name,
40 const std::string& value);
41
42 private:
43 std::map<std::string, bool> bool_properties_;
44 std::map<std::string, std::string> string_properties_;
45
46 DISALLOW_COPY_AND_ASSIGN(KeyValueStore);
47};
48
49} // namespace shill
50
51#endif // SHILL_KEY_VALUE_STORE_