DeviceConfig.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 
8 
10 {
11  class DeviceConfig;
12 
13  /**
14  * @brief A base class that does not have Subdevices or Slaves but can be used for Subdevices
15  * or DeviceProfiles
16  */
17  class DeviceConfigBase : public Config, public ControllerConfig
18  {
19  friend class ConfigParser;
20  friend class DeviceConfig;
21 
22  public:
23  DeviceConfigBase(std::string type, std::string name);
24 
25  DeviceConfigBase(std::string type,
26  std::string name,
27  std::shared_ptr<DeviceConfigBase> profile);
28 
29  ~DeviceConfigBase() = default;
30 
31  std::string getType() const;
32 
33  std::string getName() const;
34 
35  void print(std::stringstream& s, int indention) const override;
36 
37  private:
38  std::string type;
39  std::string name;
40  };
41 
43  {
44  friend class ConfigParser;
45 
46  public:
47  DeviceConfig(std::string type, std::string name);
48 
49  DeviceConfig(std::string type, std::string name, std::shared_ptr<DeviceConfigBase> profile);
50 
51  ~DeviceConfig() = default;
52 
53  SlaveConfig& getSlaveConfig(const std::uint32_t vendorID,
54  const std::uint32_t productCode,
55  const std::uint32_t serialNumber);
56 
57  SlaveConfig& getSlaveConfig(const std::string type, const std::string name = "");
58 
60 
61  DeviceConfigBase& getSubdeviceConfig(const std::string& subDeviceName);
62 
63  std::list<std::reference_wrapper<DeviceConfigBase>>
64  getSubDeviceConfigsWithType(const std::string subDeviceType);
65 
66  bool checkAllItemsRead(std::vector<std::string>& errors) const override;
67 
68  void print(std::stringstream& s, int indention) const override;
69 
70  void onParsingFinished() override;
71 
72  private:
73  void addSlaveConfig(std::shared_ptr<SlaveConfig> slaveConfig);
74 
75  void addSubDeviceConfig(const std::string name,
76  std::shared_ptr<DeviceConfigBase> subDeviceConfig);
77 
78  std::list<std::shared_ptr<SlaveConfig>> slaveConfigs;
79  std::map<std::string, std::shared_ptr<DeviceConfigBase>> subDeviceConfigs;
80  };
81 } // namespace armarx::control::hardware_config
armarx::control::hardware_config::DeviceConfig::checkAllItemsRead
bool checkAllItemsRead(std::vector< std::string > &errors) const override
This method is called once the device has read the configuration data it needs.
Definition: DeviceConfig.cpp:114
armarx::control::hardware_config::DeviceConfig::onParsingFinished
void onParsingFinished() override
This method is called when the config is completely read form the HardwareConfig file.
Definition: DeviceConfig.cpp:184
SlaveConfig.h
armarx::control::hardware_config::DeviceConfig::~DeviceConfig
~DeviceConfig()=default
armarx::control::hardware_config::DeviceConfigBase::~DeviceConfigBase
~DeviceConfigBase()=default
armarx::control::hardware_config::DeviceConfigBase::DeviceConfig
friend class DeviceConfig
Definition: DeviceConfig.h:20
armarx::control::hardware_config
Definition: Config.cpp:3
armarx::control::hardware_config::DeviceConfigBase::DeviceConfigBase
DeviceConfigBase(std::string type, std::string name)
Definition: DeviceConfig.cpp:16
armarx::control::hardware_config::DeviceConfig::getSubDeviceConfigsWithType
std::list< std::reference_wrapper< DeviceConfigBase > > getSubDeviceConfigsWithType(const std::string subDeviceType)
Definition: DeviceConfig.cpp:87
armarx::control::hardware_config::DeviceConfig::print
void print(std::stringstream &s, int indention) const override
Print this configuration.
Definition: DeviceConfig.cpp:134
armarx::control::hardware_config::ConfigParser
Definition: ConfigParser.h:19
armarx::control::hardware_config::DeviceConfigBase::getName
std::string getName() const
Definition: DeviceConfig.cpp:108
armarx::control::hardware_config::DeviceConfigBase
A base class that does not have Subdevices or Slaves but can be used for Subdevices or DeviceProfiles...
Definition: DeviceConfig.h:17
armarx::control::hardware_config::DeviceConfig
Definition: DeviceConfig.h:42
armarx::control::hardware_config::DeviceConfigBase::getType
std::string getType() const
Definition: DeviceConfig.cpp:102
armarx::control::hardware_config::DeviceConfig::getOnlySlaveConfig
SlaveConfig & getOnlySlaveConfig()
Definition: DeviceConfig.cpp:65
SlaveIdentifierConfig.h
Config.h
armarx::control::hardware_config::DeviceConfig::getSlaveConfig
SlaveConfig & getSlaveConfig(const std::uint32_t vendorID, const std::uint32_t productCode, const std::uint32_t serialNumber)
Definition: DeviceConfig.cpp:29
armarx::control::hardware_config::DeviceConfigBase::print
void print(std::stringstream &s, int indention) const override
Print this configuration.
Definition: DeviceConfig.cpp:202
armarx::control::hardware_config::Config
The Config class is the base class of all specialized configurations that have a direct key -> value ...
Definition: Config.h:91
armarx::control::hardware_config::SlaveConfig
Definition: SlaveConfig.h:27
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::control::hardware_config::DeviceConfig::getSubdeviceConfig
DeviceConfigBase & getSubdeviceConfig(const std::string &subDeviceName)
Definition: DeviceConfig.cpp:76
armarx::control::hardware_config::ControllerConfig
Config with additional Config objects for controllers.
Definition: Config.h:349