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 
21  void
23  {
24  for (auto& i : deviceConfigs)
25  {
26  i.second->onParsingFinished();
27  }
28  }
29 
30  void
31  HardwareConfig::addDeviceConfig(const std::string name, std::shared_ptr<DeviceConfig> config)
32  {
33  if (deviceConfigs.find(name) != deviceConfigs.end())
34  {
35  throw ConfigElementNotFoundError("Parser error: Device with name " + name +
36  " is defined multiple times");
37  }
38  deviceConfigs[name] = config;
39  }
40 
41  bool
42  HardwareConfig::checkAllItemsRead(std::vector<std::string>& errors) const
43  {
44  bool succ = true;
45  for (auto& dev : deviceConfigs)
46  {
47  succ &= dev.second->checkAllItemsRead(errors);
48  }
49  return succ;
50  }
51 } // 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:22
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:31
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:42
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