Debian Codegraph @

src/core/components/controls/amd/pm/fixed/pmfixed.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include "pmfixed.h"
5
6 #include <algorithm>
7
8 AMD::PMFixed::PMFixed(std::string_view mode) noexcept
9 : Control(false)
10 , id_(AMD::PMFixed::ItemID)
11 , mode_(mode)
12 {
13 }
14
15 void AMD::PMFixed::preInit(ICommandQueue &)
16 {
17 }
18
19 void AMD::PMFixed::postInit(ICommandQueue &)
20 {
21 }
22
23 void AMD::PMFixed::init()
24 {
25 }
26
27 std::string const &AMD::PMFixed::ID() const
28 {
29 return id_;
30 }
31
32 void AMD::PMFixed::importControl(IControl::Importer &i)
33 {
34 auto &pmFixedImporter = dynamic_cast<AMD::PMFixed::Importer &>(i);
35 mode(pmFixedImporter.providePMFixedMode());
36 }
37
38 void AMD::PMFixed::exportControl(IControl::Exporter &e) const
39 {
40 auto &pmFixedExporter = dynamic_cast<AMD::PMFixed::Exporter &>(e);
41 pmFixedExporter.takePMFixedModes(modes());
42 pmFixedExporter.takePMFixedMode(mode());
43 }
44
45 std::string const &AMD::PMFixed::mode() const
46 {
47 return mode_;
48 }
49
50 void AMD::PMFixed::mode(std::string const &mode)
51 {
52 // only assign known modes
53 auto iter = std::find_if(
54 modes().cbegin(), modes().cend(),
55 [&](auto const &availableMode) { return mode == availableMode; });
56 if (iter != modes().cend())
57 mode_ = mode;
58 }