registration_utils.h
Go to the documentation of this file.
1 
26 #ifndef REGISTRATION_UTILS_H
27 #define REGISTRATION_UTILS_H
28 
30 
31 namespace pal_statistics
32 {
37 template <typename T>
38 inline IdType customRegister(StatisticsRegistry &registry, const std::string &name, const T * variable,
39  RegistrationsRAII *bookkeeping = NULL, bool enabled = true)
40 {
41  boost::function<double()> funct = [variable] { return static_cast<double>(*variable); };
42  return registry.registerFunction(name, funct, bookkeeping, enabled);
43 }
44 
49 template <>
50 inline IdType customRegister(StatisticsRegistry &registry, const std::string &name, const double * variable,
51  RegistrationsRAII *bookkeeping, bool enabled)
52 {
53  return registry.registerVariable(name, variable, bookkeeping, enabled);
54 }
55 
56 
57 
62 template <typename T>
63 inline IdType customRegister(StatisticsRegistry &registry, const std::string &name,
64  const boost::function<T()> &funct,
65  RegistrationsRAII *bookkeeping = NULL, bool enabled = true)
66 {
67  boost::function<double()> double_funct = [funct] { return static_cast<double>(funct()); };
68  return registry.registerFunction(name, double_funct, bookkeeping, enabled);
69 }
70 
71 
76 template <>
77 inline IdType customRegister(StatisticsRegistry &registry, const std::string &name,
78  const boost::function<double()> &funct,
79  RegistrationsRAII *bookkeeping, bool enabled)
80 {
81  return registry.registerFunction(name, funct, bookkeeping, enabled);
82 }
83 
89 } // namespace pal_statistics
90 
91 #endif // REGISTRATION_UTILS_H
pal_statistics::customRegister
IdType customRegister(StatisticsRegistry &registry, const std::string &name, const T *variable, RegistrationsRAII *bookkeeping=NULL, bool enabled=true)
Default implementation that accepts anything variable that can be casted to a double.
Definition: registration_utils.h:38
pal_statistics::StatisticsRegistry
The StatisticsRegistry class reads the value of registered variables and publishes them on the specif...
Definition: pal_statistics.h:53
pal_statistics.h
pal_statistics
Definition: extract_rosbag_signals.h:14
pal_statistics::StatisticsRegistry::registerVariable
IdType registerVariable(const std::string &name, const double *variable, RegistrationsRAII *bookkeeping=NULL, bool enabled=true)
registerVariable Specialization for double*, the most common case, to avoid going through a boost fun...
Definition: pal_statistics.h:64
pal_statistics::StatisticsRegistry::registerFunction
IdType registerFunction(const std::string &name, const boost::function< double()> &funct, RegistrationsRAII *bookkeeping=NULL, bool enabled=true)
registerFunction Adds a function that returns double with the specified name
Definition: pal_statistics.cpp:44
pal_statistics::RegistrationsRAII
The RegistrationsRAII class holds handles to registered variables and when it is destroyed,...
Definition: pal_statistics_utils.h:117
pal_statistics::IdType
unsigned int IdType
Definition: pal_statistics_utils.h:46


pal_statistics
Author(s):
autogenerated on Fri Aug 2 2024 08:29:35