hpp-corbaserver: include/hpp/corbaserver/core_idl/paths.hh Source File

hpp-corbaserver 9.0.2 Corba server for Humanoid Path Planner applications

Loading...
Searching...
No Matches
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
38#include <hpp/corbaserver/conversions.hh>
39#include <hpp/corbaserver/fwd.hh>
40#include <vector>
41
42#include "hpp/corbaserver/servant-base.hh"
43#include "hpp/core/path-vector.hh"
44#include "hpp/core/path.hh"
45#include "hpp/core_idl/paths-idl.hh"
46
47 namespace hpp {
48 namespace corbaServer {
49 namespace core_idl {
50hpp::core_idl::Path_ptr makePathServant(Server* server, const PathPtr_t& path);
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) {
80 vector_t res(get()->outputDerivativeSize());
81 get()->derivative(res, t, order);
82 return vectorToFloatSeq(res);
83 }
84
85 hpp::core_idl::Path_ptr extract(value_type tmin, value_type tmax) {
86 return makePathServant(server_,
87 get()->extract(core::interval_t(tmin, tmax)));
88 }
89
90 hpp::core_idl::PathVector_ptr asVector();
91};
92
93 typedef PathServant<POA_hpp::core_idl::Path, core::PathPtr_t> Path;
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:
100 typedef PathServant<Base, Storage> Parent;
101
102 PathVectorServant(Server* server, const Storage& s) : Parent(server, s) {}
103
104 std::size_t numberPaths() { return getT()->numberPaths(); }
105
106 hpp::core_idl::Path_ptr pathAtRank(std::size_t rank) {
107 return makePathServant(server_, getT()->pathAtRank(rank));
108 }
109
110 void appendPath(hpp::core_idl::Path_ptr path) {
111 getT()->appendPath(
112 reference_to_servant_base<core::Path>(server_, path)->get());
113 }
114
115 void concatenate(hpp::core_idl::PathVector_ptr path) {
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>
122 PathVector;
123
124 template <typename _Base, typename _Storage>
125hpp::core_idl::PathVector_ptr PathServant<_Base, _Storage>::asVector() {
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
floatSeq
Definition common-idl.hh:689
hpp::corbaServer::AbstractServantBase::server_
Server * server_
Definition servant-base.hh:118
hpp::corbaServer::ServantBase
Definition servant-base.hh:122
hpp::corbaServer::ServantBase< core::Path, _Storage >::Storage
_Storage Storage
Definition servant-base.hh:124
hpp::corbaServer::ServantBase< core::Path, _Storage >::getT
StorageElementShPtr_t getT() const
Definition servant-base.hh:146
hpp::corbaServer::ServantBase< core::Path, _Storage >::get
virtual TShPtr_t get() const
Definition servant-base.hh:132
hpp::corbaServer::Server
Implementation of Hpp module Corba server.
Definition server.hh:78
hpp::corbaServer::core_idl::PathServant
Definition paths.hh:54
hpp::corbaServer::core_idl::PathServant::asVector
hpp::core_idl::PathVector_ptr asVector()
Definition paths.hh:125
hpp::corbaServer::core_idl::PathServant::str
char * str()
Definition paths.hh:68
hpp::corbaServer::core_idl::PathServant::outputSize
size_type outputSize()
Definition paths.hh:62
hpp::corbaServer::core_idl::PathServant::value
floatSeq * value(value_type t, CORBA::Boolean &success)
Definition paths.hh:75
hpp::corbaServer::core_idl::PathServant::length
value_type length()
Definition paths.hh:66
hpp::corbaServer::core_idl::PathServant::extract
hpp::core_idl::Path_ptr extract(value_type tmin, value_type tmax)
Definition paths.hh:85
hpp::corbaServer::core_idl::PathServant::~PathServant
virtual ~PathServant()
Definition paths.hh:60
hpp::corbaServer::core_idl::PathServant::outputDerivativeSize
size_type outputDerivativeSize()
Definition paths.hh:64
hpp::corbaServer::core_idl::PathServant::PathServant
PathServant(Server *server, const Storage &s)
Definition paths.hh:58
hpp::corbaServer::core_idl::PathServant::derivative
floatSeq * derivative(value_type t, CORBA::Short order)
Definition paths.hh:79
hpp::corbaServer::core_idl::PathVectorServant
Definition paths.hh:96
hpp::corbaServer::core_idl::PathVectorServant::numberPaths
std::size_t numberPaths()
Definition paths.hh:104
hpp::corbaServer::core_idl::PathVectorServant::pathAtRank
hpp::core_idl::Path_ptr pathAtRank(std::size_t rank)
Definition paths.hh:106
hpp::corbaServer::core_idl::PathVectorServant::PathVectorServant
PathVectorServant(Server *server, const Storage &s)
Definition paths.hh:102
hpp::corbaServer::core_idl::PathVectorServant::concatenate
void concatenate(hpp::core_idl::PathVector_ptr path)
Definition paths.hh:115
hpp::corbaServer::core_idl::PathVectorServant::appendPath
void appendPath(hpp::core_idl::Path_ptr path)
Definition paths.hh:110
hpp::corbaServer::core_idl::PathVectorServant::Parent
PathServant< Base, Storage > Parent
Definition paths.hh:100
hpp::core::PathVector::create
static PathVectorPtr_t create(size_type outputSize, size_type outputDerivativeSize)
hpp::core::Path
conversions.hh
fwd.hh
hpp::corbaServer::makeServantDownCast
ReturnType::Object_var makeServantDownCast(Server *server, const typename ServantBaseType::Storage &t)
Definition servant-base.hh:407
SERVANT_BASE_TYPEDEFS
#define SERVANT_BASE_TYPEDEFS(idlObj, hppObj)
Definition servant-base.hh:73
hpp::core_idl::PathVector
Definition paths.idl:67
hpp::core_idl::Path
Definition paths.idl:23
hpp::corbaServer::core_idl::makePathServant
hpp::core_idl::Path_ptr makePathServant(Server *server, const PathPtr_t &path)
hpp::corbaServer::core_idl::Path
PathServant< POA_hpp::core_idl::Path, core::PathPtr_t > Path
Definition paths.hh:93
hpp::corbaServer::core_idl::PathVector
PathVectorServant< POA_hpp::core_idl::PathVector, core::PathVectorPtr_t > PathVector
Definition paths.hh:122
hpp::corbaServer::PathVectorPtr_t
core::PathVectorPtr_t PathVectorPtr_t
Definition fwd.hh:98
hpp::corbaServer::vector_t
pinocchio::vector_t vector_t
Definition fwd.hh:107
hpp::corbaServer::vectorToFloatSeq
floatSeq * vectorToFloatSeq(core::vectorIn_t input)
hpp::corbaServer::size_type
pinocchio::size_type size_type
Definition fwd.hh:110
hpp::corbaServer::PathPtr_t
core::PathPtr_t PathPtr_t
Definition fwd.hh:95
hpp::corbaServer::value_type
pinocchio::value_type value_type
Definition fwd.hh:104
hpp::core::interval_t
std::pair< value_type, value_type > interval_t
hpp
Implement CORBA interface `‘Obstacle’'.
path-vector.hh
path.hh
paths-idl.hh
servant-base.hh