server_object_addon.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2013-2014 by Alexander Rykovanov *
3  * rykovanov.as@gmail.com *
4  * *
5  * This library is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU Lesser General Public License as *
7  * published by the Free Software Foundation; version 3 of the License. *
8  * *
9  * This library is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU Lesser General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU Lesser General Public License *
15  * along with this library; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18  ******************************************************************************/
19 
20 #include "server_object.h"
21 #include "server_object_addon.h"
22 
25 #include <opc/ua/node.h>
26 
27 namespace
28 {
29 
30 class ServerObjectAddon : public Common::Addon
31 {
32 public:
33  void Initialize(Common::AddonsManager & manager, const Common::AddonParameters & parameters) override
34  {
35  for (const Common::Parameter & param : parameters.Parameters)
36  {
37  if (param.Name == "debug")
38  { Debug = param.Value == "false" || param.Value == "0" ? false : true; }
39  }
40 
41  OpcUa::Server::ServicesRegistry::SharedPtr registry = manager.GetAddon<OpcUa::Server::ServicesRegistry>(OpcUa::Server::ServicesRegistryAddonId);
42  OpcUa::Server::AsioAddon::SharedPtr asio = manager.GetAddon<OpcUa::Server::AsioAddon>(OpcUa::Server::AsioAddonId);
43  OpcUa::Services::SharedPtr services = registry->GetServer();
44  Object.reset(new OpcUa::Server::ServerObject(services, asio->GetIoService(), Debug));
45  }
46 
47  void Stop() override
48  {
49  Object.reset();
50  }
51 
52 private:
53  bool Debug = false;
54  OpcUa::Server::ServerObject::UniquePtr Object;
55 };
56 
57 } // namespace
58 
59 
60 namespace OpcUa
61 {
62 namespace Server
63 {
64 
65 Common::Addon::UniquePtr ServerObjectFactory::CreateAddon()
66 {
67  return Common::Addon::UniquePtr(new ServerObjectAddon());
68 }
69 
70 } // namespace UaServer
71 } // namespace OpcUa
Common::Addon * CreateAddon()
Addon interface definition GNU LGPL.
virtual std::shared_ptr< Addon > GetAddon(const AddonId &id) const =0
getting addon by id
virtual void Stop()=0
Stopping addon work. After calling this method addon should throw exception on any calls...
const char ServicesRegistryAddonId[]
registry_t< std::mutex > registry
Definition: registry.h:211
const char AsioAddonId[]
Definition: asio_addon.h:31
virtual void Initialize(AddonsManager &manager, const AddonParameters &parameters)=0
initialize addon.
Debug
OPC UA Address space part. GNU LGPL.
const char Server[]
Definition: strings.h:121
std::vector< Parameter > Parameters


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