hpp-corbaserver  4.9.0
Corba server for Humanoid Path Planner applications
server-plugin.hh
Go to the documentation of this file.
1 // Copyright (C) 2019 CNRS-LAAS
2 // Author: Joseph Mirabel
3 //
4 // This file is part of the hpp-corbaserver.
5 //
6 // hpp-corbaserver is free software: you can redistribute
7 // it and/or modify it under the terms of the GNU Lesser General
8 // Public License as published by the Free Software Foundation, either
9 // version 3 of the License, or (at your option) any later version.
10 //
11 // hpp-corbaserver is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with hpp-corbaserver. If not, see
18 // <http://www.gnu.org/licenses/>.
19 
20 #ifndef HPP_CORBASERVER_SERVER_PLUGIN_HH
21 # define HPP_CORBASERVER_SERVER_PLUGIN_HH
22 
23 # include <stdexcept>
24 
25 # include <hpp/util/exception.hh>
26 
27 # include <hpp/corbaserver/config.hh>
28 # include <hpp/corbaserver/fwd.hh>
30 
31 # include <hpp/corbaserver/server.hh>
33 
34 #define HPP_CORBASERVER_DEFINE_PLUGIN(PluginClassName) \
35  extern "C" { \
36  ::hpp::corbaServer::ServerPlugin* createServerPlugin (::hpp::corbaServer::Server* server) \
37  { \
38  return new PluginClassName (server); \
39  } \
40  }
41 
42 namespace hpp {
43  namespace corbaServer {
44  class HPP_CORBASERVER_DLLAPI ServerPlugin
45  {
46  public:
47  virtual ~ServerPlugin () {}
48 
50  virtual void startCorbaServer (const std::string& contextId,
51  const std::string& contextKind) = 0;
52 
53  virtual std::string name() const = 0;
54 
55  virtual ::CORBA::Object_ptr servant (const std::string& name) const = 0;
56 
58  {
59  return parent_;
60  }
61 
63  {
64  return problemSolverMap_->selected();
65  }
66 
68  {
69  return problemSolverMap_;
70  }
71 
74  {
75  problemSolverMap_ = psMap;
76  }
77 
78  protected:
79  ServerPlugin (Server* parent)
80  : parent_ (parent) {}
81 
84 
85  template <typename T> void initializeTplServer (corba::Server<T>*& server,
86  const std::string& contextId,
87  const std::string& contextKind,
88  const std::string& objectId,
89  const std::string& objectKind)
90  {
91  server = new corba::Server <T> (0, NULL);
92  server->initRootPOA(parent()->multiThread());
93 
94  int ret = parent()->nameService()
95  ? server->startCorbaServer(contextId, contextKind, objectId, objectKind)
96  : server->startCorbaServer();
97 
98  if (ret != 0) {
99  throw std::runtime_error ("Failed to start corba "
100  + contextId + '.' + contextKind + '/'
101  + objectId + '.' + objectKind
102  + " server.");
103  }
104  }
105  }; // class ServerPlugin
106  } // namespace corbaserver
107 } // namespace hpp
108 
109 #endif // HPP_CORBASERVER_SERVER_PLUGIN_HH
Server * parent()
Definition: server-plugin.hh:57
Definition: server-plugin.hh:44
Implement CORBA interface ``Obstacle&#39;&#39;.
ProblemSolverMapPtr_t problemSolverMap_
Definition: server-plugin.hh:83
virtual ~ServerPlugin()
Definition: server-plugin.hh:47
ServerPlugin(Server *parent)
Definition: server-plugin.hh:79
boost::shared_ptr< ProblemSolverMap > ProblemSolverMapPtr_t
Definition: fwd.hh:34
Server * parent_
Definition: server-plugin.hh:82
int startCorbaServer(const std::string &contextId, const std::string &contextKind, const std::string &objectId, const std::string &objectKind)
void setProblemSolverMap(ProblemSolverMapPtr_t psMap)
Set planner that will be controlled by server.
Definition: server-plugin.hh:73
Implementation of Hpp module Corba server.
Definition: server.hh:54
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:85
core::ProblemSolverPtr_t problemSolver() const
Definition: server-plugin.hh:62
bool initRootPOA(bool inMultiThread)
ProblemSolverMapPtr_t problemSolverMap() const
Definition: server-plugin.hh:67