hpp-core: include/hpp/core/parameter.hh Source File

hpp-core 9.0.2 Implement basic classes for canonical path planning for kinematic chains.

Loading...
Searching...
No Matches
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
41namespace hpp {
42namespace core {
43/*
44class Parameter;
45class DYNAMIC_GRAPH_DLLAPI EitherType {
46public:
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;
58private:
59 const Parameter* value_;
60};
61*/
62
63 class HPP_CORE_DLLAPI Parameter {
64 public:
65 enum Type {
66 NONE,
67 BOOL,
69 INT,
71 FLOAT,
72 STRING,
74 VECTOR,
76 MATRIX,
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;
123 Type type_;
124
125 const void* const value_;
126};
127
128 class HPP_CORE_DLLAPI ParameterDescription {
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
hpp::core::ParameterDescription
Definition parameter.hh:128
hpp::core::ParameterDescription::ParameterDescription
ParameterDescription(Parameter::Type type, std::string name, std::string doc="", Parameter defaultValue=Parameter())
Definition parameter.hh:130
hpp::core::ParameterDescription::ParameterDescription
ParameterDescription()
Definition parameter.hh:135
hpp::core::ParameterDescription::name
const std::string & name() const
Definition parameter.hh:137
hpp::core::ParameterDescription::type
const Parameter::Type & type() const
Definition parameter.hh:138
hpp::core::ParameterDescription::doc
const std::string & doc() const
Definition parameter.hh:139
hpp::core::ParameterDescription::defaultValue
const Parameter & defaultValue() const
hpp::core::Parameter
Definition parameter.hh:63
hpp::core::Parameter::Parameter
Parameter(const value_type &value)
hpp::core::Parameter::matrixValue
matrix_t matrixValue() const
hpp::core::Parameter::Parameter
Parameter()
Construct an empty parameter (None)
hpp::core::Parameter::Type
Type
Definition parameter.hh:65
hpp::core::Parameter::STRING
@ STRING
Definition parameter.hh:72
hpp::core::Parameter::VECTOR
@ VECTOR
as vector_t
Definition parameter.hh:74
hpp::core::Parameter::NONE
@ NONE
Definition parameter.hh:66
hpp::core::Parameter::BOOL
@ BOOL
Definition parameter.hh:67
hpp::core::Parameter::FLOAT
@ FLOAT
as value_type
Definition parameter.hh:71
hpp::core::Parameter::MATRIX
@ MATRIX
as matrix_t
Definition parameter.hh:76
hpp::core::Parameter::INT
@ INT
as size_type
Definition parameter.hh:69
hpp::core::Parameter::type
Type type() const
Return the type of the value.
hpp::core::Parameter::operator=
Parameter operator=(const Parameter &value)
hpp::core::Parameter::floatValue
value_type floatValue() const
hpp::core::Parameter::boolValue
bool boolValue() const
hpp::core::Parameter::operator<<
HPP_CORE_DLLAPI friend std::ostream & operator<<(std::ostream &os, const Parameter &value)
Output in a stream.
hpp::core::Parameter::Parameter
Parameter(const matrix_t &value)
hpp::core::Parameter::type_
Type type_
Definition parameter.hh:123
hpp::core::Parameter::typeName
static std::string typeName(Type type)
Return the name of the type.
hpp::core::Parameter::Parameter
Parameter(const std::string &value)
hpp::core::Parameter::intValue
size_type intValue() const
hpp::core::Parameter::~Parameter
~Parameter()
hpp::core::Parameter::Parameter
Parameter(const Parameter &value)
Copy constructor.
hpp::core::Parameter::Parameter
Parameter(const bool &value)
hpp::core::Parameter::Parameter
Parameter(const size_type &value)
hpp::core::Parameter::Parameter
Parameter(const vector_t &value)
hpp::core::Parameter::stringValue
std::string stringValue() const
hpp::core::Parameter::deleteValue
void deleteValue()
hpp::core::Parameter::value_
const void *const value_
Definition parameter.hh:125
hpp::core::Parameter::vectorValue
vector_t vectorValue() const
config.hh
HPP_CORE_DLLAPI
#define HPP_CORE_DLLAPI
Definition config.hh:88
fwd.hh
hpp
hpp::core::value_type
pinocchio::value_type value_type
Definition fwd.hh:174
hpp::core::vector_t
pinocchio::vector_t vector_t
Definition fwd.hh:220
hpp::core::size_type
pinocchio::size_type size_type
Definition fwd.hh:173
hpp::core::matrix_t
pinocchio::matrix_t matrix_t
Definition fwd.hh:162