services_registry_impl.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 #include <opc/ua/server/addons/services_registry.h>
00012 
00013 #include <opc/ua/protocol/endpoints.h>
00014 
00015 namespace
00016 {
00017   using namespace OpcUa;
00018 
00019   class ServicesRegistry : public OpcUa::Server::ServicesRegistry
00020   {
00021   public:
00022     ServicesRegistry();
00023 
00024   public: // InternalServerAddon
00025     virtual OpcUa::Services::SharedPtr GetServer() const;
00026     virtual void RegisterEndpointsServices(EndpointServices::SharedPtr endpoints) override;
00027     virtual void UnregisterEndpointsServices()  override;
00028     virtual void RegisterViewServices(ViewServices::SharedPtr views) override;
00029     virtual void UnregisterViewServices() override;
00030     virtual void RegisterMethodServices(MethodServices::SharedPtr method) override;
00031     virtual void UnregisterMethodServices() override;
00032     virtual void RegisterNodeManagementServices(NodeManagementServices::SharedPtr addr) override;
00033     virtual void UnregisterNodeManagementServices() override;
00034     virtual void RegisterAttributeServices(AttributeServices::SharedPtr attributes) override;
00035     virtual void UnregisterAttributeServices() override;
00036     virtual void RegisterSubscriptionServices(SubscriptionServices::SharedPtr service) override;
00037     virtual void UnregisterSubscriptionServices() override;
00038 
00039   private:
00040     class InternalServer;
00041     std::shared_ptr<InternalServer> Comp;
00042   };
00043 
00044 
00045   class DefaultServices
00046     : public EndpointServices
00047     , public ViewServices
00048     , public AttributeServices
00049     , public MethodServices
00050     , public NodeManagementServices
00051     , public SubscriptionServices
00052   {
00053   public:
00054     virtual std::vector<OpcUa::ApplicationDescription> FindServers(const FindServersParameters& params) const
00055     {
00056       return std::vector<OpcUa::ApplicationDescription>();
00057     }
00058 
00059     virtual std::vector<OpcUa::EndpointDescription> GetEndpoints(const GetEndpointsParameters& filter) const
00060     {
00061       return std::vector<OpcUa::EndpointDescription>();
00062     }
00063 
00064     virtual void RegisterServer(const ServerParameters& parameters)
00065     {
00066     }
00067 
00068     virtual std::vector<CallMethodResult> Call(const std::vector<CallMethodRequest>& methodsToCall)
00069     {
00070       return std::vector<CallMethodResult>();
00071     }
00072 
00073     virtual std::vector<AddNodesResult> AddNodes(const std::vector<AddNodesItem>& items)
00074     {
00075       return std::vector<AddNodesResult>();
00076     }
00077 
00078     virtual std::vector<StatusCode> AddReferences(const std::vector<AddReferencesItem>& items)
00079     {
00080       return std::vector<StatusCode>();
00081     }
00082 
00083     virtual void AddAttribute(const NodeId& node, AttributeId attribute, const Variant& value)
00084     {
00085     }
00086 
00087     virtual void AddReference(const NodeId& sourceNode, const ReferenceDescription& reference)
00088     {
00089     }
00090 
00091     virtual std::vector<BrowseResult> Browse(const NodesQuery& query) const
00092     {
00093       return std::vector<BrowseResult>();
00094     }
00095 
00096     virtual std::vector<BrowseResult> BrowseNext() const
00097     {
00098       return std::vector<BrowseResult>();
00099     }
00100 
00101     virtual std::vector<BrowsePathResult> TranslateBrowsePathsToNodeIds(const TranslateBrowsePathsParameters& params) const
00102     {
00103       return std::vector<BrowsePathResult>();
00104     }
00105 
00106         virtual std::vector<NodeId> RegisterNodes(const std::vector<NodeId>& params) const
00107         {
00108                 return std::vector<NodeId>();
00109         }
00110 
00111         virtual void UnregisterNodes(const std::vector<NodeId>& params) const
00112         {
00113                 return;
00114         }
00115 
00116     virtual std::vector<OpcUa::DataValue> Read(const OpcUa::ReadParameters& filter) const
00117     {
00118       DataValue value;
00119       value.Encoding = DATA_VALUE_STATUS_CODE;
00120       value.Status = StatusCode::BadNotImplemented;
00121       return std::vector<OpcUa::DataValue>(filter.AttributesToRead.size(), value);
00122     }
00123 
00124     virtual std::vector<OpcUa::StatusCode> Write(const std::vector<OpcUa::WriteValue>& filter)
00125     {
00126       return std::vector<OpcUa::StatusCode>(filter.size(), StatusCode::BadNotImplemented);
00127     }
00128 
00129     virtual SubscriptionData CreateSubscription(const CreateSubscriptionRequest& request, std::function<void (PublishResult)> callback=0)
00130     {
00131       return SubscriptionData();
00132     }
00133 
00134     virtual std::vector<StatusCode> DeleteSubscriptions(const std::vector<uint32_t>& subscriptions)
00135     {
00136       return std::vector<StatusCode>();
00137     }
00138 
00139     virtual std::vector<MonitoredItemCreateResult> CreateMonitoredItems(const MonitoredItemsParameters& parameters)
00140     {
00141       return std::vector<MonitoredItemCreateResult>();
00142     }
00143 
00144     virtual std::vector<StatusCode> DeleteMonitoredItems(const DeleteMonitoredItemsParameters& params)
00145     {
00146       return std::vector<StatusCode>();
00147     }
00148 
00149     virtual void Publish(const PublishRequest& request)
00150     {
00151     }
00152 
00153     virtual RepublishResponse Republish(const RepublishParameters& params)
00154     {
00155       RepublishResponse response;
00156       response.Header.ServiceResult = StatusCode::BadNotImplemented;
00157       return response;
00158     }
00159 
00160   };
00161 
00162   class ServicesRegistry::InternalServer : public Services
00163   {
00164   public:
00165     InternalServer()
00166       : Services(new DefaultServices())
00167     {
00168       SetEndpoints(Services);
00169       SetViews(Services);
00170       SetAttributes(Services);
00171       SetSubscriptions(Services);
00172     }
00173 
00174     virtual CreateSessionResponse CreateSession(const RemoteSessionParameters& parameters)
00175     {
00176       return CreateSessionResponse();
00177     }
00178 
00179     virtual ActivateSessionResponse ActivateSession(const ActivateSessionParameters &session_parameters) override
00180     {
00181       (void)session_parameters;
00182       return ActivateSessionResponse();
00183     }
00184 
00185     virtual OpenSecureChannelResponse OpenSecureChannel(const OpenSecureChannelParameters& parameters)
00186     {
00187       return OpenSecureChannelResponse();
00188     }
00189 
00190     virtual void CloseSecureChannel(uint32_t channelId)
00191     {
00192     }
00193 
00194     virtual CloseSessionResponse CloseSession()
00195     {
00196       return CloseSessionResponse();
00197     }
00198 
00199     virtual void AbortSession()
00200     {
00201     }
00202 
00203     virtual DeleteNodesResponse DeleteNodes(const std::vector<OpcUa::DeleteNodesItem> &nodesToDelete) override
00204     {
00205       return DeleteNodesResponse();
00206     }
00207 
00208     virtual EndpointServices::SharedPtr Endpoints() override
00209     {
00210       return EndpointsServices;
00211     }
00212 
00213     virtual std::shared_ptr<ViewServices> Views() override
00214     {
00215       return ViewsServices;
00216     }
00217 
00218     virtual std::shared_ptr<MethodServices> Method() override
00219     {
00220       return MethodsServices;
00221     }
00222 
00223     virtual std::shared_ptr<NodeManagementServices> NodeManagement() override
00224     {
00225       return NodeServices;
00226     }
00227 
00228     virtual std::shared_ptr<AttributeServices> Attributes() override
00229     {
00230       return AttributesServices;
00231     }
00232 
00233     virtual std::shared_ptr<SubscriptionServices> Subscriptions() override
00234     {
00235       return SubscriptionsServices;
00236     }
00237 
00238   public:
00239     void SetEndpoints(std::shared_ptr<EndpointServices> endpoints)
00240     {
00241       EndpointsServices = endpoints ? endpoints : Services;
00242     }
00243 
00244     void SetViews(std::shared_ptr<ViewServices> views)
00245     {
00246       ViewsServices = views ? views : Services;
00247     }
00248 
00249     void SetMethod(std::shared_ptr<MethodServices> method)
00250     {
00251       MethodsServices = method ? method : Services;
00252     }
00253 
00254     void SetAddressSpace(std::shared_ptr<NodeManagementServices> addrs)
00255     {
00256       NodeServices = addrs ? addrs : Services;
00257     }
00258 
00259     void SetAttributes(std::shared_ptr<AttributeServices> attributes)
00260     {
00261       AttributesServices = attributes ? attributes : Services;
00262     }
00263 
00264     void SetSubscriptions(std::shared_ptr<SubscriptionServices> subscriptions)
00265     {
00266       SubscriptionsServices = subscriptions ? subscriptions : Services;
00267     }
00268 
00269   public:
00270     OpcUa::AttributeServices::SharedPtr AttributesServices;
00271     OpcUa::ViewServices::SharedPtr ViewsServices;
00272     OpcUa::MethodServices::SharedPtr MethodsServices;
00273     OpcUa::NodeManagementServices::SharedPtr NodeServices;
00274     OpcUa::EndpointServices::SharedPtr EndpointsServices;
00275     OpcUa::SubscriptionServices::SharedPtr SubscriptionsServices;
00276     std::shared_ptr<DefaultServices> Services;
00277   };
00278 
00279 
00280   ServicesRegistry::ServicesRegistry()
00281     : Comp(new InternalServer())
00282   {
00283   }
00284 
00285   std::shared_ptr<Services> ServicesRegistry::GetServer() const
00286   {
00287     return Comp;
00288   }
00289 
00290   void ServicesRegistry::RegisterEndpointsServices(EndpointServices::SharedPtr endpoints)
00291   {
00292     Comp->SetEndpoints(endpoints);
00293   }
00294 
00295   void ServicesRegistry::UnregisterEndpointsServices()
00296   {
00297     Comp->SetEndpoints(EndpointServices::SharedPtr());
00298   }
00299 
00300   void ServicesRegistry::RegisterViewServices(ViewServices::SharedPtr views)
00301   {
00302     Comp->SetViews(views);
00303   }
00304 
00305   void ServicesRegistry::UnregisterViewServices()
00306   {
00307     Comp->SetViews(ViewServices::SharedPtr());
00308   }
00309 
00310   void ServicesRegistry::RegisterMethodServices(MethodServices::SharedPtr method)
00311   {
00312     Comp->SetMethod(method);
00313   }
00314 
00315   void ServicesRegistry::UnregisterMethodServices()
00316   {
00317     Comp->SetMethod(MethodServices::SharedPtr());
00318   }
00319 
00320   void ServicesRegistry::RegisterNodeManagementServices(NodeManagementServices::SharedPtr addr)
00321   {
00322     Comp->SetAddressSpace(addr);
00323   }
00324 
00325   void ServicesRegistry::UnregisterNodeManagementServices()
00326   {
00327     Comp->SetAddressSpace(NodeManagementServices::SharedPtr());
00328   }
00329 
00330 
00331   void ServicesRegistry::RegisterAttributeServices(AttributeServices::SharedPtr attributes)
00332   {
00333     Comp->SetAttributes(attributes);
00334   }
00335 
00336   void ServicesRegistry::UnregisterAttributeServices()
00337   {
00338     Comp->SetAttributes(AttributeServices::SharedPtr());
00339   }
00340 
00341   void ServicesRegistry::RegisterSubscriptionServices(SubscriptionServices::SharedPtr service)
00342   {
00343     Comp->SetSubscriptions(service);
00344   }
00345 
00346   void ServicesRegistry::UnregisterSubscriptionServices()
00347   {
00348     Comp->SetSubscriptions(SubscriptionServices::SharedPtr());
00349   }
00350 
00351 }
00352 
00353 namespace OpcUa
00354 {
00355 
00356   Server::ServicesRegistry::UniquePtr Server::CreateServicesRegistry()
00357   {
00358     return Server::ServicesRegistry::UniquePtr(new ::ServicesRegistry());
00359   }
00360 
00361 }


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Sat Jun 8 2019 18:24:56