Skip to content
Snippets Groups Projects
Commit e1583f36 authored by Sergei Zharko's avatar Sergei Zharko
Browse files

L1Algo core: featuring L1Assert

parent 61a9f408
No related branches found
No related tags found
1 merge request!796L1Algo interface and tools: updates
......@@ -37,7 +37,16 @@ class L1AlgoDraw;
//#define MERGE_CLONES
/*********************************************************************************
************ TEMPORARY MACROS, SHOULD BE REMOVED (TODO!!, S. Zharko) ***********
* */
#define FEATURING_L1ALGO_INIT 1 // If defined, new initialization will be used, if not - the old one
// Macro: 1 - new track finder loop, other - old track finder loop
#define FEATURING_L1ALGO_CATRACKFINDER_ITERATIONLOOP 1
/* *
*********************************************************************************/
#include <array>
#include <iomanip>
......
/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Sergey Gorbunov, Sergei Zharko [committer] */
/// @file L1Assert.h
/// @author Sergei Zharko
/// @date 22.02.2022
/// @brief Level-defined assertion functionality
///
/// This file provides level-dependent assertion mechanism. Two defined macros L1ASSERT(LEVEL, COND)
/// and L1MASSERT(LEVEL, COND, MSG), which will do the assertion for LEVEL >= L1Assert::kAssertionLevel
/// and skip it otherwise. When L1ASSERT(LEVEL, COND) is called the COND expression is printed on the screen.
/// When L
#ifndef L1Assert_h
#define L1Assert_h 1
#include "FairLogger.h"
#if defined(NDEBUG) || defined(L1_NO_ASSERT)
#define L1ASSERT(LEVEL, COND)
#define L1MASSERT(LEVEL, COND, MSG)
#else
#define L1ASSERT(LEVEL, COND) L1Assert::DoAssertion<(LEVEL) >= L1Assert::kAssertionLevel>((LEVEL), (COND), (#COND), __FILE__, __LINE__)
#define L1MASSERT(LEVEL, COND, MSG) L1Assert::DoAssertion<(LEVEL) >= L1Assert::kAssertionLevel>((LEVEL), (COND), (MSG), __FILE__, __LINE__)
#endif // defined(NDEBUG) || defined(L1_NO_ASSERT)
namespace L1Assert {
constexpr int kAssertionLevel {1};
/// Basic template function. Usage: place "level >= L1Assert::kAssertionLevel"
template <bool IsAsserted>
int DoAssertion (int level, bool condition, const char* msg, const char* fileName, int lineNo);
/// Specialization in case of IsAsserted = true, i.e. the assertion is made
template <>
int DoAssertion<true>(int level, bool condition, const char* msg, const char* fileName, int lineNo)
{
if (!condition) {
LOG(fatal) << "Level " << level << " assertion failed: " << msg << " (" << fileName << " : " << lineNo << ")\n";
//std::abort(); // Do we need it with LOG(fatal)?
}
return 1;
}
/// Specialization in case of IsAsserted = false, i.e. the assertion is not made
template <>
int DoAssertion<false>(int level, bool condition, const char* msg, const char* fileName, int lineNo) { return 0 };
};
#endif // L1Assert_h
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment