Debian Codegraph @

src/core/iprofilemanager.h

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #pragma once
5
6 #include "importable.h"
7 #include "iprofile.h"
8 #include <filesystem>
9 #include <functional>
10 #include <memory>
11 #include <optional>
12 #include <string>
13 #include <vector>
14
15 class ISysModel;
16
17 class IProfileManager
18 {
19 public:
20 /// Profile manager observers must implement this interface.
21 class Observer
22 {
23 public:
24 /// A new profile was added.
25 /// @param profileName name of the added profile
26 virtual void profileAdded(std::string const &profileName) = 0;
27
28 /// A profile was removed.
29 /// @param profileName name of the removed profile
30 virtual void profileRemoved(std::string const &profileName) = 0;
31
32 /// The settings of a profile changed.
33 /// @param profileName name of the profile that changed
34 virtual void profileChanged(std::string const &profileName) = 0;
35
36 /// The active state of a profile changed.
37 /// @param profileName name of the profile that changed
38 /// @param active new active state
39 virtual void profileActiveChanged(std::string const &profileName,
40 bool active) = 0;
41
42 /// A profile was saved.
43 /// @param profileName name of the saved profile
44 virtual void profileSaved(std::string const &profileName) = 0;
45
46 /// The info of a profile changed.
47 /// @param oldInfo old profile info
48 /// @param newInfo new profile info
49 virtual void profileInfoChanged(IProfile::Info const &oldInfo,
50 IProfile::Info const &newInfo) = 0;
51
52 virtual ~Observer() = default;
53 };
54
55 /// Adds a new profile manager observer.
56 /// @param observer new observer to be added
57 virtual void
58 addObserver(std::shared_ptr<IProfileManager::Observer> observer) = 0;
59
60 /// Removes a observer from the profile manager observers
61 /// @param observer observer to be removed
62 virtual void
63 removeObserver(std::shared_ptr<IProfileManager::Observer> const &observer) = 0;
64
65 /// Initialization method.
66 /// @param model system model to initialize from
67 virtual void init(ISysModel const &model) = 0;
68
69 /// Available profiles.
70 /// @return names of the available profiles
71 virtual std::vector<std::string> profiles() const = 0;
72
73 /// Request a profile from the avaiable profiles.
74 /// @param profileName name of the requested profile
75 /// @return the named profile when is available
76 virtual std::optional<std::reference_wrapper<IProfile const>>
77 profile(std::string const &profileName) const = 0;
78
79 /// Request the list of not saved profiles.
80 /// @return names of the unsaved profiles
81 virtual std::vector<std::string> unsavedProfiles() const = 0;
82
83 /// Checks whether a profile is not saved.
84 /// @param profileName profile name to be checked
85 /// @return true when the profile is unsaved
86 virtual bool unsaved(std::string const &profileName) const = 0;
87
88 /// Adds a new profile with the supplied info.
89 /// @param info info of the profile to be created
90 virtual void add(IProfile::Info const &info) = 0;
91
92 /// Adds a clone of a profile with the supplied info.
93 /// @param cloneInfo info of the resulting profile
94 /// @param baseProfileName name of the profile to be cloned
95 virtual void clone(IProfile::Info const &cloneInfo,
96 std::string const &baseProfileName) = 0;
97
98 /// Removes a profile.
99 /// @param profileName name of the profile to be removed
100 virtual void remove(std::string const &profileName) = 0;
101
102 /// Changes the active state of a profile.
103 /// @param profileName name of the profile to be changed
104 /// @param active new active state
105 virtual void activate(std::string const &profileName, bool active) = 0;
106
107 /// Reset a profile settings to its defaults values.
108 /// @param profileName name of the profile to be reseted
109 virtual void reset(std::string const &profileName) = 0;
110
111 /// Restore a profile from the last saved state.
112 /// @param profileName name of the profile to be restored
113 virtual void restore(std::string const &profileName) = 0;
114
115 /// Updates the info of a profile.
116 /// @param profileName name of the profile to be updated
117 /// @param newInfo profile's new info
118 virtual void update(std::string const &profileName,
119 IProfile::Info const &newInfo) = 0;
120
121 /// Updates a profile settings from a profile importer.
122 /// @param profileName name of the profile to be updated
123 /// @param importer profile importer
124 virtual void update(std::string const &profileName,
125 Importable::Importer &importer) = 0;
126
127 /// Loads a profile settings from a profile file.
128 /// @param profileName name of the profile to be loaded
129 /// @param path path to the profile file
130 /// @return true when the loading was successful
131 virtual bool loadFrom(std::string const &profileName,
132 std::filesystem::path const &path) = 0;
133
134 /// Saves a profile.
135 /// @param profileName name of the profile to be saved
136 virtual void save(std::string const &profileName) = 0;
137
138 /// Exports a profile to a profile file.
139 /// @param profileName name of the profile to be exported
140 /// @param path destination path of the exported profile file
141 /// @return true when the exporting was successful
142 virtual bool exportTo(std::string const &profileName,
143 std::filesystem::path const &path) = 0;
144
145 virtual ~IProfileManager() = default;
146 };