libcyberradio  22.01.24
Debuggable Class Reference

Class that supports debug output. More...

#include <Debuggable.h>

Inheritance diagram for Debuggable:
Configurable RadioTransport HttpsSession DUCSink FlowControlClient StatusReceiver TransmitPacketizer UdpStatusReceiver SerialPort VitaIqSource

Public Member Functions

 Debuggable (bool debug=false, const std::string &debug_name="", FILE *debug_fp=DEBUG_FP, const std::string &debug_timefmt=DEBUG_TIME_FMT)
 Constructs a Debuggable object. More...
 
virtual ~Debuggable ()
 Destroys a Debuggable object.
 
 Debuggable (const Debuggable &other)
 Copies a Debuggable object. More...
 
Debuggableoperator= (const Debuggable &other)
 Assignment operator for Debuggable objects. More...
 
virtual void setDebugName (const std::string &debug_name)
 Sets the debug name for this object. More...
 
virtual void setDebugFile (FILE *debug_fp)
 Sets the debug file pointer for this object. More...
 
virtual void setDebugTimeFormat (const std::string &debug_timefmt)
 Sets the debug time format for this object. More...
 
virtual int debug (const char *format,...)
 Outputs debug information. More...
 
virtual const char * debugBool (bool x)
 Gets a debug output string for a Boolean value. More...
 
virtual bool isDebug () const
 Gets whether this object produces debug output. More...
 
virtual std::string getDebugName () const
 Gets the debug name for this object. More...
 
virtual std::string rawString (const std::string &data)
 Gets a "raw" string representation of a given data string. More...
 

Detailed Description

Class that supports debug output.

This class is intended to be a mixin for other classes, allowing them to support debug output.

Definition at line 38 of file Debuggable.h.

Constructor & Destructor Documentation

◆ Debuggable() [1/2]

Debuggable ( bool  debug = false,
const std::string &  debug_name = "",
FILE *  debug_fp = DEBUG_FP,
const std::string &  debug_timefmt = DEBUG_TIME_FMT 
)

Constructs a Debuggable object.

Parameters
debugWhether or not to create debug output.
debug_nameName for identifying this object in debug output.
debug_fpFile to send debug output to.
debug_timefmtFormat string for displaying timestamp, as compatible with strftime(). If this is an empty string, don't display a timestamp.

Definition at line 28 of file Debuggable.cpp.

◆ Debuggable() [2/2]

Debuggable ( const Debuggable other)

Copies a Debuggable object.

Parameters
otherThe Debuggable object to copy.

Definition at line 49 of file Debuggable.cpp.

Member Function Documentation

◆ debug()

int debug ( const char *  format,
  ... 
)
virtual

Outputs debug information.

This method follows the same semantics as printf(). Output is preceded by a timestamp and the name of the object, if provided.

Parameters
formatThe printf()-style format string.
...Comma-separated list of arguments to print. Note that these need to be arguments that can be supported natively through printf().
Returns
The number of characters outputted.

Definition at line 95 of file Debuggable.cpp.

◆ debugBool()

const char * debugBool ( bool  x)
virtual

Gets a debug output string for a Boolean value.

Parameters
xBoolean value
Returns
A constant string, either "true" or "false".

Definition at line 126 of file Debuggable.cpp.

◆ getDebugName()

std::string getDebugName ( ) const
virtual

Gets the debug name for this object.

Returns
The debug name, as a string.

Definition at line 138 of file Debuggable.cpp.

◆ isDebug()

bool isDebug ( ) const
virtual

Gets whether this object produces debug output.

Returns
True if producing debug, false otherwise.

Definition at line 133 of file Debuggable.cpp.

◆ operator=()

Debuggable & operator= ( const Debuggable other)

Assignment operator for Debuggable objects.

Parameters
otherThe Debuggable object to copy.
Returns
A reference to the assigned object.

Definition at line 59 of file Debuggable.cpp.

◆ rawString()

std::string rawString ( const std::string &  data)
virtual

Gets a "raw" string representation of a given data string.

"Raw" string representations mimic Python string representations. Whitespace characters are denoted by backslash representations ("\\r", "\\n", "\\t", "\\v", "\\f"), while other non-printable characters are represented with hex representation ("\\x00", etc.)

Parameters
dataData string
Returns
The data's "raw" representation.

Definition at line 143 of file Debuggable.cpp.

◆ setDebugFile()

void setDebugFile ( FILE *  debug_fp)
virtual

Sets the debug file pointer for this object.

Parameters
debug_fpFile to send debug output to.

Definition at line 81 of file Debuggable.cpp.

◆ setDebugName()

void setDebugName ( const std::string &  debug_name)
virtual

Sets the debug name for this object.

Use this method to set unique debug names for objects of the same class for easy differentiation.

Parameters
debug_nameName for identifying this object in debug output.

Definition at line 74 of file Debuggable.cpp.

◆ setDebugTimeFormat()

void setDebugTimeFormat ( const std::string &  debug_timefmt)
virtual

Sets the debug time format for this object.

Parameters
debug_timefmtFormat string for displaying timestamp, as compatible with strftime(). If this is an empty string, don't display a timestamp.

Definition at line 88 of file Debuggable.cpp.


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