hpp-core  4.9.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 
53  class HPP_CORE_DLLAPI Parameter
54  {
55  public:
56  enum Type {
60  INT,
68  NB_TYPES
69  };
70  ~Parameter();
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;
107  size_type intValue() const;
108  value_type floatValue() const;
109  std::string stringValue() const;
110  vector_t vectorValue() const;
111  matrix_t matrixValue() const;
113 
114  const void* const value_;
115  };
116 
117  class HPP_CORE_DLLAPI ParameterDescription
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
const void *const value_
Definition: parameter.hh:114
Type type_
Definition: parameter.hh:112
as matrix_t
Definition: parameter.hh:67
as value_type
Definition: parameter.hh:62
Definition: parameter.hh:58
Definition: parameter.hh:63
pinocchio::size_type size_type
Definition: fwd.hh:156
Definition: parameter.hh:117
Type
Definition: parameter.hh:56
const std::string & name() const
Definition: parameter.hh:132
Definition: parameter.hh:53
pinocchio::matrix_t matrix_t
Definition: fwd.hh:145
pinocchio::vector_t vector_t
Definition: fwd.hh:201
pinocchio::value_type value_type
Definition: fwd.hh:157
ParameterDescription(Parameter::Type type, std::string name, std::string doc="", Parameter defaultValue=Parameter())
Definition: parameter.hh:120
const Parameter::Type & type() const
Definition: parameter.hh:133
as vector_t
Definition: parameter.hh:65
const std::string & doc() const
Definition: parameter.hh:134
Definition: parameter.hh:57
as size_type
Definition: parameter.hh:60
ParameterDescription()
Definition: parameter.hh:130
std::ostream & operator<<(std::ostream &os, const Constraint &constraint)
Definition: constraint.hh:98