hpp-corbaserver  6.0.0
Corba server for Humanoid Path Planner applications
problem.hh
Go to the documentation of this file.
1 
2 // Copyright (C) 2019 by Joseph Mirabel, LAAS-CNRS.
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_CORE_IDL_PROBLEM_HH
36 #define HPP_CORE_IDL_PROBLEM_HH
37 #include <stdlib.h>
38 
43 #include <hpp/corbaserver/fwd.hh>
45 #include <hpp/core/problem.hh>
47 #include <vector>
48 
49 namespace hpp {
50 namespace corbaServer {
51 namespace core_idl {
52 template <typename _Base, typename _Storage>
53 class ProblemServant : public ServantBase<core::Problem, _Storage>,
54  public virtual _Base {
55  SERVANT_BASE_TYPEDEFS(hpp::core_idl::Problem, core::Problem);
56 
57  public:
58  ProblemServant(Server* server, const Storage& p) : _ServantBase(server, p) {}
59 
60  virtual ~ProblemServant() {}
61 
63  core::DistancePtr_t distance = get()->distance();
64  DevicePtr_t robot = get()->robot();
65 
66  hpp::core_idl::Distance_var d = makeServantDownCast<Distance>(
67  server_, Distance::Storage(robot, distance));
68  return d._retn();
69  }
70 
72  core::DistancePtr_t d;
73  try {
74  d = reference_to_servant_base<core::Distance>(server_, distance)->get();
75  } catch (const Error& e) {
76  // TODO in this case, we should define a distance from the CORBA type.
77  // This would allow to implement a distance class in Python.
78  throw;
79  }
80 
81  get()->distance(d);
82  }
83 
85  core::SteeringMethodPtr_t steeringMethod = get()->steeringMethod();
86  DevicePtr_t robot = get()->robot();
87 
88  hpp::core_idl::SteeringMethod_var d = makeServantDownCast<SteeringMethod>(
89  server_, SteeringMethod::Storage(robot, steeringMethod));
90  return d._retn();
91  }
92 
95  try {
96  d = reference_to_servant_base<core::SteeringMethod>(server_,
97  steeringMethod)
98  ->get();
99  } catch (const Error& e) {
100  // TODO in this case, we should define a steeringMethod from the CORBA
101  // type. This would allow to implement a steeringMethod class in Python.
102  throw;
103  }
104 
105  get()->steeringMethod(d);
106  }
107 
109  core::PathValidationPtr_t pathValidation = get()->pathValidation();
110 
111  hpp::core_idl::PathValidation_var d = makeServantDownCast<PathValidation>(
112  server_, PathValidation::Storage(pathValidation));
113  return d._retn();
114  }
115 
117  core::PathValidationPtr_t d;
118  try {
119  d = reference_to_servant_base<core::PathValidation>(server_,
120  pathValidation)
121  ->get();
122  } catch (const Error& e) {
123  // TODO in this case, we should define a pathValidation from the CORBA
124  // type. This would allow to implement a pathValidation class in Python.
125  throw;
126  }
127 
128  get()->pathValidation(d);
129  }
130 };
131 
133 } // namespace core_idl
134 } // end of namespace corbaServer.
135 } // end of namespace hpp.
136 
137 #endif // HPP_CORE_IDL_PROBLEM_HH
_objref_Distance * Distance_ptr
Definition: _problem-idl.hh:165
_CORBA_ObjRef_Var< _objref_SteeringMethod, SteeringMethod_Helper > SteeringMethod_var
Definition: _problem-idl.hh:208
_objref_PathValidation * PathValidation_ptr
Definition: _problem-idl.hh:269
_CORBA_ObjRef_Var< _objref_PathValidation, PathValidation_Helper > PathValidation_var
Definition: _problem-idl.hh:286
_objref_SteeringMethod * SteeringMethod_ptr
Definition: _problem-idl.hh:191
_CORBA_ObjRef_Var< _objref_Distance, Distance_Helper > Distance_var
Definition: _problem-idl.hh:182
Server * server_
Definition: servant-base.hh:118
Definition: servant-base.hh:122
_Storage Storage
Definition: servant-base.hh:124
virtual TShPtr_t get() const
Definition: servant-base.hh:132
Implementation of Hpp module Corba server.
Definition: server.hh:78
void setSteeringMethod(hpp::core_idl::SteeringMethod_ptr steeringMethod)
Definition: problem.hh:93
hpp::core_idl::PathValidation_ptr getPathValidation()
Definition: problem.hh:108
ProblemServant(Server *server, const Storage &p)
Definition: problem.hh:58
void setPathValidation(hpp::core_idl::PathValidation_ptr pathValidation)
Definition: problem.hh:116
void setDistance(hpp::core_idl::Distance_ptr distance)
Definition: problem.hh:71
virtual ~ProblemServant()
Definition: problem.hh:60
hpp::core_idl::SteeringMethod_ptr getSteeringMethod()
Definition: problem.hh:84
hpp::core_idl::Distance_ptr getDistance()
Definition: problem.hh:62
Corba exception travelling through the Corba channel.
Definition: common.idl:27
Definition: _problem.idl:33
ProblemServant< POA_hpp::core_idl::Problem, core::ProblemPtr_t > Problem
Definition: problem.hh:132
core::SteeringMethodPtr_t SteeringMethodPtr_t
Definition: fwd.hh:101
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:73
Implement CORBA interface `‘Obstacle’'.
Definition: client.hh:46