server_object_addon.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002  *   Copyright (C) 2013-2014 by Alexander Rykovanov                        *
00003  *   rykovanov.as@gmail.com                                                   *
00004  *                                                                            *
00005  *   This library is free software; you can redistribute it and/or modify     *
00006  *   it under the terms of the GNU Lesser General Public License as           *
00007  *   published by the Free Software Foundation; version 3 of the License.     *
00008  *                                                                            *
00009  *   This library is distributed in the hope that it will be useful,          *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00012  *   GNU Lesser General Public License for more details.                      *
00013  *                                                                            *
00014  *   You should have received a copy of the GNU Lesser General Public License *
00015  *   along with this library; if not, write to the                            *
00016  *   Free Software Foundation, Inc.,                                          *
00017  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                *
00018  ******************************************************************************/
00019 
00020 #include "server_object.h"
00021 #include "server_object_addon.h"
00022 
00023 #include <opc/ua/server/addons/services_registry.h>
00024 #include <opc/ua/server/addons/asio_addon.h>
00025 #include <opc/ua/node.h>
00026 
00027 namespace
00028 {
00029 
00030   class ServerObjectAddon : public Common::Addon
00031   {
00032   public:
00033     void Initialize(Common::AddonsManager& manager, const Common::AddonParameters& parameters) override
00034     {
00035       for (const Common::Parameter& param : parameters.Parameters)
00036       {
00037         if (param.Name == "debug")
00038           Debug = param.Value == "false" || param.Value == "0" ? false : true;
00039       }
00040 
00041       OpcUa::Server::ServicesRegistry::SharedPtr registry = manager.GetAddon<OpcUa::Server::ServicesRegistry>(OpcUa::Server::ServicesRegistryAddonId);
00042       OpcUa::Server::AsioAddon::SharedPtr asio = manager.GetAddon<OpcUa::Server::AsioAddon>(OpcUa::Server::AsioAddonId);
00043       OpcUa::Services::SharedPtr services = registry->GetServer();
00044       Object.reset(new OpcUa::Server::ServerObject(services, asio->GetIoService(), Debug));
00045     }
00046 
00047     void Stop() override
00048     {
00049       Object.reset();
00050     }
00051 
00052   private:
00053     bool Debug = false;
00054     OpcUa::Server::ServerObject::UniquePtr Object;
00055   };
00056 
00057 } // namespace
00058 
00059 
00060 namespace OpcUa
00061 {
00062   namespace Server
00063   {
00064 
00065     Common::Addon::UniquePtr ServerObjectFactory::CreateAddon()
00066     {
00067       return Common::Addon::UniquePtr(new ServerObjectAddon());
00068     }
00069 
00070   } // namespace UaServer
00071 } // namespace OpcUa


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