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

hpp-corbaserver 9.0.2 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>
41 #include <hpp/corbaserver/config.hh>
42 #include <hpp/corbaserver/fwd.hh>
43 #include <hpp/corbaserver/problem-solver-map.hh>
44 #include <hpp/corbaserver/read-write-lock.hh>
45
46 namespace hpp {
47 namespace corbaServer {
49
56
58
67
78 class HPP_CORBASERVER_DLLAPI Server {
79 public:
91 Server(core::ProblemSolverPtr_t problemSolver, int argc, const char* argv[],
92 bool multiThread = false);
93
98 Server(core::ProblemSolverPtr_t problemSolver, bool multiThread = false);
99
102
104 bool parseArguments(int argc, const char* argv[]);
105
107 void initialize();
108
110
112 ~Server();
113
114 PortableServer::POA_var poa() { return tools_->main_poa(); }
115
116 CORBA::ORB_var orb() { return tools_->orb(); }
117
120 void startCorbaServer();
121
123 const std::string& mainContextId() const { return mainContextId_; }
124
125 const bool& multiThread() const { return multiThread_; }
126
127 const bool& nameService() const { return nameService_; }
128
133 int processRequest(bool loop);
134
139 void requestShutdown(bool wait);
140
141 bool createContext(const std::string& contextName);
142
143 std::vector<std::string> getContexts() const;
144
145 bool deleteContext(const std::string& contextName);
146
147 CORBA::Object_ptr getServer(const std::string& contextName,
148 const std::string& pluginName,
149 const std::string& objectName);
150
154 bool loadPlugin(const std::string& contextName,
155 const std::string& libFilename);
156
157 ProblemSolverMapPtr_t problemSolverMap();
158
159 core::ProblemSolverPtr_t problemSolver();
160
161 typedef void* ServantKey;
162
163 PortableServer::Servant getServant(ServantKey servantKey) const;
164
165 void addServantKeyAndServant(ServantKey servantKey,
166 PortableServer::Servant servant);
167
168 void removeServant(PortableServer::Servant servant);
169
170 void clearServantsMap();
171
172 std::vector<std::string> getAllObjectIds();
173
174 private:
175 corba::Server<Tools>* tools_;
176
177 std::string ORBendPoint;
178 std::string mainContextId_;
179
180 bool multiThread_, nameService_;
181
189 ProblemSolverMapPtr_t problemSolverMap_;
190
191 typedef shared_ptr<ServerPlugin> ServerPluginPtr_t;
192 typedef std::map<std::string, ServerPluginPtr_t> ServerPluginMap_t;
193 struct Context {
194 ServerPluginPtr_t main;
195 ServerPluginMap_t plugins;
196 };
197 std::map<std::string, Context> contexts_;
198
199 Context& getContext(const std::string& name);
200
201 typedef std::map<ServantKey, PortableServer::Servant>
202 ServantKeyToServantMap_t;
203 typedef std::map<PortableServer::Servant, ServantKey>
204 ServantToServantKeyMap_t;
205 ServantKeyToServantMap_t servantKeyToServantMap_;
206 ServantToServantKeyMap_t servantToServantKeyMap_;
207 // Mutex for accessing servant / servant key maps.
208 ReadWriteLock lock_;
209 };
210 } // end of namespace corbaServer.
211 } // end of namespace hpp.
212 #endif
hpp::corbaServer::ReadWriteLock
Definition: read-write-lock.hh:17
hpp::corbaServer::Server
Implementation of Hpp module Corba server.
Definition: server.hh:78
hpp::corbaServer::Server::requestShutdown
void requestShutdown(bool wait)
hpp::corbaServer::Server::initialize
void initialize()
Initialize ORB and CORBA servers.
hpp::corbaServer::Server::getAllObjectIds
std::vector< std::string > getAllObjectIds()
hpp::corbaServer::Server::parseArguments
bool parseArguments(int argc, const char *argv[])
Configure using command line argument.
hpp::corbaServer::Server::clearServantsMap
void clearServantsMap()
hpp::corbaServer::Server::Server
Server(core::ProblemSolverPtr_t problemSolver, bool multiThread=false)
hpp::corbaServer::Server::getContexts
std::vector< std::string > getContexts() const
hpp::corbaServer::Server::multiThread
const bool & multiThread() const
Definition: server.hh:125
hpp::corbaServer::Server::getServer
CORBA::Object_ptr getServer(const std::string &contextName, const std::string &pluginName, const std::string &objectName)
hpp::corbaServer::Server::getServant
PortableServer::Servant getServant(ServantKey servantKey) const
hpp::corbaServer::Server::createContext
bool createContext(const std::string &contextName)
hpp::corbaServer::Server::orb
CORBA::ORB_var orb()
Definition: server.hh:116
hpp::corbaServer::Server::mainContextId
const std::string & mainContextId() const
Get main context ID.
Definition: server.hh:123
hpp::corbaServer::Server::problemSolverMap
ProblemSolverMapPtr_t problemSolverMap()
hpp::corbaServer::Server::nameService
const bool & nameService() const
Definition: server.hh:127
hpp::corbaServer::Server::addServantKeyAndServant
void addServantKeyAndServant(ServantKey servantKey, PortableServer::Servant servant)
hpp::corbaServer::Server::~Server
~Server()
Shutdown CORBA server.
hpp::corbaServer::Server::Server
Server(core::ProblemSolverPtr_t problemSolver, int argc, const char *argv[], bool multiThread=false)
hpp::corbaServer::Server::removeServant
void removeServant(PortableServer::Servant servant)
hpp::corbaServer::Server::loadPlugin
bool loadPlugin(const std::string &contextName, const std::string &libFilename)
hpp::corbaServer::Server::processRequest
int processRequest(bool loop)
If ORB work is pending, process it.
hpp::corbaServer::Server::startCorbaServer
void startCorbaServer()
Initialize CORBA server to process requests from clients.
hpp::corbaServer::Server::poa
PortableServer::POA_var poa()
Definition: server.hh:114
hpp::corbaServer::Server::ServantKey
void * ServantKey
Definition: server.hh:161
hpp::corbaServer::Server::problemSolver
core::ProblemSolverPtr_t problemSolver()
hpp::corbaServer::Server::deleteContext
bool deleteContext(const std::string &contextName)
hpp::corba::Server
hpp::core::ProblemSolver
config.hh
HPP_CORBASERVER_DLLAPI
#define HPP_CORBASERVER_DLLAPI
Definition: config.hh:88
fwd.hh
hpp::corbaServer::ProblemSolverMapPtr_t
shared_ptr< ProblemSolverMap > ProblemSolverMapPtr_t
Definition: fwd.hh:56
hpp
Implement CORBA interface `‘Obstacle’'.
problem-solver-map.hh
read-write-lock.hh
server.hh