parameter.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <any>
4 #include <stdint.h>
5 #include <string>
6 #include <unordered_map>
7 #include <vector>
8 
9 namespace foxglove {
10 
12  SUBSCRIBE,
14 };
15 
16 enum class ParameterType {
23  PARAMETER_STRUCT, // ROS 1 only
24  PARAMETER_BYTE_ARRAY, // ROS 2 only
25 };
26 
28 public:
30  ParameterValue(bool value);
31  ParameterValue(int value);
32  ParameterValue(int64_t value);
33  ParameterValue(double value);
34  ParameterValue(const std::string& value);
35  ParameterValue(const char* value);
36  ParameterValue(const std::vector<unsigned char>& value);
37  ParameterValue(const std::vector<ParameterValue>& value);
38  ParameterValue(const std::unordered_map<std::string, ParameterValue>& value);
39 
40  inline ParameterType getType() const {
41  return _type;
42  }
43 
44  template <typename T>
45  inline const T& getValue() const {
46  return std::any_cast<const T&>(_value);
47  }
48 
49 private:
51  std::any _value;
52 };
53 
54 class Parameter {
55 public:
56  Parameter();
57  Parameter(const std::string& name);
58  Parameter(const std::string& name, const ParameterValue& value);
59 
60  inline const std::string& getName() const {
61  return _name;
62  }
63 
64  inline ParameterType getType() const {
65  return _value.getType();
66  }
67 
68  inline const ParameterValue& getValue() const {
69  return _value;
70  }
71 
72 private:
73  std::string _name;
75 };
76 
77 } // namespace foxglove
const ParameterValue & getValue() const
Definition: parameter.hpp:68
ParameterType getType() const
Definition: parameter.hpp:40
ParameterValue _value
Definition: parameter.hpp:74
std::string _name
Definition: parameter.hpp:73
const std::string & getName() const
Definition: parameter.hpp:60
ParameterSubscriptionOperation
Definition: parameter.hpp:11
const T & getValue() const
Definition: parameter.hpp:45
ParameterType getType() const
Definition: parameter.hpp:64


foxglove_bridge
Author(s): Foxglove
autogenerated on Mon Jul 3 2023 02:12:22