hpp-core  4.14.0
Implement basic classes for canonical path planning for kinematic chains.
parameter.hh
Go to the documentation of this file.
1 //
2 // Copyright 2018 CNRS
3 //
4 // Author: Florent Lamiraux, Joseph Mirabel
5 //
6 
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are
9 // met:
10 //
11 // 1. Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 //
14 // 2. Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
29 // DAMAGE.
30 
31 #ifndef HPP_CORE_PARAMETER_HH
32 #define HPP_CORE_PARAMETER_HH
33 
34 #include <cassert>
35 #include <hpp/core/config.hh>
36 #include <hpp/core/fwd.hh>
37 #include <iostream>
38 #include <string>
39 #include <typeinfo>
40 
41 namespace hpp {
42 namespace core {
43 /*
44 class Parameter;
45 class DYNAMIC_GRAPH_DLLAPI EitherType {
46 public:
47  EitherType(const Parameter& value);
48  ~EitherType();
49  operator bool () const;
50  operator unsigned () const;
51  operator int () const;
52  operator float () const;
53  operator double () const;
54  operator std::string () const;
55  operator Vector () const;
56  operator Eigen::MatrixXd () const;
57  operator Eigen::Matrix4d () const;
58 private:
59  const Parameter* value_;
60 };
61 */
62 
64  public:
65  enum Type {
69  INT,
77  NB_TYPES
78  };
79  ~Parameter();
80  void deleteValue();
81  explicit Parameter(const bool& value);
82  explicit Parameter(const size_type& value);
83  explicit Parameter(const value_type& value);
84  explicit Parameter(const std::string& value);
85  explicit Parameter(const vector_t& value);
86  explicit Parameter(const matrix_t& value);
88  Parameter(const Parameter& value);
90  explicit Parameter();
91  // operator assignement
92  Parameter operator=(const Parameter& value);
94  Type type() const;
95 
107  // const EitherType value () const;
109  static std::string typeName(Type type);
110 
112  HPP_CORE_DLLAPI friend std::ostream& operator<<(std::ostream& os,
113  const Parameter& value);
114 
115  public:
116  // friend class EitherType;
117  bool boolValue() const;
118  size_type intValue() const;
119  value_type floatValue() const;
120  std::string stringValue() const;
121  vector_t vectorValue() const;
122  matrix_t matrixValue() const;
124 
125  const void* const value_;
126 };
127 
129  public:
130  ParameterDescription(Parameter::Type type, std::string name,
131  std::string doc = "",
132  Parameter defaultValue = Parameter())
133  : name_(name), doc_(doc), type_(type), defaultValue_(defaultValue) {}
134 
135  ParameterDescription() : type_(Parameter::NONE) {}
136 
137  const std::string& name() const { return name_; }
138  const Parameter::Type& type() const { return type_; }
139  const std::string& doc() const { return doc_; }
140  const Parameter& defaultValue() const;
141 
142  private:
143  std::string name_;
144  std::string doc_;
145  Parameter::Type type_;
146  Parameter defaultValue_;
147 };
148 } // namespace core
149 } // namespace hpp
150 
151 #endif // HPP_CORE_PARAMETER_HH
const void *const value_
Definition: parameter.hh:125
Type type_
Definition: parameter.hh:123
as matrix_t
Definition: parameter.hh:76
as value_type
Definition: parameter.hh:71
Definition: bi-rrt-planner.hh:35
Definition: parameter.hh:67
Definition: parameter.hh:72
pinocchio::size_type size_type
Definition: fwd.hh:172
Definition: parameter.hh:128
Type
Definition: parameter.hh:65
const std::string & name() const
Definition: parameter.hh:137
Definition: parameter.hh:63
pinocchio::matrix_t matrix_t
Definition: fwd.hh:161
pinocchio::vector_t vector_t
Definition: fwd.hh:219
pinocchio::value_type value_type
Definition: fwd.hh:173
ParameterDescription(Parameter::Type type, std::string name, std::string doc="", Parameter defaultValue=Parameter())
Definition: parameter.hh:130
const Parameter::Type & type() const
Definition: parameter.hh:138
as vector_t
Definition: parameter.hh:74
const std::string & doc() const
Definition: parameter.hh:139
Definition: parameter.hh:66
as size_type
Definition: parameter.hh:69
ParameterDescription()
Definition: parameter.hh:135
std::ostream & operator<<(std::ostream &os, const Constraint &constraint)
Definition: constraint.hh:99
#define HPP_CORE_DLLAPI
Definition: config.hh:64