hpp-corbaserver  4.11.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, JRL.
2 //
3 // This file is part of the hpp-corbaserver.
4 //
5 // This software is provided "as is" without warranty of any kind,
6 // either expressed or implied, including but not limited to the
7 // implied warranties of fitness for a particular purpose.
8 //
9 // See the COPYING file for more information.
10 
11 #ifndef HPP_CORBASERVER_SERVER_HH
12 # define HPP_CORBASERVER_SERVER_HH
13 
14 # include <omniORB4/CORBA.h>
15 
16 # include <hpp/corbaserver/fwd.hh>
17 # include <hpp/corbaserver/config.hh>
19 
20 # include <hpp/corba/template/server.hh>
21 
22 namespace hpp
23 {
24  namespace corbaServer
25  {
27 
32 
34 
43 
55  {
56  public:
68  Server (core::ProblemSolverPtr_t problemSolver, int argc,
69  const char* argv[], bool multiThread = false);
70 
82  Server (ProblemSolverMapPtr_t problemSolverMap, int argc,
83  const char* argv[], bool multiThread = false);
84 
86  ~Server ();
87 
88  PortableServer::POA_var poa ()
89  {
90  return tools_->main_poa();
91  }
92 
93  CORBA::ORB_var orb()
94  {
95  return tools_->orb();
96  }
97 
100  void startCorbaServer ();
101 
103  const std::string& mainContextId () const
104  {
105  return mainContextId_;
106  }
107 
108  const bool& multiThread () const
109  {
110  return multiThread_;
111  }
112 
113  const bool& nameService () const
114  {
115  return nameService_;
116  }
117 
122  int processRequest (bool loop);
123 
128  void requestShutdown (bool wait);
129 
130  bool createContext (const std::string& contextName);
131 
132  CORBA::Object_ptr getServer (const std::string& contextName,
133  const std::string& pluginName,
134  const std::string& objectName);
135 
139  bool loadPlugin (const std::string& contextName,
140  const std::string& libFilename);
141 
142  ProblemSolverMapPtr_t problemSolverMap ();
143 
144  core::ProblemSolverPtr_t problemSolver ();
145 
146  typedef void* ServantKey;
147 
148  PortableServer::Servant getServant (ServantKey servantKey) const;
149 
150  void addServantKeyAndServant (ServantKey servantKey, PortableServer::Servant servant);
151 
152  void removeServant (PortableServer::Servant servant);
153 
154  void clearServantsMap ();
155 
156  private:
157 
161 
162  void parseArguments (int argc, const char* argv[]);
163 
165 
166  corba::Server<Tools>* tools_;
167 
168  std::string ORBendPoint;
169  std::string mainContextId_;
170 
171  bool multiThread_, nameService_;
172 
180  ProblemSolverMapPtr_t problemSolverMap_;
181 
182  typedef shared_ptr<ServerPlugin> ServerPluginPtr_t;
183  typedef std::map<std::string, ServerPluginPtr_t> ServerPluginMap_t;
184  struct Context {
185  ServerPluginPtr_t main;
186  ServerPluginMap_t plugins;
187  };
188  std::map<std::string, Context> contexts_;
189 
190  Context& getContext (const std::string& name);
191 
192  typedef std::map <ServantKey, PortableServer::Servant> ServantKeyToServantMap_t;
193  typedef std::map <PortableServer::Servant, ServantKey> ServantToServantKeyMap_t;
194  ServantKeyToServantMap_t servantKeyToServantMap_;
195  ServantToServantKeyMap_t servantToServantKeyMap_;
196  };
197  } // end of namespace corbaServer.
198 } // end of namespace hpp.
199 #endif
shared_ptr< ProblemSolverMap > ProblemSolverMapPtr_t
Definition: fwd.hh:34
Implement CORBA interface ``Obstacle&#39;&#39;.
Definition: basic-server.hh:27
CORBA::ORB_var orb()
Definition: server.hh:93
PortableServer::POA_var poa()
Definition: server.hh:88
#define HPP_CORBASERVER_DLLAPI
Definition: config.hh:64
const std::string & mainContextId() const
Get main context ID.
Definition: server.hh:103
Implementation of Hpp module Corba server.
Definition: server.hh:54
const bool & multiThread() const
Definition: server.hh:108
void * ServantKey
Definition: server.hh:146
const bool & nameService() const
Definition: server.hh:113