| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// Copyright (C) 2014 CNRS-LAAS |
| 2 |
|
|
// Author: Florent Lamiraux. |
| 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 |
|
|
#include <hpp/corbaserver/manipulation/server.hh> |
| 30 |
|
|
#include <hpp/corbaserver/server.hh> |
| 31 |
|
|
#include <hpp/util/exception.hh> |
| 32 |
|
|
|
| 33 |
|
|
#include "graph.impl.hh" |
| 34 |
|
|
#include "problem.impl.hh" |
| 35 |
|
|
#include "robot.impl.hh" |
| 36 |
|
|
|
| 37 |
|
|
namespace hpp { |
| 38 |
|
|
namespace manipulation { |
| 39 |
|
✗ |
Server::Server(corbaServer::Server* server) |
| 40 |
|
|
: corbaServer::ServerPlugin(server), |
| 41 |
|
✗ |
graphImpl_(NULL), |
| 42 |
|
✗ |
problemImpl_(NULL), |
| 43 |
|
✗ |
robotImpl_(NULL) {} |
| 44 |
|
|
|
| 45 |
|
✗ |
Server::~Server() { |
| 46 |
|
✗ |
if (graphImpl_) delete graphImpl_; |
| 47 |
|
✗ |
if (problemImpl_) delete problemImpl_; |
| 48 |
|
✗ |
if (robotImpl_) delete robotImpl_; |
| 49 |
|
|
} |
| 50 |
|
|
|
| 51 |
|
✗ |
std::string Server::name() const { return "manipulation"; } |
| 52 |
|
|
|
| 53 |
|
|
/// Start corba server |
| 54 |
|
✗ |
void Server::startCorbaServer(const std::string& contextId, |
| 55 |
|
|
const std::string& contextKind) { |
| 56 |
|
✗ |
initializeTplServer(graphImpl_, contextId, contextKind, name(), "graph"); |
| 57 |
|
✗ |
initializeTplServer(problemImpl_, contextId, contextKind, name(), "problem"); |
| 58 |
|
✗ |
initializeTplServer(robotImpl_, contextId, contextKind, name(), "robot"); |
| 59 |
|
|
|
| 60 |
|
✗ |
graphImpl_->implementation().setServer(this); |
| 61 |
|
✗ |
problemImpl_->implementation().setServer(this); |
| 62 |
|
✗ |
robotImpl_->implementation().setServer(this); |
| 63 |
|
|
} |
| 64 |
|
|
|
| 65 |
|
✗ |
ProblemSolverPtr_t Server::problemSolver() { |
| 66 |
|
|
ProblemSolverPtr_t psm = |
| 67 |
|
✗ |
dynamic_cast<ProblemSolverPtr_t>(problemSolverMap_->selected()); |
| 68 |
|
✗ |
if (psm == NULL) |
| 69 |
|
✗ |
throw std::logic_error("ProblemSolver is not a manipulation problem"); |
| 70 |
|
✗ |
return psm; |
| 71 |
|
|
} |
| 72 |
|
|
|
| 73 |
|
✗ |
::CORBA::Object_ptr Server::servant(const std::string& name) const { |
| 74 |
|
✗ |
if (name == "graph") return graphImpl_->implementation()._this(); |
| 75 |
|
✗ |
if (name == "problem") return problemImpl_->implementation()._this(); |
| 76 |
|
✗ |
if (name == "robot") return robotImpl_->implementation()._this(); |
| 77 |
|
✗ |
throw std::invalid_argument("No servant " + name); |
| 78 |
|
|
} |
| 79 |
|
|
} // namespace manipulation |
| 80 |
|
|
} // namespace hpp |
| 81 |
|
|
|
| 82 |
|
✗ |
HPP_CORBASERVER_DEFINE_PLUGIN(hpp::manipulation::Server) |
| 83 |
|
|
|