hpp-corbaserver  4.9.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 
21 
22 namespace hpp
23 {
24  namespace corbaServer
25  {
27 
32 
34 
43 
54  class HPP_CORBASERVER_DLLAPI Server
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  private:
155 
159 
160  void parseArguments (int argc, const char* argv[]);
161 
163 
164  corba::Server<Tools>* tools_;
165 
166  std::string ORBendPoint;
167  std::string mainContextId_;
168 
169  bool multiThread_, nameService_;
170 
178  ProblemSolverMapPtr_t problemSolverMap_;
179 
180  typedef boost::shared_ptr<ServerPlugin> ServerPluginPtr_t;
181  typedef std::map<std::string, ServerPluginPtr_t> ServerPluginMap_t;
182  struct Context {
183  ServerPluginPtr_t main;
184  ServerPluginMap_t plugins;
185  };
186  std::map<std::string, Context> contexts_;
187 
188  Context& getContext (const std::string& name);
189 
190  typedef std::map <ServantKey, PortableServer::Servant> ServantKeyToServantMap_t;
191  typedef std::map <PortableServer::Servant, ServantKey> ServantToServantKeyMap_t;
192  ServantKeyToServantMap_t servantKeyToServantMap_;
193  ServantToServantKeyMap_t servantToServantKeyMap_;
194  };
195  } // end of namespace corbaServer.
196 } // end of namespace hpp.
197 #endif
Implement CORBA interface ``Obstacle&#39;&#39;.
CORBA::ORB_var orb()
Definition: server.hh:93
boost::shared_ptr< ProblemSolverMap > ProblemSolverMapPtr_t
Definition: fwd.hh:34
PortableServer::POA_var poa()
Definition: server.hh:88
bool loadPlugin(const std::string &lib, ProblemSolver *ps)
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