| Darin Petkov | 4f0a07b | 2011-05-25 16:47:20 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 
| Darin Petkov | 3003059 | 2010-07-27 13:53:20 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be | 
|  | 3 | // found in the LICENSE file. | 
|  | 4 |  | 
| Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 5 | #ifndef UPDATE_ENGINE_PREFS_INTERFACE_H_ | 
|  | 6 | #define UPDATE_ENGINE_PREFS_INTERFACE_H_ | 
| Darin Petkov | 3003059 | 2010-07-27 13:53:20 -0700 | [diff] [blame] | 7 |  | 
| Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 8 | #include <stdint.h> | 
|  | 9 |  | 
| Darin Petkov | 3003059 | 2010-07-27 13:53:20 -0700 | [diff] [blame] | 10 | #include <string> | 
|  | 11 |  | 
|  | 12 | namespace chromeos_update_engine { | 
|  | 13 |  | 
|  | 14 | // The prefs interface allows access to a persistent preferences | 
|  | 15 | // store. The two reasons for providing this as an interface are | 
|  | 16 | // testing as well as easier switching to a new implementation in the | 
|  | 17 | // future, if necessary. | 
|  | 18 |  | 
|  | 19 | class PrefsInterface { | 
|  | 20 | public: | 
| Alex Deymo | 610277e | 2014-11-11 21:18:11 -0800 | [diff] [blame] | 21 | virtual ~PrefsInterface() {} | 
|  | 22 |  | 
| Darin Petkov | 3003059 | 2010-07-27 13:53:20 -0700 | [diff] [blame] | 23 | // Gets a string |value| associated with |key|. Returns true on | 
|  | 24 | // success, false on failure (including when the |key| is not | 
|  | 25 | // present in the store). | 
|  | 26 | virtual bool GetString(const std::string& key, std::string* value) = 0; | 
|  | 27 |  | 
|  | 28 | // Associates |key| with a string |value|. Returns true on success, | 
|  | 29 | // false otherwise. | 
|  | 30 | virtual bool SetString(const std::string& key, const std::string& value) = 0; | 
|  | 31 |  | 
| Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 32 | // Gets an int64_t |value| associated with |key|. Returns true on | 
| Darin Petkov | 3003059 | 2010-07-27 13:53:20 -0700 | [diff] [blame] | 33 | // success, false on failure (including when the |key| is not | 
|  | 34 | // present in the store). | 
|  | 35 | virtual bool GetInt64(const std::string& key, int64_t* value) = 0; | 
|  | 36 |  | 
| Ben Chan | 9abb763 | 2014-08-07 00:10:53 -0700 | [diff] [blame] | 37 | // Associates |key| with an int64_t |value|. Returns true on success, | 
| Darin Petkov | 3003059 | 2010-07-27 13:53:20 -0700 | [diff] [blame] | 38 | // false otherwise. | 
|  | 39 | virtual bool SetInt64(const std::string& key, const int64_t value) = 0; | 
| Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 40 |  | 
| Alex Deymo | efb7c4c | 2013-07-09 14:34:00 -0700 | [diff] [blame] | 41 | // Gets a boolean |value| associated with |key|. Returns true on | 
|  | 42 | // success, false on failure (including when the |key| is not | 
|  | 43 | // present in the store). | 
|  | 44 | virtual bool GetBoolean(const std::string& key, bool* value) = 0; | 
|  | 45 |  | 
|  | 46 | // Associates |key| with a boolean |value|. Returns true on success, | 
|  | 47 | // false otherwise. | 
|  | 48 | virtual bool SetBoolean(const std::string& key, const bool value) = 0; | 
|  | 49 |  | 
| Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 50 | // Returns true if the setting exists (i.e. a file with the given key | 
|  | 51 | // exists in the prefs directory) | 
|  | 52 | virtual bool Exists(const std::string& key) = 0; | 
|  | 53 |  | 
|  | 54 | // Returns true if successfully deleted the file corresponding to | 
|  | 55 | // this key. Calling with non-existent keys does nothing. | 
|  | 56 | virtual bool Delete(const std::string& key) = 0; | 
| Darin Petkov | 3003059 | 2010-07-27 13:53:20 -0700 | [diff] [blame] | 57 | }; | 
|  | 58 |  | 
|  | 59 | }  // namespace chromeos_update_engine | 
|  | 60 |  | 
| Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 61 | #endif  // UPDATE_ENGINE_PREFS_INTERFACE_H_ |