hpp-corbaserver 4.14.0
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
40#include <vector>
41
43#include "hpp/core/path-vector.hh"
44#include "hpp/core/path.hh"
46
47namespace hpp {
48namespace corbaServer {
49namespace core_idl {
50hpp::core_idl::Path_ptr makePathServant(Server* server, const PathPtr_t& path);
51
52template <typename _Base, typename _Storage>
53class PathServant : public ServantBase<core::Path, _Storage>,
54 public virtual _Base {
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
85 hpp::core_idl::Path_ptr extract(value_type tmin, value_type tmax) {
87 get()->extract(core::interval_t(tmin, tmax)));
88 }
89
90 hpp::core_idl::PathVector_ptr asVector();
91};
92
94
95template <typename _Base, typename _Storage>
96class PathVectorServant : public PathServant<_Base, _Storage> {
98
99 public:
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
121typedef PathVectorServant<POA_hpp::core_idl::PathVector, core::PathVectorPtr_t>
123
124template <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
Definition: common-idl.hh:689
Server * server_
Definition: servant-base.hh:116
Definition: servant-base.hh:120
_Storage Storage
Definition: servant-base.hh:122
StorageElementShPtr_t getT() const
Definition: servant-base.hh:139
virtual TShPtr_t get() const
Definition: servant-base.hh:130
Implementation of Hpp module Corba server.
Definition: server.hh:77
hpp::core_idl::PathVector_ptr asVector()
Definition: paths.hh:125
char * str()
Definition: paths.hh:68
size_type outputSize()
Definition: paths.hh:62
floatSeq * value(value_type t, CORBA::Boolean &success)
Definition: paths.hh:75
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 * 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
#define SERVANT_BASE_TYPEDEFS(idlObj, hppObj)
Definition: servant-base.hh:73
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:100
pinocchio::vector_t vector_t
Definition: fwd.hh:112
floatSeq * vectorToFloatSeq(core::vectorIn_t input)
pinocchio::size_type size_type
Definition: fwd.hh:115
core::PathPtr_t PathPtr_t
Definition: fwd.hh:97
pinocchio::value_type value_type
Definition: fwd.hh:109
Implement CORBA interface `‘Obstacle’'.
Definition: basic-server.hh:35