blob: 283b205f4ca4b70fb60b41493c63d35d226cb703 [file] [log] [blame]
Darin Petkov083047b2011-06-23 20:42:48 -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_STORE_INTERFACE_
6#define SHILL_STORE_INTERFACE_
7
8#include <set>
9#include <string>
Darin Petkovb2841fd2011-06-30 12:54:12 -070010#include <vector>
Darin Petkov083047b2011-06-23 20:42:48 -070011
12namespace shill {
13
14// An interface to a persistent store implementation.
15class StoreInterface {
16 public:
17 virtual ~StoreInterface() {}
18
Darin Petkov083047b2011-06-23 20:42:48 -070019 // Returns a set of all groups contained in the store.
20 virtual std::set<std::string> GetGroups() = 0;
21
22 // Returns true if the store contains |group|, false otherwise.
23 virtual bool ContainsGroup(const std::string &group) = 0;
24
25 // Deletes |group|:|key|. Returns true on success.
26 virtual bool DeleteKey(const std::string &group, const std::string &key) = 0;
27
28 // Deletes |group|. Returns true on success.
29 virtual bool DeleteGroup(const std::string &group) = 0;
30
31 // Gets a string |value| associated with |group|:|key|. Returns true on
32 // success and false on failure (including when |group|:|key| is not present
33 // in the store).
34 virtual bool GetString(const std::string &group,
35 const std::string &key,
36 std::string *value) = 0;
37
38 // Associates |group|:|key| with a string |value|. Returns true on success,
39 // false otherwise.
40 virtual bool SetString(const std::string &group,
41 const std::string &key,
42 const std::string &value) = 0;
43
44 // Gets a boolean |value| associated with |group|:|key|. Returns true on
45 // success and false on failure (including when the |group|:|key| is not
46 // present in the store).
47 virtual bool GetBool(const std::string &group,
48 const std::string &key,
49 bool *value) = 0;
50
51 // Associates |group|:|key| with a boolean |value|. Returns true on success,
52 // false otherwise.
53 virtual bool SetBool(const std::string &group,
54 const std::string &key,
55 bool value) = 0;
56
57 // Gets a integer |value| associated with |group|:|key|. Returns true on
58 // success and false on failure (including when the |group|:|key| is not
59 // present in the store).
60 virtual bool GetInt(const std::string &group,
61 const std::string &key,
62 int *value) = 0;
63
64 // Associates |group|:|key| with an integer |value|. Returns true on success,
65 // false otherwise.
66 virtual bool SetInt(const std::string &group,
67 const std::string &key,
68 int value) = 0;
Darin Petkov86964e02011-06-29 13:49:28 -070069
Darin Petkovb2841fd2011-06-30 12:54:12 -070070 // Gets a string list |value| associated with |group|:|key|. Returns true on
71 // success and false on failure (including when |group|:|key| is not present
72 // in the store).
73 virtual bool GetStringList(const std::string &group,
74 const std::string &key,
75 std::vector<std::string> *value) = 0;
76
77 // Associates |group|:|key| with a string list |value|. Returns true on
78 // success, false otherwise.
79 virtual bool SetStringList(const std::string &group,
80 const std::string &key,
81 const std::vector<std::string> &value) = 0;
82
Darin Petkov86964e02011-06-29 13:49:28 -070083 // Gets and decrypts string |value| associated with |group|:|key|. Returns
84 // true on success and false on failure (including when |group|:|key| is not
85 // present in the store).
86 virtual bool GetCryptedString(const std::string &group,
87 const std::string &key,
88 std::string *value) = 0;
89
90 // Associates |group|:|key| with a string |value| after encrypting it. Returns
91 // true on success, false otherwise.
92 virtual bool SetCryptedString(const std::string &group,
93 const std::string &key,
94 const std::string &value) = 0;
Darin Petkov083047b2011-06-23 20:42:48 -070095};
96
97} // namespace shill
98
99#endif // SHILL_STORE_INTERFACE_