Vitaly Buka | 1175a9b | 2015-08-15 10:42:17 -0700 | [diff] [blame] | 1 | // Copyright 2015 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 BUFFET_BUFFET_CONFIG_H_ |
| 6 | #define BUFFET_BUFFET_CONFIG_H_ |
| 7 | |
Vitaly Buka | becd461 | 2015-08-16 23:31:55 -0700 | [diff] [blame] | 8 | #include <map> |
Vitaly Buka | 1175a9b | 2015-08-15 10:42:17 -0700 | [diff] [blame] | 9 | #include <set> |
| 10 | #include <string> |
| 11 | #include <vector> |
| 12 | |
| 13 | #include <base/callback.h> |
| 14 | #include <base/files/file_path.h> |
| 15 | #include <chromeos/key_value_store.h> |
Alex Vakulenko | e32375b | 2015-09-28 08:55:40 -0700 | [diff] [blame] | 16 | #include <weave/provider/config_store.h> |
Vitaly Buka | 1175a9b | 2015-08-15 10:42:17 -0700 | [diff] [blame] | 17 | |
| 18 | namespace buffet { |
| 19 | |
| 20 | class StorageInterface; |
| 21 | |
| 22 | // Handles reading buffet config and state files. |
Alex Vakulenko | e32375b | 2015-09-28 08:55:40 -0700 | [diff] [blame] | 23 | class BuffetConfig final : public weave::provider::ConfigStore { |
Vitaly Buka | 1175a9b | 2015-08-15 10:42:17 -0700 | [diff] [blame] | 24 | public: |
Alex Vakulenko | 0022b75 | 2015-10-02 11:09:59 -0700 | [diff] [blame^] | 25 | struct Options { |
| 26 | base::FilePath defaults; |
| 27 | base::FilePath settings; |
| 28 | |
| 29 | base::FilePath definitions; |
| 30 | base::FilePath test_definitions; |
| 31 | |
| 32 | bool disable_security{false}; |
| 33 | std::string test_privet_ssid; |
| 34 | }; |
| 35 | |
Vitaly Buka | 1175a9b | 2015-08-15 10:42:17 -0700 | [diff] [blame] | 36 | ~BuffetConfig() override = default; |
| 37 | |
Alex Vakulenko | 0022b75 | 2015-10-02 11:09:59 -0700 | [diff] [blame^] | 38 | explicit BuffetConfig(const Options& options); |
Vitaly Buka | 1175a9b | 2015-08-15 10:42:17 -0700 | [diff] [blame] | 39 | |
| 40 | // Config overrides. |
| 41 | bool LoadDefaults(weave::Settings* settings) override; |
| 42 | std::string LoadSettings() override; |
| 43 | void SaveSettings(const std::string& settings) override; |
Vitaly Buka | becd461 | 2015-08-16 23:31:55 -0700 | [diff] [blame] | 44 | std::map<std::string, std::string> LoadCommandDefs() override; |
Vitaly Buka | becd461 | 2015-08-16 23:31:55 -0700 | [diff] [blame] | 45 | std::map<std::string, std::string> LoadStateDefs() override; |
| 46 | std::vector<std::string> LoadStateDefaults() override; |
Vitaly Buka | 1175a9b | 2015-08-15 10:42:17 -0700 | [diff] [blame] | 47 | |
Vitaly Buka | 1175a9b | 2015-08-15 10:42:17 -0700 | [diff] [blame] | 48 | bool LoadDefaults(const chromeos::KeyValueStore& store, |
| 49 | weave::Settings* settings); |
| 50 | |
| 51 | private: |
Alex Vakulenko | 0022b75 | 2015-10-02 11:09:59 -0700 | [diff] [blame^] | 52 | Options options_; |
Vitaly Buka | 1175a9b | 2015-08-15 10:42:17 -0700 | [diff] [blame] | 53 | |
| 54 | DISALLOW_COPY_AND_ASSIGN(BuffetConfig); |
| 55 | }; |
| 56 | |
| 57 | } // namespace buffet |
| 58 | |
| 59 | #endif // BUFFET_BUFFET_CONFIG_H_ |