Debian Codegraph @

src/core/components/controls/controlmode.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 "core/components/controls/control.h"
7 #include <memory>
8 #include <string>
9 #include <string_view>
10 #include <vector>
11
12 /// A control that aggregates other controls,
13 /// having only one of them active at the same time.
14 class ControlMode : public Control
15 {
16 public:
17 class Importer : public IControl::Importer
18 {
19 public:
20 virtual std::string const &provideMode() const = 0;
21 };
22
23 class Exporter : public IControl::Exporter
24 {
25 public:
26 virtual void takeMode(std::string const &mode) = 0;
27 virtual void takeModes(std::vector<std::string> const &modes) = 0;
28 };
29
30 ControlMode(std::string_view id,
31 std::vector<std::unique_ptr<IControl>> &&controls,
32 bool active) noexcept;
33
34 void preInit(ICommandQueue &ctlCmds) final override;
35 void postInit(ICommandQueue &ctlCmds) final override;
36 void init() final override;
37 std::string const &ID() const final override;
38
39 protected:
40 void importControl(IControl::Importer &i) final override;
41 void exportControl(IControl::Exporter &e) const final override;
42
43 void cleanControl(ICommandQueue &ctlCmds) final override;
44 void syncControl(ICommandQueue &ctlCmds) final override;
45
46 std::string const &mode() const;
47 void mode(std::string const &mode);
48
49 private:
50 std::string const id_;
51 std::vector<std::unique_ptr<IControl>> const controls_;
52 std::string mode_;
53 };