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 << ") failed because " << reason,
45 ((const char*)condition)((const char*)reason))
46#ifdef __rtems__
47#include <assert.h>
48#define ERS_INTERNAL_ABORT(m) __assert_func(__FILE__, __LINE__, __ASSERT_FUNC, m)
49#else
50#define ERS_INTERNAL_ABORT(_) ::abort()
51#endif
52
55#define ERS_ASSERT_MSG(expression, message) \
56 { \
57 if (!(expression)) { \
58 std::ostringstream ers_report_impl_out_buffer; \
59 ers_report_impl_out_buffer << BOOST_PP_IF(ERS_IS_EMPTY(message), "of unknown reason", message); \
60 std::string reason = ers_report_impl_out_buffer.str(); \
61 ers::Assertion __issue__(ERS_HERE, #expression, reason.c_str()); \
62 ers::StreamManager::instance().report_issue(ers::Fatal, __issue__); \
63 ERS_INTERNAL_ABORT(#expression); \
64 } \
65 }
66
72#define ERS_ASSERT(expression) ERS_ASSERT_MSG(expression, "of bad internal state")
73
79#define ERS_PRECONDITION(expression) ERS_ASSERT_MSG(expression, "of bad external parameter")
80
86#define ERS_RANGE_CHECK(min, val, max) \
87 ERS_ASSERT_MSG((min) <= (val) && (val) <= (max), val << " is not in [" << min << "," << max << "] range")
88
94#define ERS_STRICT_RANGE_CHECK(min, val, max) \
95 ERS_ASSERT_MSG((min) < (val) && (val) < (max), val << " is not in (" << min << "," << max << ") range")
96
97#endif
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message_, attributes)
Definition macro.hpp:71