HardwareConfig.cpp
Go to the documentation of this file.
1 #include "HardwareConfig.h"
2 
4 {
6  {
7  }
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
armarx::control::hardware_config::HardwareConfig::onParsingFinished
void onParsingFinished()
This method is called when the config is completely read form the HardwareConfig file.
Definition: HardwareConfig.cpp:21
armarx::control::hardware_config::ConfigElementNotFoundError
The ConfigElementNotFoundError class represents an error that is thrown when trying to get a config v...
Definition: Errors.h:24
armarx::control::hardware_config::HardwareConfig::HardwareConfig
HardwareConfig()
Definition: HardwareConfig.cpp:5
armarx::control::hardware_config
Definition: Config.cpp:3
armarx::control::hardware_config::HardwareConfig::addDeviceConfig
void addDeviceConfig(const std::string name, std::shared_ptr< DeviceConfig > config)
Add a DeviceConfig.
Definition: HardwareConfig.cpp:30
armarx::control::hardware_config::HardwareConfig::checkAllItemsRead
bool checkAllItemsRead(std::vector< std::string > &errors) const
This method is called when the config is completely read form the HardwareConfig file.
Definition: HardwareConfig.cpp:41
armarx::control::hardware_config::DeviceConfig
Definition: DeviceConfig.h:42
HardwareConfig.h
armarx::control::hardware_config::HardwareConfig::deviceConfigs
std::map< std::string, std::shared_ptr< DeviceConfig > > deviceConfigs
Definition: HardwareConfig.h:59
armarx::control::hardware_config::HardwareConfig::getDeviceConfig
DeviceConfig & getDeviceConfig(std::string name)
Definition: HardwareConfig.cpp:10