Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
SurgSim::Framework::AssertMessage Class Reference

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

#include <SurgSim/Framework/AssertMessage.h>

Inheritance diagram for SurgSim::Framework::AssertMessage:
SurgSim::Framework::LogMessageBase

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 >
LogMessageBaseoperator<< (T &&input)
 Add the given input to the current log message. More...
 
LogMessageBaseoperator<< (std::ios_base &(*manipulator)(std::ios_base &))
 
LogMessageBaseoperator<< (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

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

SurgSim::Framework::AssertMessage::AssertMessage ( Logger logger)
inlineexplicit

Constructor.

Parameters
loggerLogger used to log this message.
SurgSim::Framework::AssertMessage::AssertMessage ( const std::unique_ptr< Logger > &  logger)
inlineexplicit

Constructor.

Parameters
loggerLogger used to log this message.
SurgSim::Framework::AssertMessage::AssertMessage ( const std::shared_ptr< Logger > &  logger)
inlineexplicit

Constructor.

Parameters
loggerLogger used to log this message.
SurgSim::Framework::AssertMessage::~AssertMessage ( )
inlinenoexcept

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

C++11 introduced noexcept

Member Function Documentation

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.
void SurgSim::Framework::AssertMessage::killApplication ( const std::string errorMessage)
staticprivate

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

Parameters
errorMessageMessage describing the error (which will be ignored).
static void SurgSim::Framework::AssertMessage::setFailureBehaviorToDeath ( )
inlinestatic

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.

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

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

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

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.

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

Kill the application by throwing an exception.

Parameters
errorMessageMessage describing the error.

Member Data Documentation

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

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: