SlaveConfig.cpp
Go to the documentation of this file.
1#include "SlaveConfig.h"
2
4{
5
7 std::optional<std::string> type,
8 std::optional<std::string> name) :
9 identifier(identifier), type(type), name(name)
10 {
11 }
12
14 std::optional<std::string> type,
15 std::optional<std::string> name,
16 std::shared_ptr<SlaveProfile> profile) :
17 identifier(identifier), type(type), name(name)
18 {
19 this->items = profile->items;
20 }
21
24 {
25 identifierRead = true;
26 return identifier;
27 }
28
29 std::optional<std::string>
31 {
32 return type;
33 }
34
35 std::optional<std::string>
37 {
38 return name;
39 }
40
41 bool
42 SlaveConfig::checkAllItemsRead(std::vector<std::string>& errors) const
43 {
44 bool succ = true;
45
46 if (!identifierRead)
47 {
48 succ = false;
49 std::stringstream s;
50 s << "Identifier of slave not read. ";
51 s << "Identifier details: " << identifier;
52 errors.push_back(s.str());
53 }
54 succ &= Config::checkAllItemsRead(errors);
55 return succ;
56 }
57
58 void
59 SlaveConfig::print(std::stringstream& s, int indention) const
60 {
61 for (int i = 0; i < indention; i++)
62 {
63 s << "\t";
64 }
65 s << "Slave:" << std::endl;
66 for (int i = 0; i < indention + 1; i++)
67 {
68 s << "\t";
69 }
70 s << "Type: " << getType().value_or("<no type>") << std::endl;
71 for (int i = 0; i < indention + 1; i++)
72 {
73 s << "\t";
74 }
75 s << "Name: " << getName().value_or("<no name>") << std::endl;
76 for (int i = 0; i < indention + 1; i++)
77 {
78 s << "\t";
79 }
80 s << "Identifier: " << identifier << std::endl;
81
82 for (int i = 0; i < indention + 1; i++)
83 {
84 s << "\t";
85 }
86 s << "Config:" << std::endl;
87 Config::print(s, indention + 2);
88 }
89
90 void
92 {
93 identifierRead = false;
94 }
95
96 std::string
98 {
99 return name;
100 }
101
102 std::string
104 {
105 return type;
106 }
107
110 {
111 return identifier;
112 }
113
114} // namespace armarx::control::hardware_config
virtual void print(std::stringstream &s, int indention) const
Print this configuration.
Definition Config.cpp:121
virtual bool checkAllItemsRead(std::vector< std::string > &errors) const
This method is called once the device has read the configuration data it needs.
Definition Config.cpp:76
std::map< std::string, ConfigItemWithMetadata > items
Definition Config.h:252
std::optional< std::string > getType() const
bool checkAllItemsRead(std::vector< std::string > &errors) const override
This method is called once the device has read the configuration data it needs.
void onParsingFinished() override
This method is called when the config is completely read form the HardwareConfig file.
void print(std::stringstream &s, int indention) const override
Print this configuration.
SlaveConfig(SlaveIdentifierConfig identifier, std::optional< std::string > type, std::optional< std::string > name)
std::optional< std::string > getName() const
Data structure holding the information necessary to create a SlaveIdentifier.