This file provides helper methods easing access to parameters passed to nodes, nodelets and filters. More...
#include <functional>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <vector>
#include <cras_cpp_common/log_utils.h>
#include <cras_cpp_common/optional.hpp>
#include <cras_cpp_common/string_utils.hpp>
#include <cras_cpp_common/type_utils.hpp>
#include <cras_cpp_common/xmlrpc_value_utils.hpp>
#include <cras_cpp_common/param_utils/get_param_adapter.hpp>
#include <cras_cpp_common/param_utils/get_param_options.hpp>
#include <cras_cpp_common/param_utils/get_param_result.hpp>
Go to the source code of this file.
Classes | |
class | cras::GetParamException |
Exception thrown when conversion of a parameter fails during getParam() if option throwIfConvertFails is true or when a missing parameter is required. More... | |
Namespaces | |
cras | |
Macros | |
#define | DEFINE_CONVERTING_GET_PARAM(resultType, paramServerType, defaultUnit, convertToResultFn) |
Generate definitions of "specializations" of getParam(Verbose) that use different ResultType and ParamServerType. They will be automatically used when the user requests a parameter of type ResultType. If cras::to_string() cannot convert ResultType to string, you have to declare overload ::cras::to_string(const ResultType&) prior to calling this macro. More... | |
#define | DEFINE_CONVERTING_GET_PARAM_WITH_CAST(resultType, paramServerType, defaultUnit) |
Generate definitions of "specializations" of getParam(Verbose) that use different ResultType and ParamServerType. They will be automatically used when the user requests a parameter of type ResultType. paramServerType is converted to resultType via static_cast. More... | |
#define | DEFINE_CONVERTING_GET_PARAM_WITH_CONSTRUCTOR(resultType, paramServerType, defaultUnit) |
Generate definitions of "specializations" of getParam(Verbose) that use different ResultType and ParamServerType. They will be automatically used when the user requests a parameter of type ResultType. paramServerType is converted to resultType via resultType one-arg constructor. More... | |
Typedefs | |
template<typename ResultType , typename ParamServerType > | |
using | cras::check_get_param_types = typename std::enable_if_t< !::cras::is_optional< ResultType >::value &&!::cras::is_c_string< ResultType >::value &&!::cras::is_c_string< ParamServerType >::value > |
This type is a TrueType if the combination of ResultType and ParamServerType is valid. More... | |
Functions | |
inline ::std::string | cras::getParam (const ::cras::GetParamAdapter ¶m, const ::std::string &name, const ::cras::optional< const char * > &defaultValue, const ::std::string &unit="", const ::cras::GetParamOptions<::std::string > &options={}, const ::cras::LogHelper *const logger=nullptr) |
Get the value of the given ROS parameter, falling back to the specified default value (if not nullopt), and print out a ROS log message with the loaded values (if specified). More... | |
template<typename ResultType , typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type, ::cras::check_get_param_types< ResultType, ParamServerType > * = nullptr> | |
ResultType | cras::getParam (const ::cras::GetParamAdapter ¶m, const ::std::string &name, const ::cras::optional< ResultType > &defaultValue=ResultType(), const ::std::string &unit="", const ::cras::GetParamOptions< ResultType, ParamServerType > &options={}, const ::cras::LogHelper *const logger=nullptr) |
Get the value of the given ROS parameter, falling back to the specified default value (if not nullopt), and print out a ROS log message with the loaded values (if specified). More... | |
inline ::std::string | cras::getParam (const ::cras::GetParamAdapter ¶m, const ::std::string &name, const char *defaultValue, const ::std::string &unit="", const ::cras::GetParamOptions<::std::string > &options={}, const ::cras::LogHelper *const logger=nullptr) |
Get the value of the given ROS parameter, falling back to the specified default value, and print out a ROS log message with the loaded values (if specified). More... | |
template<typename ResultType , typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type, ::cras::check_get_param_types< ResultType, ParamServerType > * = nullptr> | |
ResultType | cras::getParam (const ::cras::GetParamAdapter ¶m, const ::std::string &name, const ResultType &defaultValue=ResultType(), const ::std::string &unit="", const ::cras::GetParamOptions< ResultType, ParamServerType > &options={}, const ::cras::LogHelper *const logger=nullptr) |
Get the value of the given ROS parameter, falling back to the specified default value, and print out a ROS log message with the loaded values (if specified). More... | |
inline ::cras::GetParamResult<::std::string > | cras::getParamVerbose (const ::cras::GetParamAdapter ¶m, const ::std::string &name, const ::cras::optional< const char * > &defaultValue, const ::std::string &unit="", const ::cras::GetParamOptions<::std::string > &options={}, const ::cras::LogHelper *const logger=nullptr) |
Get the value of the given ROS parameter, falling back to the specified default value (if not nullopt), and print out a ROS log message with the loaded values (if specified). More... | |
template<typename ResultType , typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type, ::cras::check_get_param_types< ResultType, ParamServerType > * = nullptr> | |
inline ::cras::GetParamResult< ResultType > | cras::getParamVerbose (const ::cras::GetParamAdapter ¶m, const ::std::string &name, const ::cras::optional< ResultType > &defaultValue=ResultType(), const ::std::string &unit="", const ::cras::GetParamOptions< ResultType, ParamServerType > &options={}, const ::cras::LogHelper *const logger=nullptr) |
Get the value of the given ROS parameter, falling back to the specified default value (if not nullopt), and print out a ROS log message with the loaded values (if specified). More... | |
inline ::cras::GetParamResult<::std::string > | cras::getParamVerbose (const ::cras::GetParamAdapter ¶m, const ::std::string &name, const char *defaultValue, const ::std::string &unit="", const ::cras::GetParamOptions<::std::string > &options={}, const ::cras::LogHelper *const logger=nullptr) |
Get the value of the given ROS parameter, falling back to the specified default value, and print out a ROS log message with the loaded values (if specified). More... | |
template<typename ResultType , typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type, ::cras::check_get_param_types< ResultType, ParamServerType > * = nullptr> | |
inline ::cras::GetParamResult< ResultType > | cras::getParamVerbose (const ::cras::GetParamAdapter ¶m, const ::std::string &name, const ResultType &defaultValue=ResultType(), const ::std::string &unit="", const ::cras::GetParamOptions< ResultType, ParamServerType > &options={}, const ::cras::LogHelper *const logger=nullptr) |
Get the value of the given ROS parameter, falling back to the specified default value, and print out a ROS log message with the loaded values (if specified). More... | |
This file provides helper methods easing access to parameters passed to nodes, nodelets and filters.
Definition in file param_utils.hpp.
#define DEFINE_CONVERTING_GET_PARAM | ( | resultType, | |
paramServerType, | |||
defaultUnit, | |||
convertToResultFn | |||
) |
Generate definitions of "specializations" of getParam(Verbose) that use different ResultType and ParamServerType. They will be automatically used when the user requests a parameter of type ResultType. If cras::to_string() cannot convert ResultType to string, you have to declare overload ::cras::to_string(const ResultType&) prior to calling this macro.
resultType | Type of the result values. |
paramServerType | Type of the intermediate values to which XmlRpcValues are converted. |
defaultUnit | The unit to use if the users doesn't pass any. |
convertToResultFn | The ToResultFn to use for parameter conversion. |
cras
namespace. Definition at line 484 of file param_utils.hpp.
#define DEFINE_CONVERTING_GET_PARAM_WITH_CAST | ( | resultType, | |
paramServerType, | |||
defaultUnit | |||
) |
Generate definitions of "specializations" of getParam(Verbose) that use different ResultType and ParamServerType. They will be automatically used when the user requests a parameter of type ResultType. paramServerType is converted to resultType via static_cast.
resultType | Type of the result values. |
paramServerType | Type of the intermediate values to which XmlRpcValues are converted. |
defaultUnit | The unit to use if the users doesn't pass any. |
cras
namespace. Definition at line 525 of file param_utils.hpp.
#define DEFINE_CONVERTING_GET_PARAM_WITH_CONSTRUCTOR | ( | resultType, | |
paramServerType, | |||
defaultUnit | |||
) |
Generate definitions of "specializations" of getParam(Verbose) that use different ResultType and ParamServerType. They will be automatically used when the user requests a parameter of type ResultType. paramServerType is converted to resultType via resultType one-arg constructor.
resultType | Type of the result values. |
paramServerType | Type of the intermediate values to which XmlRpcValues are converted. |
defaultUnit | The unit to use if the users doesn't pass any. |
cras
namespace. Definition at line 512 of file param_utils.hpp.