DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Assertion.hpp
Go to the documentation of this file.
1/*
2 * Assertion.h
3 * ers
4 *
5 * Created by Matthias Wiesmann on 26.11.04.
6 * Modified by Serguei Kolos on 02.08.05.
7 * Copyright 2004 CERN. All rights reserved.
8 *
9 */
10
15#ifndef ERS_ASSERTION_H
16#define ERS_ASSERTION_H
17
18#include <ers/Issue.hpp>
19#include <ers/Severity.hpp>
20#include <ers/StreamManager.hpp>
21
32 Assertion,
33 "Assertion (" << condition
34 << ") failed because " << reason,
35 ((const char *)condition )
36 ((const char *)reason ) )
37#ifdef __rtems__
38#include <assert.h>
39#define ERS_INTERNAL_ABORT(m) __assert_func (__FILE__, __LINE__, __ASSERT_FUNC, m)
40#else
41#define ERS_INTERNAL_ABORT(_) ::abort()
42#endif
43
46#define ERS_ASSERT_MSG( expression, message ) { \
47if( !(expression) ) \
48{ \
49 std::ostringstream ers_report_impl_out_buffer; \
50 ers_report_impl_out_buffer << BOOST_PP_IF( ERS_IS_EMPTY( message ), "of unknown reason", message ); \
51 std::string reason = ers_report_impl_out_buffer.str(); \
52 ers::Assertion __issue__( ERS_HERE, #expression, reason.c_str() ); \
53 ers::StreamManager::instance().report_issue( ers::Fatal, __issue__ ); \
54 ERS_INTERNAL_ABORT(#expression); \
55}}
56
62#define ERS_ASSERT( expression ) ERS_ASSERT_MSG( expression, "of bad internal state" )
63
69#define ERS_PRECONDITION( expression ) ERS_ASSERT_MSG( expression, "of bad external parameter" )
70
76#define ERS_RANGE_CHECK( min, val, max ) \
77 ERS_ASSERT_MSG( (min) <= (val) && (val) <= (max), \
78 val << " is not in [" << min << "," << max << "] range" )
79
85#define ERS_STRICT_RANGE_CHECK( min, val, max ) \
86 ERS_ASSERT_MSG( (min) < (val) && (val) < (max), \
87 val << " is not in (" << min << "," << max << ") range" )
88
89#endif
90
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)