SurgSim::Framework::AssertMessage Class Reference
Assertions » Internal assertion helpers

An internal message class used for assertion failures. More...

`#include <SurgSim/Framework/AssertMessage.h>`

Inheritance diagram for SurgSim::Framework::AssertMessage:

## Public Types

typedef void(* | DeathCallback) (const std::string &message)
| The type used for the callback function that is triggered after an assertion has failed. More...

## Public Member Functions

| AssertMessage (Logger *logger)
| Constructor. More...
| AssertMessage (const std::unique_ptr< Logger > &logger)
| Constructor. More...
| AssertMessage (const std::shared_ptr< Logger > &logger)
| Constructor. More...
| ~AssertMessage () noexcept(false)
| Destructor, which may throw an exception if the failure behavior does. More...
Public Member Functions inherited from SurgSim::Framework::LogMessageBase
| LogMessageBase (Logger *logger, int level)
| Construct a LogMessage. More...
| ~LogMessageBase ()
| Destructor. More...
template<typename T >
LogMessageBase & | operator<< (T &&input)
| Add the given input to the current log message. More...
LogMessageBase & | operator<< (std::ios_base &(*manipulator)(std::ios_base &))
LogMessageBase & | operator<< (std::ostream &(*manipulator)(std::ostream &))

## Static Public Member Functions

static void | setFailureCallback (DeathCallback callback)
| After an assertion has failed, call some arbitrary function. More...
static DeathCallback | getFailureCallback ()
| Get the callback that will currently be called after an assertion has failed. More...
static void | setFailureBehaviorToThrow ()
| After an assertion has failed, throw a C++ exception. More...
static void | setFailureBehaviorToDeath ()
| After an assertion has failed, enter the debugger or kill the application in a system-dependent way. More...

## Static Private Member Functions

static void | throwException (const std::string &errorMessage)
| Kill the application by throwing an exception. More...
static void | killApplication (const std::string &errorMessage)
| Enter the debugger or kill the application in a system-dependent way. More...

## Static Private Attributes

static DeathCallback | m_killMeNow = AssertMessage::throwException
| The callback function that is triggered after an assertion has failed. More...

## Additional Inherited Members

Protected Member Functions inherited from SurgSim::Framework::LogMessageBase
std::string | getMessage ()
void | flush ()
| write the current message to the logger More...

## Detailed Description

An internal message class used for assertion failures.

Dies after logging.

## Member Typedef Documentation

## DeathCallback

typedef void(* SurgSim::Framework::AssertMessage::DeathCallback) (const std::string &message)

The type used for the callback function that is triggered after an assertion has failed.

## Constructor & Destructor Documentation

## AssertMessage() [1/3]

SurgSim::Framework::AssertMessage::AssertMessage | ( | Logger * | logger | ) |

inline explicit

Constructor.

Parameters

  logger | Logger used to log this message.

## AssertMessage() [2/3]

SurgSim::Framework::AssertMessage::AssertMessage | ( | const std::unique_ptr< Logger > & | logger | ) |

inline explicit

Constructor.

Parameters

  logger | Logger used to log this message.

## AssertMessage() [3/3]

SurgSim::Framework::AssertMessage::AssertMessage | ( | const std::shared_ptr< Logger > & | logger | ) |

inline explicit

Constructor.

Parameters

  logger | Logger used to log this message.

## ~AssertMessage()

SurgSim::Framework::AssertMessage::~AssertMessage | ( |  | ) |

inline noexcept

Destructor, which may throw an exception if the failure behavior does.

C++11 introduced noexcept

## Member Function Documentation

## getFailureCallback()

AssertMessage::DeathCallback SurgSim::Framework::AssertMessage::getFailureCallback | ( |  | ) |

static

Get the callback that will currently be called after an assertion has failed.

Thread-unsafe if called concurrently from multiple threads, or concurrently with a failing assertion.

Returns
  The callback.

## killApplication()

void SurgSim::Framework::AssertMessage::killApplication | ( | const std::string & | errorMessage | ) |

static private

Enter the debugger or kill the application in a system-dependent way.

Parameters

  errorMessage | Message describing the error (which will be ignored).

## setFailureBehaviorToDeath()

static void SurgSim::Framework::AssertMessage::setFailureBehaviorToDeath | ( |  | ) |

inline static

After an assertion has failed, enter the debugger or kill the application in a system-dependent way.

Thread-unsafe if called concurrently from multiple threads, or concurrently with a failing assertion.

## setFailureBehaviorToThrow()

static void SurgSim::Framework::AssertMessage::setFailureBehaviorToThrow | ( |  | ) |

inline static

After an assertion has failed, throw a C++ exception.

Thread-unsafe if called concurrently from multiple threads, or concurrently with a failing assertion.

## setFailureCallback()

void SurgSim::Framework::AssertMessage::setFailureCallback | ( | AssertMessage::DeathCallback | callback | ) |

static

After an assertion has failed, call some arbitrary function.

The callback function should cause the application (or at least the current thread) to terminate.

Thread-unsafe if called concurrently from multiple threads, or concurrently with a failing assertion.

## throwException()

void SurgSim::Framework::AssertMessage::throwException | ( | const std::string & | errorMessage | ) |

static private

Kill the application by throwing an exception.

Parameters

  errorMessage | Message describing the error.

## Member Data Documentation

## m_killMeNow

AssertMessage::DeathCallback SurgSim::Framework::AssertMessage::m_killMeNow = AssertMessage::throwException

static private

The callback function that is triggered after an assertion has failed.

Thread-unsafe if called concurrently from multiple threads.

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

- SurgSim/Framework/AssertMessage.h
- SurgSim/Framework/AssertMessage.cpp