blob: 9e20ce043ec6241e81f0537049327ad57696b351 [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
Chris Masoneb9c00592011-10-06 13:10:39 -070019 // Flush current in-memory data to disk.
20 virtual bool Flush() = 0;
21
Darin Petkov083047b2011-06-23 20:42:48 -070022 // Returns a set of all groups contained in the store.
23 virtual std::set<std::string> GetGroups() = 0;
24
Paul Stewarta41e38d2011-11-11 07:47:29 -080025 // Returns the names of all groups that contain the named |key|.
26 virtual std::set<std::string> GetGroupsWithKey(const std::string &key) = 0;
27
Darin Petkov083047b2011-06-23 20:42:48 -070028 // Returns true if the store contains |group|, false otherwise.
29 virtual bool ContainsGroup(const std::string &group) = 0;
30
31 // Deletes |group|:|key|. Returns true on success.
32 virtual bool DeleteKey(const std::string &group, const std::string &key) = 0;
33
34 // Deletes |group|. Returns true on success.
35 virtual bool DeleteGroup(const std::string &group) = 0;
36
Paul Stewart5dc40aa2011-10-28 19:43:43 -070037 // Sets a descriptive header on the key file.
38 virtual bool SetHeader(const std::string &header) = 0;
39
Darin Petkov083047b2011-06-23 20:42:48 -070040 // Gets a string |value| associated with |group|:|key|. Returns true on
41 // success and false on failure (including when |group|:|key| is not present
42 // in the store).
43 virtual bool GetString(const std::string &group,
44 const std::string &key,
45 std::string *value) = 0;
46
47 // Associates |group|:|key| with a string |value|. Returns true on success,
48 // false otherwise.
49 virtual bool SetString(const std::string &group,
50 const std::string &key,
51 const std::string &value) = 0;
52
53 // Gets a boolean |value| associated with |group|:|key|. Returns true on
54 // success and false on failure (including when the |group|:|key| is not
55 // present in the store).
56 virtual bool GetBool(const std::string &group,
57 const std::string &key,
58 bool *value) = 0;
59
60 // Associates |group|:|key| with a boolean |value|. Returns true on success,
61 // false otherwise.
62 virtual bool SetBool(const std::string &group,
63 const std::string &key,
64 bool value) = 0;
65
66 // Gets a integer |value| associated with |group|:|key|. Returns true on
67 // success and false on failure (including when the |group|:|key| is not
68 // present in the store).
69 virtual bool GetInt(const std::string &group,
70 const std::string &key,
71 int *value) = 0;
72
73 // Associates |group|:|key| with an integer |value|. Returns true on success,
74 // false otherwise.
75 virtual bool SetInt(const std::string &group,
76 const std::string &key,
77 int value) = 0;
Darin Petkov86964e02011-06-29 13:49:28 -070078
Darin Petkovb2841fd2011-06-30 12:54:12 -070079 // Gets a string list |value| associated with |group|:|key|. Returns true on
80 // success and false on failure (including when |group|:|key| is not present
81 // in the store).
82 virtual bool GetStringList(const std::string &group,
83 const std::string &key,
84 std::vector<std::string> *value) = 0;
85
86 // Associates |group|:|key| with a string list |value|. Returns true on
87 // success, false otherwise.
88 virtual bool SetStringList(const std::string &group,
89 const std::string &key,
90 const std::vector<std::string> &value) = 0;
91
Darin Petkov86964e02011-06-29 13:49:28 -070092 // Gets and decrypts string |value| associated with |group|:|key|. Returns
93 // true on success and false on failure (including when |group|:|key| is not
94 // present in the store).
95 virtual bool GetCryptedString(const std::string &group,
96 const std::string &key,
97 std::string *value) = 0;
98
99 // Associates |group|:|key| with a string |value| after encrypting it. Returns
100 // true on success, false otherwise.
101 virtual bool SetCryptedString(const std::string &group,
102 const std::string &key,
103 const std::string &value) = 0;
Darin Petkov083047b2011-06-23 20:42:48 -0700104};
105
106} // namespace shill
107
108#endif // SHILL_STORE_INTERFACE_