blob: 20dea47833394ddc493d43149dc0eab3aea09d31 [file] [log] [blame]
Vitaly Buka1175a9b2015-08-15 10:42:17 -07001// 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 Bukabecd4612015-08-16 23:31:55 -07008#include <map>
Vitaly Buka1175a9b2015-08-15 10:42:17 -07009#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 Vakulenkoe32375b2015-09-28 08:55:40 -070016#include <weave/provider/config_store.h>
Vitaly Buka1175a9b2015-08-15 10:42:17 -070017
18namespace buffet {
19
20class StorageInterface;
21
22// Handles reading buffet config and state files.
Alex Vakulenkoe32375b2015-09-28 08:55:40 -070023class BuffetConfig final : public weave::provider::ConfigStore {
Vitaly Buka1175a9b2015-08-15 10:42:17 -070024 public:
Alex Vakulenko0022b752015-10-02 11:09:59 -070025 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 Buka1175a9b2015-08-15 10:42:17 -070036 ~BuffetConfig() override = default;
37
Alex Vakulenko0022b752015-10-02 11:09:59 -070038 explicit BuffetConfig(const Options& options);
Vitaly Buka1175a9b2015-08-15 10:42:17 -070039
40 // Config overrides.
41 bool LoadDefaults(weave::Settings* settings) override;
42 std::string LoadSettings() override;
43 void SaveSettings(const std::string& settings) override;
Vitaly Bukabecd4612015-08-16 23:31:55 -070044 std::map<std::string, std::string> LoadCommandDefs() override;
Vitaly Bukabecd4612015-08-16 23:31:55 -070045 std::map<std::string, std::string> LoadStateDefs() override;
46 std::vector<std::string> LoadStateDefaults() override;
Vitaly Buka1175a9b2015-08-15 10:42:17 -070047
Vitaly Buka1175a9b2015-08-15 10:42:17 -070048 bool LoadDefaults(const chromeos::KeyValueStore& store,
49 weave::Settings* settings);
50
51 private:
Alex Vakulenko0022b752015-10-02 11:09:59 -070052 Options options_;
Vitaly Buka1175a9b2015-08-15 10:42:17 -070053
54 DISALLOW_COPY_AND_ASSIGN(BuffetConfig);
55};
56
57} // namespace buffet
58
59#endif // BUFFET_BUFFET_CONFIG_H_