Commit 66e5a373 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Use plugin mechanism of hpp-corbaserver.

parent 02e75758
......@@ -35,6 +35,8 @@ SET(CUSTOM_HEADER_DIR hpp/corbaserver/rbprm)
SETUP_HPP_PROJECT ()
LIST(APPEND PKG_CONFIG_ADDITIONAL_VARIABLES cmake_plugin)
SET(${PROJECT_NAME}_HEADERS
include/hpp/corbaserver/rbprm/server.hh
)
......
......@@ -21,29 +21,30 @@
# define HPP_RBPRM_CORBA_SERVER_HH
# include <hpp/corba/template/server.hh>
# include <hpp/corbaserver/rbprm/config.hh>
# include <hpp/corbaserver/problem-solver-map.hh>
# include <hpp/corbaserver/rbprm/config.hh>
# include <hpp/corbaserver/server-plugin.hh>
namespace hpp {
namespace rbprm {
namespace impl {
class RbprmBuilder;
}
class HPP_RBPRM_CORBA_DLLAPI Server
class HPP_RBPRM_CORBA_DLLAPI Server : public corbaServer::ServerPlugin
{
public:
Server (int argc, const char *argv[], bool multiThread = false,
const std::string& poaName = "child");
Server (corbaServer::Server* parent);
~Server ();
/// Set planner that will be controlled by server
void setProblemSolverMap (hpp::corbaServer::ProblemSolverMapPtr_t psMap);
/// Start corba server
/// Call hpp::corba::Server <impl::Problem>::startCorbaServer
void startCorbaServer(const std::string& contextId,
const std::string& contextKind,
const std::string& objectId);
const std::string& contextKind);
std::string name () const;
public:
corba::Server <impl::RbprmBuilder>* rbprmBuilder_;
}; // class Server
......
......@@ -20,6 +20,8 @@ SET(IDL_SOURCES
rbprmbuilder
)
INCLUDE(${HPP_CORBASERVER_CMAKE_PLUGIN})
OMNIIDL_INCLUDE_DIRECTORIES(
${HPP_CORBASERVER_DATAROOTDIR}/idl ${CMAKE_SOURCE_DIR}/idl
)
......@@ -51,27 +53,25 @@ INSTALL(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/hpp_stubs/rbprm
DESTINATION ${PYTHON_SITELIB}/hpp_stubs)
ADD_LIBRARY(${LIBRARY_NAME} SHARED
HPP_ADD_SERVER_PLUGIN(rbprm-corba
SOURCES
${ALL_IDL_CPP_STUBS}
rbprmbuilder.impl.cc
rbprmbuilder.impl.hh
server.cc
)
PKG_CONFIG_DEPENDENCIES
hpp-rbprm
hpp-corbaserver
omniORB4
hpp-util
hpp-rbprm)
ADD_CUSTOM_TARGET(generate_idl_cpp DEPENDS ${ALL_IDL_CPP_STUBS})
ADD_CUSTOM_TARGET(generate_idl_python DEPENDS ${ALL_IDL_PYTHON_STUBS})
ADD_DEPENDENCIES (${LIBRARY_NAME} generate_idl_cpp)
ADD_DEPENDENCIES (${LIBRARY_NAME} generate_idl_python)
TARGET_INCLUDE_DIRECTORIES(${LIBRARY_NAME} PUBLIC ${CDD_INCLUDE_DIRS})
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-rbprm)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-corbaserver)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} omniORB4)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-affordance-corba)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-util)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} hpp-rbprm)
INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION lib)
ADD_DEPENDENCIES (rbprm-corba generate_idl_cpp)
ADD_DEPENDENCIES (rbprm-corba generate_idl_python)
TARGET_INCLUDE_DIRECTORIES(rbprm-corba PUBLIC ${CDD_INCLUDE_DIRS})
INSTALL(
FILES
......@@ -102,7 +102,8 @@ INSTALL(
)
# Stand alone corba server
ADD_EXECUTABLE (hpp-rbprm-server hpp-rbprm-corba.cc)
TARGET_LINK_LIBRARIES (hpp-rbprm-server ${LIBRARY_NAME} hpp-rbprm)
PKG_CONFIG_USE_DEPENDENCY(hpp-rbprm-server hpp-corbaserver)
PKG_CONFIG_USE_DEPENDENCY(hpp-rbprm-server hpp-pinocchio)
INSTALL (TARGETS hpp-rbprm-server DESTINATION ${CMAKE_INSTALL_BINDIR})
......@@ -16,31 +16,18 @@
// <http://www.gnu.org/licenses/>.
#include <hpp/corbaserver/server.hh>
#include <hpp/corbaserver/affordance/server.hh>
#include <hpp/corbaserver/rbprm/server.hh>
#include <hpp/core/problem-solver.hh>
typedef hpp::rbprm::Server RbprmServer;
typedef hpp::corbaServer::Server CorbaServer;
typedef hpp::affordanceCorba::Server AffordanceServer;
int main (int argc, char* argv [])
{
hpp::core::ProblemSolverPtr_t problemSolver (hpp::core::ProblemSolver::create());
CorbaServer corbaServer (problemSolver, argc,
const_cast<const char**> (argv), true);
AffordanceServer affordanceServer (argc, const_cast<const char**> (argv),
true);
affordanceServer.setProblemSolverMap(corbaServer.problemSolverMap());
RbprmServer rbprmServer (argc, const_cast<const char**> (argv),
true, "rbprmChild");
rbprmServer.setProblemSolverMap (corbaServer.problemSolverMap());
corbaServer.startCorbaServer ();
affordanceServer.startCorbaServer ("hpp", "corbaserver",
"affordanceCorba", "affordance");
rbprmServer.startCorbaServer ("hpp", "corbaserver", "rbprm");
corbaServer.loadPlugin (corbaServer.mainContextId (), "rbprm-corba.so");
corbaServer.loadPlugin (corbaServer.mainContextId (), "affordance-corba.so");
corbaServer.processRequest(true);
}
......@@ -3319,13 +3319,6 @@ namespace hpp {
}
}
void RbprmBuilder::SetProblemSolverMap (hpp::corbaServer::ProblemSolverMapPtr_t psMap)
{
psMap_ = psMap;
//bind shooter creator to hide problem as a parameter and respect signature
//initNewProblemSolver();
}
void RbprmBuilder::initNewProblemSolver()
{
//bind shooter creator to hide problem as a parameter and respect signature
......
......@@ -37,6 +37,7 @@
# include <hpp/core/config-validations.hh>
#include <hpp/rbprm/dynamic/dynamic-path-validation.hh>
# include "hpp/corbaserver/fwd.hh"
# include "hpp/corbaserver/rbprm/server.hh"
namespace hpp {
namespace rbprm {
......@@ -168,6 +169,11 @@ namespace hpp {
public:
RbprmBuilder ();
void setServer (Server* server)
{
server_ = server;
}
virtual void loadRobotRomModel (const char* robotName,
const char* rootJointType,
const char* packageName,
......@@ -377,12 +383,12 @@ namespace hpp {
void initNewProblemSolver ();
private:
/// \brief Pointer to hppPlanner object of hpp::corbaServer::Server.
corbaServer::ProblemSolverMapPtr_t psMap_;
core::ProblemSolverPtr_t problemSolver()
{
return psMap_->selected();
return server_->problemSolver();
}
Server* server_;
FullBodyMap fullBodyMap_;
rbprm::RbPrmFullBodyPtr_t fullBody()
{
......
......@@ -17,37 +17,44 @@
// License along with hpp-manipulation-corba. If not, see
// <http://www.gnu.org/licenses/>.
#include <hpp/corbaserver/rbprm/server.hh>
#include <hpp/util/exception.hh>
#include "rbprmbuilder.impl.hh"
#include <hpp/corbaserver/rbprm/server.hh>
#include <hpp/corbaserver/server.hh>
namespace hpp {
namespace rbprm {
Server::Server (int argc, const char *argv[], bool multiThread,
const std::string& poaName) :
rbprmBuilder_ (new corba::Server <impl::RbprmBuilder>
(argc, argv, multiThread, poaName)) {}
Server::Server (corbaServer::Server* server)
: corbaServer::ServerPlugin (server),
rbprmBuilder_ (NULL)
{}
Server::~Server ()
{
delete rbprmBuilder_;
if (rbprmBuilder_) delete rbprmBuilder_;
}
void Server::setProblemSolverMap (hpp::corbaServer::ProblemSolverMapPtr_t psMap)
std::string Server::name () const
{
rbprmBuilder_->implementation ().SetProblemSolverMap(psMap);
return "rbprm";
}
/// Start corba server
void Server::startCorbaServer(const std::string& contextId,
const std::string& contextKind,
const std::string& objectId)
const std::string& contextKind)
{
bool mThd = parent()->multiThread();
rbprmBuilder_ = new corba::Server <impl::RbprmBuilder> (0, NULL, mThd, "child");
rbprmBuilder_->implementation ().setServer (this);
if (rbprmBuilder_->startCorbaServer(contextId, contextKind,
objectId, "rbprmbuilder") != 0) {
HPP_THROW_EXCEPTION (hpp::Exception,
"Failed to start corba rbprm server.");
"rbprm", "rbprmbuilder") != 0) {
HPP_THROW_EXCEPTION (hpp::Exception,
"Failed to start corba rbprm server.");
}
}
} // namespace rbprm
} // namespace hpp
HPP_CORBASERVER_DEFINE_PLUGIN(hpp::rbprm::Server)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment