blob: 59c30fad57db13acc558170223a18ccf47c95495 [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
25 // Returns true if the store contains |group|, false otherwise.
26 virtual bool ContainsGroup(const std::string &group) = 0;
27
28 // Deletes |group|:|key|. Returns true on success.
29 virtual bool DeleteKey(const std::string &group, const std::string &key) = 0;
30
31 // Deletes |group|. Returns true on success.
32 virtual bool DeleteGroup(const std::string &group) = 0;
33
34 // Gets a string |value| associated with |group|:|key|. Returns true on
35 // success and false on failure (including when |group|:|key| is not present
36 // in the store).
37 virtual bool GetString(const std::string &group,
38 const std::string &key,
39 std::string *value) = 0;
40
41 // Associates |group|:|key| with a string |value|. Returns true on success,
42 // false otherwise.
43 virtual bool SetString(const std::string &group,
44 const std::string &key,
45 const std::string &value) = 0;
46
47 // Gets a boolean |value| associated with |group|:|key|. Returns true on
48 // success and false on failure (including when the |group|:|key| is not
49 // present in the store).
50 virtual bool GetBool(const std::string &group,
51 const std::string &key,
52 bool *value) = 0;
53
54 // Associates |group|:|key| with a boolean |value|. Returns true on success,
55 // false otherwise.
56 virtual bool SetBool(const std::string &group,
57 const std::string &key,
58 bool value) = 0;
59
60 // Gets a integer |value| associated with |group|:|key|. Returns true on
61 // success and false on failure (including when the |group|:|key| is not
62 // present in the store).
63 virtual bool GetInt(const std::string &group,
64 const std::string &key,
65 int *value) = 0;
66
67 // Associates |group|:|key| with an integer |value|. Returns true on success,
68 // false otherwise.
69 virtual bool SetInt(const std::string &group,
70 const std::string &key,
71 int value) = 0;
Darin Petkov86964e02011-06-29 13:49:28 -070072
Darin Petkovb2841fd2011-06-30 12:54:12 -070073 // Gets a string list |value| associated with |group|:|key|. Returns true on
74 // success and false on failure (including when |group|:|key| is not present
75 // in the store).
76 virtual bool GetStringList(const std::string &group,
77 const std::string &key,
78 std::vector<std::string> *value) = 0;
79
80 // Associates |group|:|key| with a string list |value|. Returns true on
81 // success, false otherwise.
82 virtual bool SetStringList(const std::string &group,
83 const std::string &key,
84 const std::vector<std::string> &value) = 0;
85
Darin Petkov86964e02011-06-29 13:49:28 -070086 // Gets and decrypts string |value| associated with |group|:|key|. Returns
87 // true on success and false on failure (including when |group|:|key| is not
88 // present in the store).
89 virtual bool GetCryptedString(const std::string &group,
90 const std::string &key,
91 std::string *value) = 0;
92
93 // Associates |group|:|key| with a string |value| after encrypting it. Returns
94 // true on success, false otherwise.
95 virtual bool SetCryptedString(const std::string &group,
96 const std::string &key,
97 const std::string &value) = 0;
Darin Petkov083047b2011-06-23 20:42:48 -070098};
99
100} // namespace shill
101
102#endif // SHILL_STORE_INTERFACE_