CbmRoot
Loading...
Searching...
No Matches
CaDefines.h
Go to the documentation of this file.
1/* Copyright (C) 2010-2021 Frankfurt Institute for Advanced Studies, Goethe-Universität Frankfurt, Frankfurt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Maksym Zyzak, Igor Kulakov [committer], Sergey Gorbunov */
4
8
9#pragma once // include this header only once per compilation unit
10
12
13#include <cassert>
14#include <sstream>
15
16// #define CBMCA_DEBUG_MODE
17
18#if defined(CBMCA_DEBUG_MODE)
19
20#define CBMCA_DEBUG_ASSERT(v) \
21 if (!(v)) { \
22 LOG(error) << __FILE__ << ":" << __LINE__ << " assertion failed: " << #v << " = " << (v); \
23 assert(v); \
24 }
25
26#define CBMCA_DEBUG_SHOW(expr) \
27 LOG(info) << __FILE__ << ":" << __LINE__ << ": \033[01;38;5;208m" << (#expr) << "\033[0m = " << (expr);
28
29#define CBMCA_DEBUG_SHOWF(msg) \
30 LOG(info) << "(!) " << __FILE__ << ":" << __LINE__ << ": \033[01;38;5;208m" << (#msg) << "\033[0m";
31
32#define CBMCA_DEBUG_SHOWCONTAINER(cont) \
33 std::stringstream ss; \
34 ss << __FILE__ << ":" << __LINE__ << ": \033[01;38;5;208m" << (#cont) << "\033[0m: "; \
35 std::for_each(cont.cbegin(), cont.cend(), [](const auto& el) { ss << el << " "; }); \
36 LOG(info) << ss.str();
37
38#else // not CBMCA_DEBUG_MODE
39
40#define CBMCA_DEBUG_ASSERT(v)
41
42#define CBMCA_DEBUG_SHOW(expr)
43
44#define CBMCA_DEBUG_SHOWF(msg)
45
46#define CBMCA_DEBUG_SHOWCONTAINER(cont)
47
48#endif // CBMCA_DEBUG_MODE