ORCA: Optimization-based framework for Robotic Control Applications
ParameterData.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <orca/utils/Utils.h>
4 
5 namespace orca
6 {
7 namespace common
8 {
13 template<class T>
15 {
16 public:
18  virtual ~ParameterData() {}
19 
20  ParameterData(const T& val)
21  : val_(val)
22  , is_set_(true)
23  {}
24 
25  template<class T2>
27  : ParameterData(v.get())
28  {}
29 
30  T& get()
31  {
32  if(!is_set_)
33  utils::orca_throw("Trying to get() but parameter is not set");
34  return val_;
35  }
36  const T& get() const
37  {
38  if(!is_set_)
39  utils::orca_throw("Trying to get() but parameter is not set");
40  return val_;
41  }
42 
43  void set(const T& val)
44  {
45  val_ = val;
46  if(!is_set_)
47  is_set_ = true;
48  }
49 
50  bool isSet() const
51  {
52  return is_set_;
53  }
54 private:
55  bool is_set_ = false;
56  T val_;
57 };
58 
59 } // namespace common
60 } // namespace orca
virtual ~ParameterData()
Definition: ParameterData.h:18
This class holds the data for a parameter of any type.
Definition: ParameterData.h:14
ParameterData()
Definition: ParameterData.h:17
void orca_throw(const std::string &arg)
Definition: Utils.h:153
ParameterData(const ParameterData< T2 > &v)
Definition: ParameterData.h:26
T & get()
Definition: ParameterData.h:30
ParameterData(const T &val)
Definition: ParameterData.h:20
Definition: CartesianAccelerationPID.h:44
bool isSet() const
Definition: ParameterData.h:50