Debian Codegraph @

src/core/profilepart.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 "exportable.h"
7 #include "iprofilepart.h"
8 #include "iprofilepartprovider.h"
9 #include <functional>
10 #include <memory>
11 #include <optional>
12 #include <string>
13 #include <vector>
14
15 class ProfilePart : public IProfilePart
16 {
17 public:
18 ProfilePart() = default;
19 ProfilePart(ProfilePart const &) = delete;
20 ProfilePart &operator=(ProfilePart const &) = delete;
21
22 bool active() const final override;
23 void activate(bool active) final override;
24
25 std::unique_ptr<IProfilePart> clone() const final override;
26
27 void importWith(Importable::Importer &i) final override;
28 void exportWith(Exportable::Exporter &e) const final override;
29
30 class Factory
31 {
32 public:
33 Factory(IProfilePartProvider const &profilePartProvider) noexcept;
34
35 std::optional<std::reference_wrapper<Exportable::Exporter>>
36 factory(std::string const &componentID);
37
38 virtual void takeProfilePart(std::unique_ptr<IProfilePart> &&part) = 0;
39 virtual ~Factory() = default;
40
41 protected:
42 std::unique_ptr<IProfilePart> createPart(std::string const &componentID) const;
43
44 private:
45 IProfilePartProvider const &profilePartProvider_;
46 std::vector<std::unique_ptr<Exportable::Exporter>> factories_;
47 };
48
49 protected:
50 virtual void importProfilePart(IProfilePart::Importer &i) = 0;
51 virtual void exportProfilePart(IProfilePart::Exporter &e) const = 0;
52 virtual std::unique_ptr<IProfilePart> cloneProfilePart() const = 0;
53
54 private:
55 bool active_{true};
56 };