DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
include
dbe
macro.hpp
Go to the documentation of this file.
1
/************************************************************
2
* macro.h *
3
* *
4
* Created on: Sep 14, 2014 *
5
* Author: Leonidas Georgopoulos *
6
*
7
* Copyright (C) 2014 Leonidas Georgopoulos
8
* Distributed under the Boost Software License, Version 1.0.
9
* (See accompanying file LICENSE_1_0.txt or
10
* copy at http://www.boost.org/LICENSE_1_0.txt)
11
*
12
************************************************************/
13
14
#ifndef LUTILS_MACRO_H_
15
#define LUTILS_MACRO_H_
16
17
#include <string>
18
#include "
dbe/convenience.hpp
"
19
20
//------------------------------------------------------------------------------
21
// Messaging macros
22
//------------------------------------------------------------------------------
27
#define HERE_TMPL_DEF(T,funname) \
28
typedef typename ::tools::gentraits<T> t_gentraits_T; \
29
static typename t_gentraits_T::t_is const TYPEA = t_gentraits_T::filt(); \
30
static typename t_gentraits_T::t_is const HERE = #funname + "< " + TYPEA +" >"; \
31
36
#define HERE_AUTO_DEF(funname) \
37
static auto TYPEA = ::tools::filt(this); \
38
static auto HERE = std::string("< ") + TYPEA \
39
+ std::string(" >::") + std::string(#funname); \
40
44
#define HERE_DEF(cn,fn) static char const * const HERE = "< "#cn" >:: "#fn" ";
45
50
#define HERE_FUN_DEF(fn) static char const * const HERE = #fn" ";
51
55
#ifndef RELEASE
56
57
#define ERROR_NOREL(MSG) ERROR(MSG)
58
#define WARN_NOREL(MSG) WARN(MSG)
59
#define INFO_NOREL(MSG) INFO(MSG)
60
#define DEBUG_NOREL(MSG) DEBUG(MSG)
61
62
#else
63
#define ERROR_NOREL(MSG)
64
#define INFO_NOREL(MSG)
65
#define DEBUG_NOREL(MSG)
66
#endif
67
68
//------------------------------------------------------------------------------
69
70
//------------------------------------------------------------------------------
71
// Concurrency macros
72
//------------------------------------------------------------------------------
76
#define CONDITION_STD_SET(cond,lock,var,val) \
77
{ \
78
{ \
79
std::lock_guard<std::mutex> \
80
__LUTILS_CONDITIONAL_SET_GUARD_##cond_##lock_##var__(lock); \
81
var = val; \
82
} \
83
cond.notify_all(); \
84
} \
85
91
#define CONDITION_BOOL_WAIT(cond,lock,var) \
92
\
93
std::unique_lock<std::mutex> \
94
__LUTILS_CONDITIONAL_BOOL_WAIT_GUARD_##cond_##lock_##var__(lock); \
95
try { \
96
cond.wait(__LUTILS_CONDITIONAL_BOOL_WAIT_GUARD_##cond_##lock_##var__, [this]() \
97
{ return var;}); \
98
} catch (...) {\
99
break;\
100
}\
101
108
#define CONDITION_BOOL_WAIT_TRYFUN(cond,lock,var,tryfun) \
109
\
110
std::unique_lock<std::mutex> \
111
__LUTILS_CONDITIONAL_BOOL_WAIT_TRYFUN_GUARD_##cond_##lock_##var__(lock); \
112
try { \
113
cond.wait(__LUTILS_CONDITIONAL_BOOL_WAIT_TRYFUN_GUARD_##cond_##lock_##var__, [this]() \
114
{ return var;}); \
115
} catch (...) {\
116
break;\
117
}\
118
125
#define CONDITION_BOOL_WAIT_FUN(cond,lock,fun) \
126
\
127
std::unique_lock<std::mutex> \
128
__LUTILS_CONDITIONAL_BOOL_WAIT_FUN_GUARD_##cond_##lock_(lock); \
129
try { \
130
cond.wait(__LUTILS_CONDITIONAL_BOOL_WAIT_FUN_GUARD_##cond_##lock_, fun ); \
131
} catch(...) {\
132
break; \
133
}\
134
141
#define CONDITION_BOOL_WAIT_FUN_TRYFUN(cond,lock,fun,tryfun) \
142
\
143
std::unique_lock<std::mutex> \
144
__LUTILS_CONDITIONAL_BOOL_WAIT_FUN_TRYFUN_GUARD_##cond_##lock_(lock); \
145
try { \
146
cond.wait(__LUTILS_CONDITIONAL_BOOL_WAIT_FUN_TRYFUN_GUARD_##cond_##lock_, fun ); \
147
} catch(...) {\
148
tryfun(); \
149
}\
150
//------------------------------------------------------------------------------
151
152
//------------------------------------------------------------------------------
153
// IDE COMPAT MACROS
154
//------------------------------------------------------------------------------
155
// A workaround for eclipse formatter bug when using decltype
156
#define DECLTYPE(x) decltype(x)
157
//------------------------------------------------------------------------------
158
159
//------------------------------------------------------------------------------
160
// VARIABLE ARGUMENTS MACRO COMPAT MACROS
161
//------------------------------------------------------------------------------
162
#define CAT( A, B ) A ## B
163
#define SELECT( NAME, NUM ) CAT( NAME ## _, NUM )
164
165
#define GET_COUNT( _1, _2, _3, _4, _5, _6 , _7, _8, _9, COUNT, ... ) COUNT
166
#define VA_SIZE( ... ) GET_COUNT( __VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1 )
167
168
#define VA_SELECT( NAME, ... ) SELECT( NAME, VA_SIZE(__VA_ARGS__) )(__VA_ARGS__)
169
//------------------------------------------------------------------------------
170
171
172
173
#endif
/* LUTILS_MACRO_H_ */
convenience.hpp
Generated on Sat Jun 28 2025 for DUNE-DAQ by
1.12.0