Public Member Functions | List of all members
diagnostic_updater::DiagnosticStatusWrapper Class Reference

Wrapper for the diagnostic_msgs::DiagnosticStatus message that makes it easier to update. More...

#include <DiagnosticStatusWrapper.h>

Inheritance diagram for diagnostic_updater::DiagnosticStatusWrapper:
Inheritance graph
[legend]

Public Member Functions

template<class T >
void add (const std::string &key, const T &val)
 Add a key-value pair. More...
 
template<>
void add (const std::string &key, const bool &b)
 For bool, diagnostic value is "True" or "False". More...
 
void addf (const std::string &key, const char *format,...)
 Add a key-value pair using a format string. More...
 
void clear ()
 Clear the key-value pairs. More...
 
void clearSummary ()
 clears the summary, setting the level to zero and the message to "". More...
 
void mergeSummary (unsigned char lvl, const std::string s)
 Merges a level and message with the existing ones. More...
 
void mergeSummary (const diagnostic_msgs::DiagnosticStatus &src)
 Version of mergeSummary that merges in the summary from another DiagnosticStatus. More...
 
void mergeSummaryf (unsigned char lvl, const char *format,...)
 Formatted version of mergeSummary. More...
 
void summary (unsigned char lvl, const std::string s)
 Fills out the level and message fields of the DiagnosticStatus. More...
 
void summary (const diagnostic_msgs::DiagnosticStatus &src)
 copies the summary from a DiagnosticStatus message More...
 
void summaryf (unsigned char lvl, const char *format,...)
 Formatted version of summary. More...
 

Detailed Description

Wrapper for the diagnostic_msgs::DiagnosticStatus message that makes it easier to update.

This class handles common string formatting and vector handling issues for filling the diagnostic_msgs::DiagnosticStatus message. It is a subclass of diagnostic_msgs::DiagnosticStatus, so it can be passed directly to diagnostic publish calls.

Definition at line 66 of file DiagnosticStatusWrapper.h.

Member Function Documentation

template<class T >
void diagnostic_updater::DiagnosticStatusWrapper::add ( const std::string &  key,
const T &  val 
)
inline

Add a key-value pair.

This method adds a key-value pair. Any type that has a << stream operator can be passed as the second argument. Formatting is done using a std::stringstream.

Parameters
keyKey to be added.
valueValue to be added.

Definition at line 204 of file DiagnosticStatusWrapper.h.

template<>
void diagnostic_updater::DiagnosticStatusWrapper::add ( const std::string &  key,
const bool &  b 
)
inline

For bool, diagnostic value is "True" or "False".

Definition at line 245 of file DiagnosticStatusWrapper.h.

void diagnostic_updater::DiagnosticStatusWrapper::addf ( const std::string &  key,
const char *  format,
  ... 
)
inline

Add a key-value pair using a format string.

This method adds a key-value pair. A format string is used to set the value. The current implementation limits the value to 1000 characters in length.

Definition at line 256 of file DiagnosticStatusWrapper.h.

void diagnostic_updater::DiagnosticStatusWrapper::clear ( )
inline

Clear the key-value pairs.

The values vector containing the key-value pairs is cleared.

Definition at line 228 of file DiagnosticStatusWrapper.h.

void diagnostic_updater::DiagnosticStatusWrapper::clearSummary ( )
inline

clears the summary, setting the level to zero and the message to "".

Definition at line 179 of file DiagnosticStatusWrapper.h.

void diagnostic_updater::DiagnosticStatusWrapper::mergeSummary ( unsigned char  lvl,
const std::string  s 
)
inline

Merges a level and message with the existing ones.

It is sometimes useful to merge two DiagnosticStatus messages. In that case, the key value pairs can be unioned, but the level and summary message have to be merged more intelligently. This function does the merge in an intelligent manner, combining the summary in *this, with the one that is passed in.

The combined level is the greater of the two levels to be merged. If both levels are non-zero (not OK), the messages are combined with a semicolon separator. If only one level is zero, and the other is non-zero, the message for the zero level is discarded. If both are zero, the new message is ignored.

Parameters
lvlNumerical level to of the merged-in summary.
sDescriptive status message for the merged-in summary.

Definition at line 101 of file DiagnosticStatusWrapper.h.

void diagnostic_updater::DiagnosticStatusWrapper::mergeSummary ( const diagnostic_msgs::DiagnosticStatus &  src)
inline

Version of mergeSummary that merges in the summary from another DiagnosticStatus.

Parameters
srcDiagnosticStatus from which to merge the summary.

Definition at line 123 of file DiagnosticStatusWrapper.h.

void diagnostic_updater::DiagnosticStatusWrapper::mergeSummaryf ( unsigned char  lvl,
const char *  format,
  ... 
)
inline

Formatted version of mergeSummary.

This method is identical to mergeSummary, except that the message is an sprintf-style format string.

Parameters
lvlNumerical level to of the merged-in summary.
formatFormat string for the descriptive status message for the merged-in summary.
...Values to be formatted by the format string.

Definition at line 140 of file DiagnosticStatusWrapper.h.

void diagnostic_updater::DiagnosticStatusWrapper::summary ( unsigned char  lvl,
const std::string  s 
)
inline

Fills out the level and message fields of the DiagnosticStatus.

Parameters
lvlNumerical level to assign to this Status (OK, Warn, Err).
sDescriptive status message.

Definition at line 76 of file DiagnosticStatusWrapper.h.

void diagnostic_updater::DiagnosticStatusWrapper::summary ( const diagnostic_msgs::DiagnosticStatus &  src)
inline

copies the summary from a DiagnosticStatus message

Parameters
srcStatusWrapper to copy the summary from.

Definition at line 189 of file DiagnosticStatusWrapper.h.

void diagnostic_updater::DiagnosticStatusWrapper::summaryf ( unsigned char  lvl,
const char *  format,
  ... 
)
inline

Formatted version of summary.

This method is identical to summary, except that the message is an sprintf-style format string.

Parameters
lvlNumerical level to assign to this Status (OK, Warn, Err).
sFormat string for the descriptive status message.
...Values to be formatted by the format string.

Definition at line 163 of file DiagnosticStatusWrapper.h.


The documentation for this class was generated from the following file:


diagnostic_updater
Author(s): Kevin Watts, Brice Rebsamen , Jeremy Leibs, Blaise Gassend
autogenerated on Mon Jun 10 2019 13:06:54