Debian Codegraph @

DataModel/FeedbackConfig.h

raw symbols SCIP
1 /*
2 RailControl - Model Railway Control Software
3
4 Copyright (c) 2017-2025 by Teddy / Dominik Mahrer - www.railcontrol.org
5
6 RailControl is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
10
11 RailControl is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with RailControl; see the file LICENCE. If not see
18 <http://www.gnu.org/licenses/>.
19 */
20
21 #pragma once
22
23 #include <string>
24
25 #include "DataModel/Feedback.h"
26 #include "Hardware/FeedbackCache.h"
27
28 namespace DataModel
29 {
30 class FeedbackConfig
31 {
32 public:
33 inline FeedbackConfig()
34 : controlId(ControlNone),
35 feedbackId(FeedbackNone),
36 pin(FeedbackPinNone),
37 isInUse(false)
38 {
39 }
40
41 inline FeedbackConfig(const DataModel::Feedback& feedback)
42 : controlId(feedback.GetControlID()),
43 feedbackId(feedback.GetID()),
44 pin(feedback.GetPin()),
45 name(feedback.GetName()),
46 matchKey(feedback.GetMatchKey()),
47 isInUse(feedback.IsInUse())
48 {
49 }
50
51 inline FeedbackConfig(const Hardware::FeedbackCacheEntry& feedback)
52 : controlId(feedback.GetControlID()),
53 feedbackId(feedback.GetFeedbackID()),
54 pin(feedback.GetPin()),
55 name(feedback.GetName()),
56 matchKey(feedback.GetMatchKey()),
57 isInUse(false)
58 {
59 }
60
61 inline FeedbackConfig& operator=(const DataModel::Feedback& feedback)
62 {
63 controlId = feedback.GetControlID();
64 feedbackId = feedback.GetID();
65 pin = feedback.GetPin();
66 name = feedback.GetName();
67 matchKey = feedback.GetMatchKey();
68 isInUse = feedback.IsInUse();
69 return *this;
70 }
71
72 inline FeedbackConfig& operator=(const Hardware::FeedbackCacheEntry& feedback)
73 {
74 controlId = feedback.GetControlID();
75 feedbackId = feedback.GetFeedbackID();
76 pin = feedback.GetPin();
77 name = feedback.GetName();
78 matchKey = feedback.GetMatchKey();
79 return *this;
80 }
81
82 inline ControlID GetControlId() const
83 {
84 return controlId;
85 }
86
87 inline FeedbackID GetFeedbackId() const
88 {
89 return feedbackId;
90 }
91
92 inline FeedbackPin GetPin() const
93 {
94 return pin;
95 }
96
97 inline std::string GetName() const
98 {
99 return name;
100 }
101
102 inline void SetName(const std::string& name)
103 {
104 this->name = name;
105 }
106
107 inline std::string GetMatchKey() const
108 {
109 return matchKey;
110 }
111
112 inline bool IsInUse() const
113 {
114 return isInUse;
115 }
116
117 private:
118 ControlID controlId;
119 FeedbackID feedbackId;
120 FeedbackPin pin;
121 std::string name;
122 std::string matchKey;
123 bool isInUse;
124 };
125 } // namespace DataModel