HardwareConfig.cpp
Go to the documentation of this file.
1#include "HardwareConfig.h"
2
4{
8
11 {
12 auto it = deviceConfigs.find(name);
13 if (it == deviceConfigs.end())
14 {
15 throw ConfigElementNotFoundError("Device with Name: " + name);
16 }
17 return *it->second;
18 }
19
20 void
22 {
23 for (auto& i : deviceConfigs)
24 {
25 i.second->onParsingFinished();
26 }
27 }
28
29 void
30 HardwareConfig::addDeviceConfig(const std::string name, std::shared_ptr<DeviceConfig> config)
31 {
32 if (deviceConfigs.find(name) != deviceConfigs.end())
33 {
34 throw ConfigElementNotFoundError("Parser error: Device with name " + name +
35 " is defined multiple times");
36 }
37 deviceConfigs[name] = config;
38 }
39
40 bool
41 HardwareConfig::checkAllItemsRead(std::vector<std::string>& errors) const
42 {
43 bool succ = true;
44 for (auto& dev : deviceConfigs)
45 {
46 succ &= dev.second->checkAllItemsRead(errors);
47 }
48 return succ;
49 }
50} // namespace armarx::control::hardware_config
The ConfigElementNotFoundError class represents an error that is thrown when trying to get a config v...
Definition Errors.h:25
void addDeviceConfig(const std::string name, std::shared_ptr< DeviceConfig > config)
Add a DeviceConfig.
void onParsingFinished()
This method is called when the config is completely read form the HardwareConfig file.
bool checkAllItemsRead(std::vector< std::string > &errors) const
This method is called when the config is completely read form the HardwareConfig file.
DeviceConfig & getDeviceConfig(std::string name)
std::map< std::string, std::shared_ptr< DeviceConfig > > deviceConfigs