hpp-core  4.12.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 // This file is part of hpp-core
7 // hpp-core is free software: you can redistribute it
8 // and/or modify it under the terms of the GNU Lesser General Public
9 // License as published by the Free Software Foundation, either version
10 // 3 of the License, or (at your option) any later version.
11 //
12 // hpp-core is distributed in the hope that it will be
13 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Lesser Public License for more details. You should have
16 // received a copy of the GNU Lesser General Public License along with
17 // hpp-core If not, see
18 // <http://www.gnu.org/licenses/>.
19 
20 #ifndef HPP_CORE_PARAMETER_HH
21 # define HPP_CORE_PARAMETER_HH
22 
23 #include <iostream>
24 #include <string>
25 #include <cassert>
26 #include <typeinfo>
27 
28 #include <hpp/core/config.hh>
29 #include <hpp/core/fwd.hh>
30 
31 namespace hpp {
32  namespace core {
33  /*
34  class Parameter;
35  class DYNAMIC_GRAPH_DLLAPI EitherType {
36  public:
37  EitherType(const Parameter& value);
38  ~EitherType();
39  operator bool () const;
40  operator unsigned () const;
41  operator int () const;
42  operator float () const;
43  operator double () const;
44  operator std::string () const;
45  operator Vector () const;
46  operator Eigen::MatrixXd () const;
47  operator Eigen::Matrix4d () const;
48  private:
49  const Parameter* value_;
50  };
51  */
52 
54  {
55  public:
56  enum Type {
60  INT,
68  NB_TYPES
69  };
71  void deleteValue ();
72  explicit Parameter(const bool& value);
73  explicit Parameter(const size_type& value);
74  explicit Parameter(const value_type& value);
75  explicit Parameter(const std::string& value);
76  explicit Parameter(const vector_t& value);
77  explicit Parameter(const matrix_t& value);
79  Parameter(const Parameter& value);
81  explicit Parameter();
82  // operator assignement
83  Parameter operator=(const Parameter& value);
85  Type type() const;
86 
98  // const EitherType value () const;
100  static std::string typeName(Type type);
101 
103  HPP_CORE_DLLAPI friend std::ostream& operator<<(std::ostream& os, const Parameter& value);
104  public:
105  // friend class EitherType;
106  bool boolValue() const;
109  std::string stringValue() const;
113 
114  const void* const value_;
115  };
116 
118  {
119  public:
121  std::string name,
122  std::string doc = "",
123  Parameter defaultValue = Parameter())
124  : name_ (name)
125  , doc_ (doc)
126  , type_ (type)
127  , defaultValue_ (defaultValue)
128  {}
129 
130  ParameterDescription () : type_ (Parameter::NONE) {}
131 
132  const std::string& name () const { return name_; }
133  const Parameter::Type& type () const { return type_; }
134  const std::string& doc () const { return doc_ ; }
135  const Parameter& defaultValue () const;
136 
137  private:
138  std::string name_;
139  std::string doc_;
140  Parameter::Type type_;
141  Parameter defaultValue_;
142  };
143  } // namespace core
144 } //namespace hpp
145 
146 #endif // HPP_CORE_PARAMETER_HH
Definition: parameter.hh:118
const Parameter::Type & type() const
Definition: parameter.hh:133
ParameterDescription(Parameter::Type type, std::string name, std::string doc="", Parameter defaultValue=Parameter())
Definition: parameter.hh:120
const Parameter & defaultValue() const
ParameterDescription()
Definition: parameter.hh:130
const std::string & name() const
Definition: parameter.hh:132
const std::string & doc() const
Definition: parameter.hh:134
Definition: parameter.hh:54
Parameter(const value_type &value)
matrix_t matrixValue() const
Parameter()
Construct an empty parameter (None)
Type
Definition: parameter.hh:56
@ STRING
Definition: parameter.hh:63
@ VECTOR
as vector_t
Definition: parameter.hh:65
@ NONE
Definition: parameter.hh:57
@ BOOL
Definition: parameter.hh:58
@ FLOAT
as value_type
Definition: parameter.hh:62
@ MATRIX
as matrix_t
Definition: parameter.hh:67
@ INT
as size_type
Definition: parameter.hh:60
Type type() const
Return the type of the value.
Parameter operator=(const Parameter &value)
value_type floatValue() const
bool boolValue() const
Parameter(const matrix_t &value)
Type type_
Definition: parameter.hh:112
HPP_CORE_DLLAPI friend std::ostream & operator<<(std::ostream &os, const Parameter &value)
Output in a stream.
static std::string typeName(Type type)
Return the name of the type.
Parameter(const std::string &value)
size_type intValue() const
Parameter(const Parameter &value)
Copy constructor.
Parameter(const bool &value)
Parameter(const size_type &value)
Parameter(const vector_t &value)
std::string stringValue() const
const void *const value_
Definition: parameter.hh:114
vector_t vectorValue() const
#define HPP_CORE_DLLAPI
Definition: config.hh:64
pinocchio::value_type value_type
Definition: fwd.hh:157
pinocchio::vector_t vector_t
Definition: fwd.hh:202
pinocchio::size_type size_type
Definition: fwd.hh:156
pinocchio::matrix_t matrix_t
Definition: fwd.hh:145
Definition: bi-rrt-planner.hh:24