hpp-corbaserver  5.0.0
Corba server for Humanoid Path Planner applications
paths.hh
Go to the documentation of this file.
1 // Copyright (C) 2019 by Joseph Mirabel, LAAS-CNRS.
2 //
3 
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // 1. Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 // DAMAGE.
27 //
28 // This software is provided "as is" without warranty of any kind,
29 // either expressed or implied, including but not limited to the
30 // implied warranties of fitness for a particular purpose.
31 //
32 // See the COPYING file for more information.
33 
34 #ifndef HPP_CORE_IDL_PATHS_HH
35 #define HPP_CORE_IDL_PATHS_HH
36 #include <stdlib.h>
37 
39 #include <hpp/corbaserver/fwd.hh>
40 #include <vector>
41 
43 #include "hpp/core/path-vector.hh"
44 #include "hpp/core/path.hh"
46 
47 namespace hpp {
48 namespace corbaServer {
49 namespace core_idl {
51 
52 template <typename _Base, typename _Storage>
53 class PathServant : public ServantBase<core::Path, _Storage>,
54  public virtual _Base {
55  SERVANT_BASE_TYPEDEFS(hpp::core_idl::Path, core::Path);
56 
57  public:
58  PathServant(Server* server, const Storage& s) : _ServantBase(server, s) {}
59 
60  virtual ~PathServant() {}
61 
62  size_type outputSize() { return get()->outputSize(); }
63 
64  size_type outputDerivativeSize() { return get()->outputDerivativeSize(); }
65 
66  value_type length() { return get()->length(); }
67 
68  char* str() {
69  std::ostringstream oss;
70  oss << *get();
71  std::string res = oss.str();
72  return CORBA::string_dup(res.c_str());
73  }
74 
75  floatSeq* value(value_type t, CORBA::Boolean& success) {
76  return vectorToFloatSeq(get()->operator()(t, success));
77  }
78 
79  floatSeq* derivative(value_type t, CORBA::Short order) {
81  get()->derivative(res, t, order);
82  return vectorToFloatSeq(res);
83  }
84 
86  return makePathServant(server_,
87  get()->extract(core::interval_t(tmin, tmax)));
88  }
89 
91 };
92 
94 
95 template <typename _Base, typename _Storage>
96 class PathVectorServant : public PathServant<_Base, _Storage> {
97  SERVANT_BASE_TYPEDEFS(hpp::core_idl::PathVector, core::Path);
98 
99  public:
101 
102  PathVectorServant(Server* server, const Storage& s) : Parent(server, s) {}
103 
104  std::size_t numberPaths() { return getT()->numberPaths(); }
105 
107  return makePathServant(server_, getT()->pathAtRank(rank));
108  }
109 
111  getT()->appendPath(
112  reference_to_servant_base<core::Path>(server_, path)->get());
113  }
114 
116  getT()->concatenate(
117  reference_to_servant<PathVectorServant>(server_, path)->getT());
118  }
119 };
120 
121 typedef PathVectorServant<POA_hpp::core_idl::PathVector, core::PathVectorPtr_t>
123 
124 template <typename _Base, typename _Storage>
126  PathPtr_t p = get();
127  PathVectorPtr_t pv =
128  core::PathVector::create(p->outputSize(), p->outputDerivativeSize());
129  pv->appendPath(p);
130 
131  return makeServant<hpp::core_idl::PathVector_ptr>(
132  server_, new PathVector(server_, pv));
133 }
134 
135 } // namespace core_idl
136 } // end of namespace corbaServer.
137 } // end of namespace hpp.
138 
139 #endif // HPP_CORE_IDL_PATHS_HH
Definition: common-idl.hh:689
Server * server_
Definition: servant-base.hh:118
Definition: servant-base.hh:122
_Storage Storage
Definition: servant-base.hh:124
StorageElementShPtr_t getT() const
Definition: servant-base.hh:146
virtual TShPtr_t get() const
Definition: servant-base.hh:132
Implementation of Hpp module Corba server.
Definition: server.hh:78
char * str()
Definition: paths.hh:68
hpp::core_idl::PathVector_ptr asVector()
Definition: paths.hh:125
size_type outputSize()
Definition: paths.hh:62
value_type length()
Definition: paths.hh:66
hpp::core_idl::Path_ptr extract(value_type tmin, value_type tmax)
Definition: paths.hh:85
virtual ~PathServant()
Definition: paths.hh:60
size_type outputDerivativeSize()
Definition: paths.hh:64
PathServant(Server *server, const Storage &s)
Definition: paths.hh:58
floatSeq * value(value_type t, CORBA::Boolean &success)
Definition: paths.hh:75
floatSeq * derivative(value_type t, CORBA::Short order)
Definition: paths.hh:79
std::size_t numberPaths()
Definition: paths.hh:104
hpp::core_idl::Path_ptr pathAtRank(std::size_t rank)
Definition: paths.hh:106
PathVectorServant(Server *server, const Storage &s)
Definition: paths.hh:102
void concatenate(hpp::core_idl::PathVector_ptr path)
Definition: paths.hh:115
void appendPath(hpp::core_idl::Path_ptr path)
Definition: paths.hh:110
PathServant< Base, Storage > Parent
Definition: paths.hh:100
Definition: paths.idl:67
Definition: paths.idl:23
hpp::core_idl::Path_ptr makePathServant(Server *server, const PathPtr_t &path)
PathServant< POA_hpp::core_idl::Path, core::PathPtr_t > Path
Definition: paths.hh:93
PathVectorServant< POA_hpp::core_idl::PathVector, core::PathVectorPtr_t > PathVector
Definition: paths.hh:122
core::PathVectorPtr_t PathVectorPtr_t
Definition: fwd.hh:99
pinocchio::vector_t vector_t
Definition: fwd.hh:108
pinocchio::size_type size_type
Definition: fwd.hh:111
core::PathPtr_t PathPtr_t
Definition: fwd.hh:96
floatSeq * vectorToFloatSeq(core::vectorIn_t input)
pinocchio::value_type value_type
Definition: fwd.hh:105
Implement CORBA interface `‘Obstacle’'.
Definition: client.hh:46
_objref_Path * Path_ptr
Definition: path_planners-idl.hh:83
_objref_PathVector * PathVector_ptr
Definition: paths-idl.hh:82
_CORBA_MODULE hpp _CORBA_MODULE_BEG _CORBA_MODULE core_idl _CORBA_MODULE_BEG typedef ::CORBA::ULongLong size_t
Definition: paths-idl.hh:75