DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Assertion.hpp File Reference
#include <ers/Issue.hpp>
#include <ers/Severity.hpp>
#include <ers/StreamManager.hpp>
Include dependency graph for Assertion.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ERS_INTERNAL_ABORT(_)
 
#define ERS_ASSERT_MSG(expression, message)
 
#define ERS_ASSERT(expression)
 
#define ERS_PRECONDITION(expression)
 
#define ERS_RANGE_CHECK(min, val, max)
 
#define ERS_STRICT_RANGE_CHECK(min, val, max)
 

Macro Definition Documentation

◆ ERS_ASSERT

#define ERS_ASSERT ( expression)
Value:
ERS_ASSERT_MSG( expression, "of bad internal state" )
#define ERS_ASSERT_MSG(expression, message)

◆ ERS_ASSERT_MSG

#define ERS_ASSERT_MSG ( expression,
message )
Value:
{ \
if( !(expression) ) \
{ \
std::ostringstream ers_report_impl_out_buffer; \
ers_report_impl_out_buffer << BOOST_PP_IF( ERS_IS_EMPTY( message ), "of unknown reason", message ); \
std::string reason = ers_report_impl_out_buffer.str(); \
ers::Assertion __issue__( ERS_HERE, #expression, reason.c_str() ); \
ers::StreamManager::instance().report_issue( ers::Fatal, __issue__ ); \
ERS_INTERNAL_ABORT(#expression); \
}}
#define ERS_IS_EMPTY(x)
#define ERS_HERE
@ Fatal
Definition Severity.hpp:26

◆ ERS_INTERNAL_ABORT

#define ERS_INTERNAL_ABORT ( _)
Value:
::abort()

◆ ERS_PRECONDITION

#define ERS_PRECONDITION ( expression)
Value:
ERS_ASSERT_MSG( expression, "of bad external parameter" )

If expression is not true, then an issue of type ers::Asertion is thrown. It should be used to check the parameters, which are passed to functions.

Note
This macro is defined to empty statement if the ERS_NO_DEBUG macro is defined

◆ ERS_RANGE_CHECK

#define ERS_RANGE_CHECK ( min,
val,
max )
Value:
ERS_ASSERT_MSG( (min) <= (val) && (val) <= (max), \
val << " is not in [" << min << "," << max << "] range" )

the following condition

( min <= val ) && ( val <= max )

If this expression is not true, then an issue of type ers::Asertion is thrown.

Note
This macro is defined to empty statement if the ERS_NO_DEBUG macro is defined

◆ ERS_STRICT_RANGE_CHECK

#define ERS_STRICT_RANGE_CHECK ( min,
val,
max )
Value:
ERS_ASSERT_MSG( (min) < (val) && (val) < (max), \
val << " is not in (" << min << "," << max << ") range" )

the following condition

( min < val ) && ( val < max )

If this expression is not true, then an issue of type ers::Asertion is thrown.

Note
This macro is disabled if the ERS_NO_DEBUG macro is defined