xml_address_space_addon.cpp
Go to the documentation of this file.
1 
12 
14 #include <sstream>
15 #include <iostream>
16 #include <stdexcept>
17 
18 namespace OpcUa
19 {
20 namespace Internal
21 {
22 
24 {
26 
27  if (!Registry)
28  {
29  std::stringstream stream;
30  stream << "Unable to find addon '" << Server::AddressSpaceRegistryAddonId << "'. " << std::endl;
31  throw std::logic_error(stream.str());
32  }
33 
34  for (const Common::Parameter & param : params.Parameters)
35  {
36  if (param.Name == "file_name")
37  {
38  try
39  {
40  Load(param.Value.c_str(), *Registry);
41  }
42 
43  catch (const std::exception & err)
44  {
45  std::cerr << "Unable to load address space from the file '" << param.Value << "'. " << err.what() << std::endl;
46  }
47  }
48  }
49 }
50 
52 {
53  Registry.reset();
54 }
55 
56 void XmlAddressSpaceAddon::Load(const char * path)
57 {
58  Load(path, *Registry);
59 }
60 
62 {
63  if (!Registry)
64  {
65  std::stringstream stream;
66  stream << "Unable to find addon '" << Server::AddressSpaceRegistryAddonId << "'. " << std::endl;
67  throw std::logic_error(stream.str());
68  }
69 
71  xml.Load(file);
72 }
73 
74 } // namespace Internal
75 } // namespace OpcUa
virtual void Initialize(Common::AddonsManager &addons, const Common::AddonParameters &params)
initialize addon.
bool param(const std::string &param_name, T &param_val, const T &default_val)
virtual std::shared_ptr< Addon > GetAddon(const AddonId &id) const =0
getting addon by id
NodeManagementServices::SharedPtr Registry
const char AddressSpaceRegistryAddonId[]
registry_t< std::mutex > registry
Definition: registry.h:211
OPC UA Address space part. GNU LGPL.
virtual void Stop()
Stopping addon work. After calling this method addon should throw exception on any calls...
std::vector< Parameter > Parameters


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:12:08