Debian Codegraph @

Server/Web/WebClientStatic.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 <deque>
24 #include <map>
25 #include <string>
26 #include <vector>
27
28 #include "Server/Web/HtmlTag.h"
29 #include "Server/Web/HtmlTagInputHidden.h"
30 #include "Server/Web/HtmlTagSelectWithLabel.h"
31
32 namespace Server { namespace Web
33 {
34 class WebClientStatic
35 {
36 public:
37 WebClientStatic() = delete;
38 WebClientStatic(const WebClientStatic&) = delete;
39 WebClientStatic& operator=(const WebClientStatic&) = delete;
40
41 static HtmlTag HtmlTagSelectExecuteAccessory(const bool executeAccessory = true);
42
43 static HtmlTag HtmlTagSelectSelectRouteApproach(const DataModel::SelectRouteApproach selectRouteApproach,
44 const bool addDefault = true);
45
46 static HtmlTag HtmlTagControlArgument(const unsigned char argNr, const ArgumentType type, const std::string& value);
47
48 template<class T>
49 static HtmlTag HtmlTagMatchKey(const std::map<std::string,T>& matchKeyMap,
50 const std::string& selectedMatchKey)
51 {
52 if (matchKeyMap.size() == 0)
53 {
54 return HtmlTagInputHidden("matchkey", "");
55 }
56
57 std::map<std::string,std::string> options;
58 for (auto& matchKey : matchKeyMap)
59 {
60 const std::string& name = matchKey.second.GetName();
61 const std::string& key = matchKey.second.GetMatchKey();
62 options[key] = name + (name != key ? (" (" + key + ")") : "");
63 }
64 return HtmlTagSelectWithLabel("matchkey", Languages::TextNameInControl, options, selectedMatchKey);
65 }
66
67
68 static HtmlTag HtmlTagProtocol(const std::map<std::string,Protocol>& protocolMap,
69 const Protocol selectedProtocol);
70
71 static HtmlTag HtmlTagAccessoryAddress(const DataModel::AccessoryType type,
72 const Address address,
73 const AddressPort port);
74
75 static inline HtmlTag HtmlTagDuration(const DataModel::AccessoryPulseDuration duration)
76 {
77 return HtmlTagDuration(duration, Languages::TextDuration);
78 }
79
80 static HtmlTag HtmlTagDuration(const DataModel::AccessoryPulseDuration duration,
81 const Languages::TextSelector label);
82
83 static HtmlTag HtmlTagRotation(const DataModel::LayoutItem::LayoutRotation rotation);
84
85 static HtmlTag HtmlTagNrOfTracksToReserve(const DataModel::Loco::NrOfTracksToReserve nrOfTracksToReserve);
86 static HtmlTag HtmlTagLogLevel();
87 static HtmlTag HtmlTagLanguage();
88 static HtmlTag HtmlTagStartupLocos(const StartupInitLocos startupInitLocos);
89 static HtmlTag HtmlTagControlArguments(const HardwareType hardwareType, const std::string& arg1 = "", const std::string& arg2 = "", const std::string& arg3 = "", const std::string& arg4 = "", const std::string& arg5 = "");
90 static HtmlTag HtmlTagControl(const std::map<ControlID,std::string>& controls, ControlID& controlId, const std::string& objectType, const ObjectID objectID);
91 static HtmlTag HtmlTagControl(const std::string& name, const std::map<ControlID,std::string>& controls);
92
93 static HtmlTag HtmlTagSlaveEntry(const std::string& prefix,
94 const std::string& priority,
95 const ObjectID objectId,
96 const std::map<std::string,ObjectID>& options);
97
98 static std::map<std::string,ObjectID> GetLocoSlaveOptions(const LocoID locoID = LocoNone);
99
100 static const std::map<std::string,HardwareType> ListHardwareNames();
101
102 static std::vector<ObjectID> InterpretSlaveData(const std::string& prefix, const std::map<std::string,std::string>& arguments);
103
104 static HtmlTag HtmlTagTabMenuItem(const std::string& tabName,
105 const Languages::TextSelector buttonValue,
106 const bool selected = false,
107 const bool hidden = false);
108
109 static HtmlTag HtmlTagSelectPropulsion(const Propulsion propulsion);
110 static HtmlTag HtmlTagSelectTrainType(const TrainType trainType);
111 static HtmlTag HtmlTagTabFunctions(const DataModel::LocoFunctionEntry* locoFunctions);
112 static HtmlTag HtmlTagTabAutomode(const bool pushpull,
113 const Speed maxSpeed,
114 const Speed travelSpeed,
115 const Speed reducedSpeed,
116 const Speed creepingSpeed);
117
118 static inline DataModel::ObjectIdentifier LocoIdToObjectIdentifier(const LocoID locoID)
119 {
120 const MultipleUnitID multipleUnitID = locoID & (~MultipleUnitIdPrefix);
121 if (locoID == multipleUnitID)
122 {
123 return DataModel::ObjectIdentifier(ObjectTypeLoco, locoID);
124 }
125 return DataModel::ObjectIdentifier(ObjectTypeMultipleUnit, multipleUnitID);
126 }
127
128 static std::vector<DataModel::Relation*> ConvertSlaveIDVectorToRelation(Manager& manager,
129 const MultipleUnitID multipleUnitID,
130 const std::vector<LocoID>& slaveIDs);
131 };
132
133 }} // namespace Server::Web
134