hpp-corbaserver 4.14.0
Corba server for Humanoid Path Planner applications
Loading...
Searching...
No Matches
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>
44
45namespace hpp {
46namespace 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
109
110 PortableServer::POA_var poa() { return tools_->main_poa(); }
111
112 CORBA::ORB_var orb() { return tools_->orb(); }
113
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 std::vector<std::string> getContexts() const;
140
141 bool deleteContext(const std::string& contextName);
142
143 CORBA::Object_ptr getServer(const std::string& contextName,
144 const std::string& pluginName,
145 const std::string& objectName);
146
150 bool loadPlugin(const std::string& contextName,
151 const std::string& libFilename);
152
154
155 core::ProblemSolverPtr_t problemSolver();
156
157 typedef void* ServantKey;
158
159 PortableServer::Servant getServant(ServantKey servantKey) const;
160
162 PortableServer::Servant servant);
163
164 void removeServant(PortableServer::Servant servant);
165
167
168 private:
172
173 void parseArguments(int argc, const char* argv[]);
174
176
177 corba::Server<Tools>* tools_;
178
179 std::string ORBendPoint;
180 std::string mainContextId_;
181
182 bool multiThread_, nameService_;
183
191 ProblemSolverMapPtr_t problemSolverMap_;
192
193 typedef shared_ptr<ServerPlugin> ServerPluginPtr_t;
194 typedef std::map<std::string, ServerPluginPtr_t> ServerPluginMap_t;
195 struct Context {
196 ServerPluginPtr_t main;
197 ServerPluginMap_t plugins;
198 };
199 std::map<std::string, Context> contexts_;
200
201 Context& getContext(const std::string& name);
202
203 typedef std::map<ServantKey, PortableServer::Servant>
204 ServantKeyToServantMap_t;
205 typedef std::map<PortableServer::Servant, ServantKey>
206 ServantToServantKeyMap_t;
207 ServantKeyToServantMap_t servantKeyToServantMap_;
208 ServantToServantKeyMap_t servantToServantKeyMap_;
209};
210} // end of namespace corbaServer.
211} // end of namespace hpp.
212#endif
Implementation of Hpp module Corba server.
Definition: server.hh:77
void requestShutdown(bool wait)
std::vector< std::string > getContexts() const
CORBA::Object_ptr getServer(const std::string &contextName, const std::string &pluginName, const std::string &objectName)
PortableServer::Servant getServant(ServantKey servantKey) const
bool createContext(const std::string &contextName)
CORBA::ORB_var orb()
Definition: server.hh:112
const bool & nameService() const
Definition: server.hh:123
ProblemSolverMapPtr_t problemSolverMap()
const std::string & mainContextId() const
Get main context ID.
Definition: server.hh:119
void addServantKeyAndServant(ServantKey servantKey, PortableServer::Servant servant)
~Server()
Shutdown CORBA server.
const bool & multiThread() const
Definition: server.hh:121
Server(core::ProblemSolverPtr_t problemSolver, int argc, const char *argv[], bool multiThread=false)
void removeServant(PortableServer::Servant servant)
bool loadPlugin(const std::string &contextName, const std::string &libFilename)
int processRequest(bool loop)
If ORB work is pending, process it.
void startCorbaServer()
Initialize CORBA server to process requests from clients.
PortableServer::POA_var poa()
Definition: server.hh:110
void * ServantKey
Definition: server.hh:157
Server(ProblemSolverMapPtr_t problemSolverMap, int argc, const char *argv[], bool multiThread=false)
core::ProblemSolverPtr_t problemSolver()
bool deleteContext(const std::string &contextName)
#define HPP_CORBASERVER_DLLAPI
Definition: config.hh:64
shared_ptr< ProblemSolverMap > ProblemSolverMapPtr_t
Definition: fwd.hh:58
Implement CORBA interface `‘Obstacle’'.
Definition: basic-server.hh:35