hpp-corbaserver  4.13.0
Corba server for Humanoid Path Planner applications
server.hh
Go to the documentation of this file.
1 // Copyright (C) 2009, 2010 by Florent Lamiraux, Thomas Moulard, Joseph Mirabel,
2 // JRL.
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 // This software is provided "as is" without warranty of any kind,
30 // either expressed or implied, including but not limited to the
31 // implied warranties of fitness for a particular purpose.
32 //
33 // See the COPYING file for more information.
34 
35 #ifndef HPP_CORBASERVER_SERVER_HH
36 #define HPP_CORBASERVER_SERVER_HH
37 
38 #include <omniORB4/CORBA.h>
39 
40 #include <hpp/corba/template/server.hh>
42 #include <hpp/corbaserver/fwd.hh>
44 
45 namespace hpp {
46 namespace corbaServer {
48 
55 
57 
66 
78  public:
90  Server(core::ProblemSolverPtr_t problemSolver, int argc, const char* argv[],
91  bool multiThread = false);
92 
104  Server(ProblemSolverMapPtr_t problemSolverMap, int argc, const char* argv[],
105  bool multiThread = false);
106 
108  ~Server();
109 
110  PortableServer::POA_var poa() { return tools_->main_poa(); }
111 
112  CORBA::ORB_var orb() { return tools_->orb(); }
113 
116  void startCorbaServer();
117 
119  const std::string& mainContextId() const { return mainContextId_; }
120 
121  const bool& multiThread() const { return multiThread_; }
122 
123  const bool& nameService() const { return nameService_; }
124 
129  int processRequest(bool loop);
130 
135  void requestShutdown(bool wait);
136 
137  bool createContext(const std::string& contextName);
138 
139  CORBA::Object_ptr getServer(const std::string& contextName,
140  const std::string& pluginName,
141  const std::string& objectName);
142 
146  bool loadPlugin(const std::string& contextName,
147  const std::string& libFilename);
148 
149  ProblemSolverMapPtr_t problemSolverMap();
150 
151  core::ProblemSolverPtr_t problemSolver();
152 
153  typedef void* ServantKey;
154 
155  PortableServer::Servant getServant(ServantKey servantKey) const;
156 
157  void addServantKeyAndServant(ServantKey servantKey,
158  PortableServer::Servant servant);
159 
160  void removeServant(PortableServer::Servant servant);
161 
162  void clearServantsMap();
163 
164  private:
168 
169  void parseArguments(int argc, const char* argv[]);
170 
172 
173  corba::Server<Tools>* tools_;
174 
175  std::string ORBendPoint;
176  std::string mainContextId_;
177 
178  bool multiThread_, nameService_;
179 
187  ProblemSolverMapPtr_t problemSolverMap_;
188 
189  typedef shared_ptr<ServerPlugin> ServerPluginPtr_t;
190  typedef std::map<std::string, ServerPluginPtr_t> ServerPluginMap_t;
191  struct Context {
192  ServerPluginPtr_t main;
193  ServerPluginMap_t plugins;
194  };
195  std::map<std::string, Context> contexts_;
196 
197  Context& getContext(const std::string& name);
198 
199  typedef std::map<ServantKey, PortableServer::Servant>
200  ServantKeyToServantMap_t;
201  typedef std::map<PortableServer::Servant, ServantKey>
202  ServantToServantKeyMap_t;
203  ServantKeyToServantMap_t servantKeyToServantMap_;
204  ServantToServantKeyMap_t servantToServantKeyMap_;
205 };
206 } // end of namespace corbaServer.
207 } // end of namespace hpp.
208 #endif
shared_ptr< ProblemSolverMap > ProblemSolverMapPtr_t
Definition: fwd.hh:57
Implement CORBA interface ``Obstacle&#39;&#39;.
Definition: basic-server.hh:35
CORBA::ORB_var orb()
Definition: server.hh:112
PortableServer::POA_var poa()
Definition: server.hh:110
#define HPP_CORBASERVER_DLLAPI
Definition: config.hh:64
const std::string & mainContextId() const
Get main context ID.
Definition: server.hh:119
Implementation of Hpp module Corba server.
Definition: server.hh:77
const bool & multiThread() const
Definition: server.hh:121
void * ServantKey
Definition: server.hh:153
const bool & nameService() const
Definition: server.hh:123