hpp-corbaserver: include/hpp/corbaserver/server-plugin.hh Source File

hpp-corbaserver 9.0.2 Corba server for Humanoid Path Planner applications

Loading...
Searching...
No Matches
server-plugin.hh
Go to the documentation of this file.
1// Copyright (C) 2019 CNRS-LAAS
2// Author: Joseph Mirabel
3//
4
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// 1. Redistributions of source code must retain the above copyright
10// notice, this list of conditions and the following disclaimer.
11//
12// 2. Redistributions in binary form must reproduce the above copyright
13// notice, this list of conditions and the following disclaimer in the
14// documentation and/or other materials provided with the distribution.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27// DAMAGE.
28
29#ifndef HPP_CORBASERVER_SERVER_PLUGIN_HH
30#define HPP_CORBASERVER_SERVER_PLUGIN_HH
31
32#include <hpp/corba/template/server.hh>
33#include <hpp/corbaserver/config.hh>
34#include <hpp/corbaserver/fwd.hh>
35#include <hpp/corbaserver/problem-solver-map.hh>
36#include <hpp/corbaserver/server.hh>
37#include <hpp/util/exception.hh>
38#include <stdexcept>
39
40#define HPP_CORBASERVER_DEFINE_PLUGIN(PluginClassName) \
41 extern "C" { \
42 ::hpp::corbaServer::ServerPlugin* createServerPlugin( \
43 ::hpp::corbaServer::Server* server) { \
44 return new PluginClassName(server); \
45 } \
46 }
47
48 namespace hpp {
49 namespace corbaServer {
50 class HPP_CORBASERVER_DLLAPI ServerPlugin {
51 public:
52 virtual ~ServerPlugin() {}
53
55 virtual void startCorbaServer(const std::string& contextId,
56 const std::string& contextKind) = 0;
57
58 virtual std::string name() const = 0;
59
60 virtual ::CORBA::Object_ptr servant(const std::string& name) const = 0;
61
62 Server* parent() { return parent_; }
63
64 core::ProblemSolverPtr_t problemSolver() const {
65 return problemSolverMap_->selected();
66 }
67
68 ProblemSolverMapPtr_t problemSolverMap() const { return problemSolverMap_; }
69
71 void setProblemSolverMap(ProblemSolverMapPtr_t psMap) {
72 problemSolverMap_ = psMap;
73 }
74
75 protected:
76 ServerPlugin(Server* parent) : parent_(parent) {}
77
78 Server* parent_;
79 ProblemSolverMapPtr_t problemSolverMap_;
80
81 template <typename T>
82 void initializeTplServer(corba::Server<T>*& server,
83 const std::string& contextId,
84 const std::string& contextKind,
85 const std::string& objectId,
86 const std::string& objectKind) {
87 server = new corba::Server<T>(0, NULL);
88 server->initRootPOA(parent()->multiThread());
89
90 int ret = parent()->nameService()
91 ? server->startCorbaServer(contextId, contextKind, objectId,
92 objectKind)
93 : server->startCorbaServer();
94
95 if (ret != 0) {
96 throw std::runtime_error("Failed to start corba " + contextId + '.' +
97 contextKind + '/' + objectId + '.' + objectKind +
98 " server.");
99 }
100 }
101}; // class ServerPlugin
102} // namespace corbaServer
103} // namespace hpp
104
105#endif // HPP_CORBASERVER_SERVER_PLUGIN_HH
hpp::corbaServer::ServerPlugin
Definition server-plugin.hh:50
hpp::corbaServer::ServerPlugin::parent
Server * parent()
Definition server-plugin.hh:62
hpp::corbaServer::ServerPlugin::problemSolverMap_
ProblemSolverMapPtr_t problemSolverMap_
Definition server-plugin.hh:79
hpp::corbaServer::ServerPlugin::problemSolverMap
ProblemSolverMapPtr_t problemSolverMap() const
Definition server-plugin.hh:68
hpp::corbaServer::ServerPlugin::setProblemSolverMap
void setProblemSolverMap(ProblemSolverMapPtr_t psMap)
Set planner that will be controlled by server.
Definition server-plugin.hh:71
hpp::corbaServer::ServerPlugin::initializeTplServer
void initializeTplServer(corba::Server< T > *&server, const std::string &contextId, const std::string &contextKind, const std::string &objectId, const std::string &objectKind)
Definition server-plugin.hh:82
hpp::corbaServer::ServerPlugin::ServerPlugin
ServerPlugin(Server *parent)
Definition server-plugin.hh:76
hpp::corbaServer::ServerPlugin::problemSolver
core::ProblemSolverPtr_t problemSolver() const
Definition server-plugin.hh:64
hpp::corbaServer::ServerPlugin::~ServerPlugin
virtual ~ServerPlugin()
Definition server-plugin.hh:52
hpp::corbaServer::ServerPlugin::servant
virtual ::CORBA::Object_ptr servant(const std::string &name) const =0
hpp::corbaServer::ServerPlugin::parent_
Server * parent_
Definition server-plugin.hh:78
hpp::corbaServer::ServerPlugin::startCorbaServer
virtual void startCorbaServer(const std::string &contextId, const std::string &contextKind)=0
Start corba server.
hpp::corbaServer::ServerPlugin::name
virtual std::string name() const =0
hpp::corbaServer::Server
Implementation of Hpp module Corba server.
Definition server.hh:78
hpp::corba::ServerBase::startCorbaServer
int startCorbaServer(const std::string &contextId, const std::string &contextKind, const std::string &objectId, const std::string &objectKind)
hpp::corba::Server
hpp::corba::Server::initRootPOA
bool initRootPOA(bool inMultiThread)
hpp::core::ProblemSolver
config.hh
HPP_CORBASERVER_DLLAPI
#define HPP_CORBASERVER_DLLAPI
Definition config.hh:88
exception.hh
fwd.hh
hpp::corbaServer::ProblemSolverMapPtr_t
shared_ptr< ProblemSolverMap > ProblemSolverMapPtr_t
Definition fwd.hh:57
hpp
Implement CORBA interface `‘Obstacle’'.
problem-solver-map.hh
server.hh