blob: 24a6d3795427e6378b884eead1a4a3eb1369bc54 [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
Paul Stewart5dc40aa2011-10-28 19:43:43 -070034 // Sets a descriptive header on the key file.
35 virtual bool SetHeader(const std::string &header) = 0;
36
Darin Petkov083047b2011-06-23 20:42:48 -070037 // Gets a string |value| associated with |group|:|key|. Returns true on
38 // success and false on failure (including when |group|:|key| is not present
39 // in the store).
40 virtual bool GetString(const std::string &group,
41 const std::string &key,
42 std::string *value) = 0;
43
44 // Associates |group|:|key| with a string |value|. Returns true on success,
45 // false otherwise.
46 virtual bool SetString(const std::string &group,
47 const std::string &key,
48 const std::string &value) = 0;
49
50 // Gets a boolean |value| associated with |group|:|key|. Returns true on
51 // success and false on failure (including when the |group|:|key| is not
52 // present in the store).
53 virtual bool GetBool(const std::string &group,
54 const std::string &key,
55 bool *value) = 0;
56
57 // Associates |group|:|key| with a boolean |value|. Returns true on success,
58 // false otherwise.
59 virtual bool SetBool(const std::string &group,
60 const std::string &key,
61 bool value) = 0;
62
63 // Gets a integer |value| associated with |group|:|key|. Returns true on
64 // success and false on failure (including when the |group|:|key| is not
65 // present in the store).
66 virtual bool GetInt(const std::string &group,
67 const std::string &key,
68 int *value) = 0;
69
70 // Associates |group|:|key| with an integer |value|. Returns true on success,
71 // false otherwise.
72 virtual bool SetInt(const std::string &group,
73 const std::string &key,
74 int value) = 0;
Darin Petkov86964e02011-06-29 13:49:28 -070075
Darin Petkovb2841fd2011-06-30 12:54:12 -070076 // Gets a string list |value| associated with |group|:|key|. Returns true on
77 // success and false on failure (including when |group|:|key| is not present
78 // in the store).
79 virtual bool GetStringList(const std::string &group,
80 const std::string &key,
81 std::vector<std::string> *value) = 0;
82
83 // Associates |group|:|key| with a string list |value|. Returns true on
84 // success, false otherwise.
85 virtual bool SetStringList(const std::string &group,
86 const std::string &key,
87 const std::vector<std::string> &value) = 0;
88
Darin Petkov86964e02011-06-29 13:49:28 -070089 // Gets and decrypts string |value| associated with |group|:|key|. Returns
90 // true on success and false on failure (including when |group|:|key| is not
91 // present in the store).
92 virtual bool GetCryptedString(const std::string &group,
93 const std::string &key,
94 std::string *value) = 0;
95
96 // Associates |group|:|key| with a string |value| after encrypting it. Returns
97 // true on success, false otherwise.
98 virtual bool SetCryptedString(const std::string &group,
99 const std::string &key,
100 const std::string &value) = 0;
Darin Petkov083047b2011-06-23 20:42:48 -0700101};
102
103} // namespace shill
104
105#endif // SHILL_STORE_INTERFACE_