endpoints_services_addon.cpp
Go to the documentation of this file.
1 
11 #include "endpoints_parameters.h"
12 
14 
18 
19 using namespace OpcUa;
20 using namespace OpcUa::Server;
21 
22 
23 namespace
24 {
25 
26 class EndpointsAddon : public Common::Addon, public EndpointsRegistry
27 {
28 public:
29  virtual void Initialize(Common::AddonsManager & addons, const Common::AddonParameters & params) override
30  {
31  Logger = addons.GetLogger();
32  ApplyAddonParameters(params);
33 
35  InternalServer = addons.GetAddon<ServicesRegistry>(ServicesRegistryAddonId);
36  InternalServer->RegisterEndpointsServices(Endpoints);
37 
38  const std::vector<OpcUa::Server::ApplicationData> & data = OpcUa::ParseEndpointsParameters(params.Groups, Logger);
39 
40  for (const OpcUa::Server::ApplicationData & application : data)
41  {
42  Endpoints->AddApplications(std::vector<OpcUa::ApplicationDescription>(1, application.Application));
43  Endpoints->AddEndpoints(application.Endpoints);
44  }
45  }
46 
47  virtual void Stop() override
48  {
49  InternalServer->UnregisterEndpointsServices();
50  InternalServer.reset();
51  Endpoints.reset();
52  }
53 
54  virtual void AddEndpoints(const std::vector<EndpointDescription> & endpoints) override
55  {
56  Endpoints->AddEndpoints(endpoints);
57  }
58 
59  virtual void AddApplications(const std::vector<OpcUa::ApplicationDescription> & applications) override
60  {
61  Endpoints->AddApplications(applications);
62  }
63 
64 
65  virtual std::vector<ApplicationDescription> FindServers(const FindServersParameters & params) const override
66  {
67  return Endpoints->FindServers(params);
68  }
69 
70  virtual std::vector<EndpointDescription> GetEndpoints(const GetEndpointsParameters & filter) const override
71  {
72  return Endpoints->GetEndpoints(filter);
73  }
74 
75  virtual void RegisterServer(const ServerParameters & parameters) override
76  {
77  Endpoints->RegisterServer(parameters);
78  }
79 
80 private:
81  void ApplyAddonParameters(const Common::AddonParameters & addons)
82  {
83  /*
84  for (const Common::Parameter parameter : addons.Parameters)
85  {
86  if (parameter.Name == "debug" && !parameter.Value.empty() && parameter.Value != "0")
87  {
88  Debug = true;
89  }
90  }
91  */
92  }
93 
94 private:
95  EndpointsRegistry::SharedPtr Endpoints;
96  ServicesRegistry::SharedPtr InternalServer;
97  Common::Logger::SharedPtr Logger;
98 };
99 
100 } // namespace
101 
102 
103 namespace OpcUa
104 {
105 namespace Server
106 {
108 {
109  return Common::Addon::UniquePtr(new ::EndpointsAddon());
110 }
111 }
112 }
113 
virtual const Logger::SharedPtr & GetLogger() const
Definition: addon_manager.h:90
virtual Common::Addon::UniquePtr CreateAddon() override
Create instance of addon.
virtual std::shared_ptr< Addon > GetAddon(const AddonId &id) const =0
getting addon by id
const char ServicesRegistryAddonId[]
EndpointsRegistry::UniquePtr CreateEndpointsRegistry()
OPC UA Address space part. GNU LGPL.
std::vector< Server::ApplicationData > ParseEndpointsParameters(const std::vector< Common::ParametersGroup > &rootGroup, const Common::Logger::SharedPtr &logger)
std::vector< ParametersGroup > Groups
virtual void RegisterEndpointsServices(OpcUa::EndpointServices::SharedPtr endpoints)=0
const char Server[]
Definition: strings.h:121


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