-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpublic_settings.hpp
83 lines (66 loc) · 1.83 KB
/
public_settings.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once
#include "settings/environment.hpp"
#include "filesystem/filesystem.hpp"
#include "json.hpp"
#include <unordered_map>
#include <string>
#include <mutex>
#include <optional>
class PublicSettings
{
public:
/**
* Loads them from $home/.minIDE/public_settings.json
*/
void load();
/**
* Saves them from $home/.minIDE/public_settings.json
*/
void save();
/**
* Swap for copy
*/
friend void swap(PublicSettings& lhs, PublicSettings& rhs);
/**
* ctor
*/
PublicSettings();
/**
* dtor
*/
~PublicSettings();
// copy and move
PublicSettings(PublicSettings const&);
PublicSettings(PublicSettings&&);
PublicSettings& operator=(PublicSettings);
PublicSettings& operator=(PublicSettings&&);
/**
* Get path to settings file
*/
sfs::path getFileName() const;
/**
* Get all saved environments
*/
std::unordered_map <std::string, SettingParts::Environment> environments() const;
/**
* Set (all) environments
*/
void setEnvironments(std::unordered_map <std::string, SettingParts::Environment> const& envs);
/**
* Get an environment by name and resolve inheritance.
*/
std::optional <std::unordered_map <std::string, std::string>> compileEnvironment(std::string const& name) const;
/**
* nlohnmann::json convertible
*/
friend void to_json(json& j, PublicSettings const& settings);
/**
* nlohnmann::json convertible
*/
friend void from_json(json const& j, PublicSettings& settings);
private:
mutable std::mutex memoSaver_;
mutable sfs::path homeMemo_;
private:
std::unordered_map <std::string, SettingParts::Environment> environments_;
};