DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Assertion.hpp
Go to the documentation of this file.
1/*
2 * DUNE DAQ modification notice:
3 * This file has been modified from the original ATLAS ers source for the DUNE DAQ project.
4 * Fork baseline commit: 8267df82a4f6fe6bf02c4014923eba19eddc4614 (2020-04-14).
5 * Renamed since fork: yes (from ers/Assertion.h to include/ers/Assertion.hpp).
6 *
7 * Original copyright:
8 * Copyright (C) 2001-2020 CERN for the benefit of the ATLAS collaboration.
9 * Licensed under the Apache License, Version 2.0.
10 */
11
12/*
13 * Assertion.h
14 * ers
15 *
16 * Created by Matthias Wiesmann on 26.11.04.
17 * Modified by Serguei Kolos on 02.08.05.
18 * Copyright 2004 CERN. All rights reserved.
19 *
20 */
21
25
26#ifndef ERS_ASSERTION_H
27#define ERS_ASSERTION_H
28
29#include <ers/Issue.hpp>
30#include <ers/Severity.hpp>
31#include <ers/StreamManager.hpp>
32
41
43 Assertion,
44 "Assertion (" << condition
45 << ") failed because " << reason,
46 ((const char *)condition )
47 ((const char *)reason ) )
48#ifdef __rtems__
49#include <assert.h>
50#define ERS_INTERNAL_ABORT(m) __assert_func (__FILE__, __LINE__, __ASSERT_FUNC, m)
51#else
52#define ERS_INTERNAL_ABORT(_) ::abort()
53#endif
54
57#define ERS_ASSERT_MSG( expression, message ) { \
58if( !(expression) ) \
59{ \
60 std::ostringstream ers_report_impl_out_buffer; \
61 ers_report_impl_out_buffer << BOOST_PP_IF( ERS_IS_EMPTY( message ), "of unknown reason", message ); \
62 std::string reason = ers_report_impl_out_buffer.str(); \
63 ers::Assertion __issue__( ERS_HERE, #expression, reason.c_str() ); \
64 ers::StreamManager::instance().report_issue( ers::Fatal, __issue__ ); \
65 ERS_INTERNAL_ABORT(#expression); \
66}}
67
73#define ERS_ASSERT( expression ) ERS_ASSERT_MSG( expression, "of bad internal state" )
74
80#define ERS_PRECONDITION( expression ) ERS_ASSERT_MSG( expression, "of bad external parameter" )
81
87#define ERS_RANGE_CHECK( min, val, max ) \
88 ERS_ASSERT_MSG( (min) <= (val) && (val) <= (max), \
89 val << " is not in [" << min << "," << max << "] range" )
90
96#define ERS_STRICT_RANGE_CHECK( min, val, max ) \
97 ERS_ASSERT_MSG( (min) < (val) && (val) < (max), \
98 val << " is not in (" << min << "," << max << ") range" )
99
100#endif
101
#define ERS_DECLARE_ISSUE( namespace_name, class_name, message_, attributes)
Definition macro.hpp:65