get_param_result.hpp
Go to the documentation of this file.
1 #pragma once
2 
11 #include <string>
12 #include <type_traits>
13 
14 #include <ros/console_backend.h>
15 
16 namespace cras
17 {
18 
23 {
25  bool defaultUsed {false};
26 
28  bool convertFailed {false};
29 
31  bool requiredMissing {false};
32 
34  ::std::string message{};
35 
37  ::ros::console::Level messageLevel {::ros::console::Level::Count};
38 };
39 
44 template <typename T>
46 {
52  GetParamResult(const T& value, const ::cras::GetParamResultInfo& info) : value(value), info(info) {}
53 
58  operator T() const // NOLINT(google-explicit-constructor)
59  {
60  return this->value;
61  }
62 
67  template <typename = ::std::enable_if<::std::is_same<T, char*>::value>>
68  operator ::std::string() const // NOLINT(google-explicit-constructor)
69  {
70  return {this->value};
71  }
72 
78  template <int I, typename = ::std::enable_if<::std::is_same<T, char[I]>::value>>
79  operator ::std::string() const // NOLINT(google-explicit-constructor)
80  {
81  return {this->value};
82  }
83 
85  T value;
86 
89 };
90 
91 }
cras::GetParamResultInfo::message
::std::string message
The log message (returned even if option printMessages is false).
Definition: get_param_result.hpp:34
cras
Definition: any.hpp:15
cras::GetParamResult
Wrapper for the result of a getParam() call. It is designed to autoconvert to the result type sometim...
Definition: get_param_result.hpp:45
cras::GetParamResultInfo::messageLevel
::ros::console::Level messageLevel
Severity of the log message.
Definition: get_param_result.hpp:37
cras::GetParamResultInfo::convertFailed
bool convertFailed
Whether a value conversion failed.
Definition: get_param_result.hpp:28
cras::GetParamResultInfo::defaultUsed
bool defaultUsed
Whether the default value has been used.
Definition: get_param_result.hpp:25
console_backend.h
cras::GetParamResult::GetParamResult
GetParamResult(const T &value, const ::cras::GetParamResultInfo &info)
Construct the result from a value and info.
Definition: get_param_result.hpp:52
cras::GetParamResultInfo
Detailed information about the executed getParam() call.
Definition: get_param_result.hpp:22
ros::console::levels::Level
Level
cras::GetParamResult::value
T value
The returned value.
Definition: get_param_result.hpp:85
cras::GetParamResultInfo::requiredMissing
bool requiredMissing
Whether a required parameter was found missing or could not be read.
Definition: get_param_result.hpp:31
cras::GetParamResult::info
::cras::GetParamResultInfo info
Details about getParam() execution.
Definition: get_param_result.hpp:88


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Mon Jun 17 2024 02:48:56