services_registry_impl.cpp
Go to the documentation of this file.
1 
12 
14 
15 namespace
16 {
17 using namespace OpcUa;
18 
19 class ServicesRegistry : public OpcUa::Server::ServicesRegistry
20 {
21 public:
22  ServicesRegistry();
23 
24 public: // InternalServerAddon
25  virtual OpcUa::Services::SharedPtr GetServer() const override;
26  virtual void RegisterEndpointsServices(EndpointServices::SharedPtr endpoints) override;
27  virtual void UnregisterEndpointsServices() override;
28  virtual void RegisterViewServices(ViewServices::SharedPtr views) override;
29  virtual void UnregisterViewServices() override;
30  virtual void RegisterMethodServices(MethodServices::SharedPtr method) override;
31  virtual void UnregisterMethodServices() override;
32  virtual void RegisterNodeManagementServices(NodeManagementServices::SharedPtr addr) override;
33  virtual void UnregisterNodeManagementServices() override;
34  virtual void RegisterAttributeServices(AttributeServices::SharedPtr attributes) override;
35  virtual void UnregisterAttributeServices() override;
36  virtual void RegisterSubscriptionServices(SubscriptionServices::SharedPtr service) override;
37  virtual void UnregisterSubscriptionServices() override;
38 
39 private:
40  class InternalServer;
41  std::shared_ptr<InternalServer> Comp;
42 };
43 
44 
45 class DefaultServices
46  : public EndpointServices
47  , public ViewServices
48  , public AttributeServices
49  , public MethodServices
50  , public NodeManagementServices
51  , public SubscriptionServices
52 {
53 public:
54  virtual std::vector<OpcUa::ApplicationDescription> FindServers(const FindServersParameters & params) const
55  {
56  return std::vector<OpcUa::ApplicationDescription>();
57  }
58 
59  virtual std::vector<OpcUa::EndpointDescription> GetEndpoints(const GetEndpointsParameters & filter) const
60  {
61  return std::vector<OpcUa::EndpointDescription>();
62  }
63 
64  virtual void RegisterServer(const ServerParameters & parameters)
65  {
66  }
67 
68  virtual std::vector<CallMethodResult> Call(const std::vector<CallMethodRequest> & methodsToCall)
69  {
70  return std::vector<CallMethodResult>();
71  }
72 
73  virtual std::vector<AddNodesResult> AddNodes(const std::vector<AddNodesItem> & items)
74  {
75  return std::vector<AddNodesResult>();
76  }
77 
78  virtual std::vector<StatusCode> AddReferences(const std::vector<AddReferencesItem> & items)
79  {
80  return std::vector<StatusCode>();
81  }
82 
83  virtual void SetMethod(const NodeId & node, std::function<std::vector<OpcUa::Variant> (NodeId context, std::vector<OpcUa::Variant> arguments)> callback)
84  {
85  return;
86  }
87 
88  virtual void AddAttribute(const NodeId & node, AttributeId attribute, const Variant & value)
89  {
90  }
91 
92  virtual void AddReference(const NodeId & sourceNode, const ReferenceDescription & reference)
93  {
94  }
95 
96  virtual std::vector<BrowseResult> Browse(const NodesQuery & query) const
97  {
98  return std::vector<BrowseResult>();
99  }
100 
101  virtual std::vector<BrowseResult> BrowseNext() const
102  {
103  return std::vector<BrowseResult>();
104  }
105 
106  virtual std::vector<BrowsePathResult> TranslateBrowsePathsToNodeIds(const TranslateBrowsePathsParameters & params) const
107  {
108  return std::vector<BrowsePathResult>();
109  }
110 
111  virtual std::vector<NodeId> RegisterNodes(const std::vector<NodeId> & params) const
112  {
113  return std::vector<NodeId>();
114  }
115 
116  virtual void UnregisterNodes(const std::vector<NodeId> & params) const
117  {
118  return;
119  }
120 
121  virtual std::vector<OpcUa::DataValue> Read(const OpcUa::ReadParameters & filter) const
122  {
123  DataValue value;
126  return std::vector<OpcUa::DataValue>(filter.AttributesToRead.size(), value);
127  }
128 
129  virtual std::vector<OpcUa::StatusCode> Write(const std::vector<OpcUa::WriteValue> & filter)
130  {
131  return std::vector<OpcUa::StatusCode>(filter.size(), StatusCode::BadNotImplemented);
132  }
133 
134  virtual SubscriptionData CreateSubscription(const CreateSubscriptionRequest & request, std::function<void (PublishResult)> callback = 0)
135  {
136  return SubscriptionData();
137  }
138 
139  virtual ModifySubscriptionResponse ModifySubscription(const ModifySubscriptionParameters & parameters)
140  {
142  }
143 
144  virtual std::vector<StatusCode> DeleteSubscriptions(const std::vector<uint32_t> & subscriptions)
145  {
146  return std::vector<StatusCode>();
147  }
148 
149  virtual std::vector<MonitoredItemCreateResult> CreateMonitoredItems(const MonitoredItemsParameters & parameters)
150  {
151  return std::vector<MonitoredItemCreateResult>();
152  }
153 
154  virtual std::vector<StatusCode> DeleteMonitoredItems(const DeleteMonitoredItemsParameters & params)
155  {
156  return std::vector<StatusCode>();
157  }
158 
159  virtual void Publish(const PublishRequest & request)
160  {
161  }
162 
163  virtual RepublishResponse Republish(const RepublishParameters & params)
164  {
165  RepublishResponse response;
167  return response;
168  }
169 
170 };
171 
172 class ServicesRegistry::InternalServer : public Services
173 {
174 public:
175  InternalServer()
176  : Services(new DefaultServices())
177  {
178  SetEndpoints(Services);
179  SetViews(Services);
180  SetAttributes(Services);
181  SetSubscriptions(Services);
182  SetMethod(Services);
183  }
184 
185  virtual CreateSessionResponse CreateSession(const RemoteSessionParameters & parameters) override
186  {
187  return CreateSessionResponse();
188  }
189 
190  virtual ActivateSessionResponse ActivateSession(const ActivateSessionParameters & session_parameters) override
191  {
192  (void)session_parameters;
193  return ActivateSessionResponse();
194  }
195 
196  virtual OpenSecureChannelResponse OpenSecureChannel(const OpenSecureChannelParameters & parameters) override
197  {
198  return OpenSecureChannelResponse();
199  }
200 
201  virtual void CloseSecureChannel(uint32_t channelId) override
202  {
203  }
204 
205  virtual CloseSessionResponse CloseSession() override
206  {
207  return CloseSessionResponse();
208  }
209 
210  virtual void AbortSession() override
211  {
212  }
213 
214  virtual DeleteNodesResponse DeleteNodes(const std::vector<OpcUa::DeleteNodesItem> & nodesToDelete) override
215  {
216  return DeleteNodesResponse();
217  }
218 
219  virtual EndpointServices::SharedPtr Endpoints() override
220  {
221  return EndpointsServices;
222  }
223 
224  virtual std::shared_ptr<ViewServices> Views() override
225  {
226  return ViewsServices;
227  }
228 
229  virtual std::shared_ptr<MethodServices> Method() override
230  {
231  return MethodsServices;
232  }
233 
234  virtual std::shared_ptr<NodeManagementServices> NodeManagement() override
235  {
236  return NodeServices;
237  }
238 
239  virtual std::shared_ptr<AttributeServices> Attributes() override
240  {
241  return AttributesServices;
242  }
243 
244  virtual std::shared_ptr<SubscriptionServices> Subscriptions() override
245  {
246  return SubscriptionsServices;
247  }
248 
249 public:
250  void SetEndpoints(std::shared_ptr<EndpointServices> endpoints)
251  {
252  EndpointsServices = endpoints ? endpoints : Services;
253  }
254 
255  void SetViews(std::shared_ptr<ViewServices> views)
256  {
257  ViewsServices = views ? views : Services;
258  }
259 
260  void SetMethod(std::shared_ptr<MethodServices> method)
261  {
262  MethodsServices = method ? method : Services;
263  }
264 
265  void SetAddressSpace(std::shared_ptr<NodeManagementServices> addrs)
266  {
267  NodeServices = addrs ? addrs : Services;
268  }
269 
270  void SetAttributes(std::shared_ptr<AttributeServices> attributes)
271  {
272  AttributesServices = attributes ? attributes : Services;
273  }
274 
275  void SetSubscriptions(std::shared_ptr<SubscriptionServices> subscriptions)
276  {
277  SubscriptionsServices = subscriptions ? subscriptions : Services;
278  }
279 
280 public:
281  OpcUa::AttributeServices::SharedPtr AttributesServices;
282  OpcUa::ViewServices::SharedPtr ViewsServices;
283  OpcUa::MethodServices::SharedPtr MethodsServices;
284  OpcUa::NodeManagementServices::SharedPtr NodeServices;
285  OpcUa::EndpointServices::SharedPtr EndpointsServices;
286  OpcUa::SubscriptionServices::SharedPtr SubscriptionsServices;
287  std::shared_ptr<DefaultServices> Services;
288 };
289 
290 
291 ServicesRegistry::ServicesRegistry()
292  : Comp(new InternalServer())
293 {
294 }
295 
296 std::shared_ptr<Services> ServicesRegistry::GetServer() const
297 {
298  return Comp;
299 }
300 
301 void ServicesRegistry::RegisterEndpointsServices(EndpointServices::SharedPtr endpoints)
302 {
303  Comp->SetEndpoints(endpoints);
304 }
305 
307 {
308  Comp->SetEndpoints(EndpointServices::SharedPtr());
309 }
310 
311 void ServicesRegistry::RegisterViewServices(ViewServices::SharedPtr views)
312 {
313  Comp->SetViews(views);
314 }
315 
317 {
318  Comp->SetViews(ViewServices::SharedPtr());
319 }
320 
321 void ServicesRegistry::RegisterMethodServices(MethodServices::SharedPtr method)
322 {
323  Comp->SetMethod(method);
324 }
325 
327 {
328  Comp->SetMethod(MethodServices::SharedPtr());
329 }
330 
331 void ServicesRegistry::RegisterNodeManagementServices(NodeManagementServices::SharedPtr addr)
332 {
333  Comp->SetAddressSpace(addr);
334 }
335 
337 {
338  Comp->SetAddressSpace(NodeManagementServices::SharedPtr());
339 }
340 
341 
342 void ServicesRegistry::RegisterAttributeServices(AttributeServices::SharedPtr attributes)
343 {
344  Comp->SetAttributes(attributes);
345 }
346 
348 {
349  Comp->SetAttributes(AttributeServices::SharedPtr());
350 }
351 
352 void ServicesRegistry::RegisterSubscriptionServices(SubscriptionServices::SharedPtr service)
353 {
354  Comp->SetSubscriptions(service);
355 }
356 
358 {
359  Comp->SetSubscriptions(SubscriptionServices::SharedPtr());
360 }
361 
362 }
363 
364 namespace OpcUa
365 {
366 
367 Server::ServicesRegistry::UniquePtr Server::CreateServicesRegistry()
368 {
369  return Server::ServicesRegistry::UniquePtr(new ::ServicesRegistry());
370 }
371 
372 }
std::vector< OpcUa::ReadValueId > AttributesToRead
virtual void UnregisterNodeManagementServices()=0
virtual void UnregisterAttributeServices()=0
virtual void UnregisterMethodServices()=0
virtual void UnregisterEndpointsServices()=0
void CloseSession(OpcUa::Binary::IOStream &stream, const OpcUa::Binary::CreateSessionResponse &session)
virtual void RegisterMethodServices(MethodServices::SharedPtr method)=0
const uint8_t DATA_VALUE_STATUS_CODE
Definition: data_value.h:19
StatusCode ServiceResult
Definition: types.h:259
std::vector< T > Browse(const NodeId &node, NodeClass nodeClassMask, Services::SharedPtr services)
Definition: model_impl.h:31
virtual void UnregisterSubscriptionServices()=0
OpcUa::Binary::CreateSessionResponse CreateSession(OpcUa::Binary::IOStream &stream)
virtual void RegisterAttributeServices(OpcUa::AttributeServices::SharedPtr attributes)=0
OPC UA Address space part. GNU LGPL.
void ActivateSession(OpcUa::Binary::IOStream &stream, const OpcUa::Binary::CreateSessionResponse &session)
const char Views[]
Definition: strings.h:208
virtual std::shared_ptr< OpcUa::Services > GetServer() const =0
virtual void RegisterSubscriptionServices(OpcUa::SubscriptionServices::SharedPtr attributes)=0
uint8_t Encoding
Definition: data_value.h:28
virtual void UnregisterViewServices()=0
OpcUa::ResponseHeader Header
virtual void RegisterNodeManagementServices(OpcUa::NodeManagementServices::SharedPtr attributes)=0
virtual void RegisterEndpointsServices(OpcUa::EndpointServices::SharedPtr endpoints)=0
StatusCode Status
Definition: data_value.h:30
virtual void RegisterViewServices(OpcUa::ViewServices::SharedPtr views)=0
ServicesRegistry::UniquePtr CreateServicesRegistry()


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