Vitaly Buka | 4615e0d | 2015-10-14 15:35:12 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Weave Authors. All rights reserved. |
Vitaly Buka | 17b0a8a | 2015-08-31 19:12:35 -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 | |
Johan Euphrosine | 3523fdd | 2015-10-14 20:46:05 -0700 | [diff] [blame] | 5 | #ifndef LIBWEAVE_EXAMPLES_PROVIDER_FILE_CONFIG_STORE_H_ |
| 6 | #define LIBWEAVE_EXAMPLES_PROVIDER_FILE_CONFIG_STORE_H_ |
Vitaly Buka | 17b0a8a | 2015-08-31 19:12:35 -0700 | [diff] [blame] | 7 | |
| 8 | #include <map> |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
Vitaly Buka | 1e36367 | 2015-09-25 14:01:16 -0700 | [diff] [blame] | 12 | #include <weave/provider/config_store.h> |
Vitaly Buka | ac18fcf | 2016-01-15 14:48:54 -0800 | [diff] [blame] | 13 | #include <weave/provider/task_runner.h> |
Vitaly Buka | 17b0a8a | 2015-08-31 19:12:35 -0700 | [diff] [blame] | 14 | |
| 15 | namespace weave { |
| 16 | namespace examples { |
| 17 | |
Vitaly Buka | 1e36367 | 2015-09-25 14:01:16 -0700 | [diff] [blame] | 18 | class FileConfigStore : public provider::ConfigStore { |
Vitaly Buka | 17b0a8a | 2015-08-31 19:12:35 -0700 | [diff] [blame] | 19 | public: |
Vitaly Buka | 919a8a9 | 2016-01-27 15:59:28 -0800 | [diff] [blame] | 20 | FileConfigStore(const std::string& model_id, |
Vitaly Buka | ac18fcf | 2016-01-15 14:48:54 -0800 | [diff] [blame] | 21 | provider::TaskRunner* task_runner); |
Vitaly Buka | 41a90d6 | 2015-09-29 16:58:39 -0700 | [diff] [blame] | 22 | |
Vitaly Buka | 17b0a8a | 2015-08-31 19:12:35 -0700 | [diff] [blame] | 23 | bool LoadDefaults(Settings* settings) override; |
Vitaly Buka | d1e6c4f | 2016-01-15 12:19:17 -0800 | [diff] [blame] | 24 | std::string LoadSettings(const std::string& name) override; |
| 25 | void SaveSettings(const std::string& name, |
Vitaly Buka | ac18fcf | 2016-01-15 14:48:54 -0800 | [diff] [blame] | 26 | const std::string& settings, |
| 27 | const DoneCallback& callback) override; |
Vitaly Buka | d1e6c4f | 2016-01-15 12:19:17 -0800 | [diff] [blame] | 28 | |
Vitaly Buka | 17b0a8a | 2015-08-31 19:12:35 -0700 | [diff] [blame] | 29 | std::string LoadSettings() override; |
Vitaly Buka | 41a90d6 | 2015-09-29 16:58:39 -0700 | [diff] [blame] | 30 | |
| 31 | private: |
Vitaly Buka | d1e6c4f | 2016-01-15 12:19:17 -0800 | [diff] [blame] | 32 | std::string GetPath(const std::string& name) const; |
Paul Westbrook | 15a832e | 2015-12-08 23:00:29 -0800 | [diff] [blame] | 33 | const std::string model_id_; |
Vitaly Buka | ac18fcf | 2016-01-15 14:48:54 -0800 | [diff] [blame] | 34 | provider::TaskRunner* task_runner_{nullptr}; |
Vitaly Buka | 17b0a8a | 2015-08-31 19:12:35 -0700 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | } // namespace examples |
| 38 | } // namespace weave |
| 39 | |
Johan Euphrosine | 3523fdd | 2015-10-14 20:46:05 -0700 | [diff] [blame] | 40 | #endif // LIBWEAVE_EXAMPLES_PROVIDER_FILE_CONFIG_STORE_H_ |