DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
ers
include
ers
internal
IssueDeclarationMacro.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/internal/IssueDeclarationMacro.h to include/ers/internal/IssueDeclarationMacro.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
#ifndef ERS_ISSUE_DECLARATION_MACRO_H
13
#define ERS_ISSUE_DECLARATION_MACRO_H
14
15
#include <boost/preprocessor/if.hpp>
16
#include <boost/preprocessor/seq.hpp>
17
#include <boost/preprocessor/tuple.hpp>
18
#include <boost/preprocessor/logical.hpp>
19
#include <boost/preprocessor/stringize.hpp>
20
#include <boost/preprocessor/comparison.hpp>
21
22
#define ERS_EMPTY
23
24
#define ERS_IS_EMPTY(x) ERS_IS_EMPTY_I(ERS_IS_EMPTY_HELPER x)
25
#define ERS_IS_EMPTY_I(contents) ERS_IS_EMPTY_II( contents() )
26
#define ERS_IS_EMPTY_II(contents) ERS_IS_EMPTY_III( contents )
27
#define ERS_IS_EMPTY_III(contents) BOOST_PP_TUPLE_ELEM( 2, 0, ( ERS_IS_EMPTY_DEF_ ## contents ) )
28
#define ERS_IS_EMPTY_HELPER() ERS_IS_EMPTY_TRUE
29
#define ERS_IS_EMPTY_DEF_ERS_IS_EMPTY_TRUE 1 ,
30
#define ERS_IS_EMPTY_DEF_ERS_IS_EMPTY_HELPER 0 ,
31
32
#define ERS_TYPE( tuple ) BOOST_PP_SEQ_HEAD(tuple)
33
#define ERS_NAME( tuple ) BOOST_PP_SEQ_TAIL(tuple)
34
35
#define ERS_ATTRIBUTE_NAME( _, __, tuple ) \
36
, ERS_NAME(tuple)
37
38
#define ERS_ATTRIBUTE_NAME_TYPE( _, __, tuple ) \
39
, ERS_TYPE(tuple) \
40
ERS_NAME(tuple)
41
42
#define ERS_ATTRIBUTE_SERIALIZATION( _, __, tuple ) \
43
set_value( BOOST_PP_STRINGIZE(ERS_NAME(tuple)), \
44
ERS_NAME(tuple) );
45
46
#define ERS_ATTRIBUTE_ACCESSORS( _, __, tuple ) \
47
ERS_TYPE(tuple) \
48
BOOST_PP_CAT( get_, ERS_NAME(tuple) ) () { \
49
ERS_TYPE(tuple) val; \
50
ers::Issue::get_value( BOOST_PP_STRINGIZE(ERS_NAME(tuple)), val ); \
51
return val; \
52
}
53
54
#define ERS_SET_MESSAGE( message ) \
55
std::ostringstream out;\
56
out << message;\
57
prepend_message( out.str() );
58
59
#define ERS_PRINT_LIST( decl, attributes ) \
60
BOOST_PP_SEQ_FOR_EACH( decl, _, attributes )
61
62
#define __ERS_DECLARE_ISSUE_BASE__( namespace_name, class_name, base_class_name, message, base_attributes, attributes ) \
63
namespace namespace_name { \
64
class class_name : public base_class_name { \
65
template <class> friend class ::ers::IssueRegistrator; \
66
protected: \
67
BOOST_PP_EXPR_IF( BOOST_PP_NOT_EQUAL( BOOST_PP_SEQ_SIZE( base_attributes attributes ), 0 ), \
68
class_name( const ers::Context & context ) : base_class_name( context ) { ; } )\
69
static std::list<std::string> _get_inheritance() { \
70
auto chain = base_class_name::_get_inheritance(); \
71
chain.push_back( get_uid() ); \
72
return chain; \
73
} \
74
public: \
75
static const char * get_uid() { return BOOST_PP_STRINGIZE( namespace_name::class_name ); } \
76
class_name( const ers::Context & context \
77
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY base_attributes ) \
78
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY attributes ) ); \
79
class_name( const ers::Context & context, \
80
const std::string & msg \
81
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY base_attributes ) \
82
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY attributes ) ); \
83
class_name( const ers::Context & context, \
84
const std::string & msg \
85
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY base_attributes ) \
86
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY attributes ), \
87
const std::exception & cause ); \
88
class_name( const ers::Context & context \
89
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY base_attributes ) \
90
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY attributes ), \
91
const std::exception & cause ); \
92
void raise() const { throw class_name(*this); } \
93
const char * get_class_name() const { return get_uid(); } \
94
virtual std::list<std::string> get_class_inheritance() const override { return _get_inheritance() ; } \
95
base_class_name * clone() const { return new namespace_name::class_name( *this ); } \
96
ERS_PRINT_LIST( ERS_ATTRIBUTE_ACCESSORS, ERS_EMPTY attributes ) \
97
}; \
98
}
99
100
#define __ERS_DEFINE_ISSUE_BASE__( INLINE, namespace_name, class_name, base_class_name, message, base_attributes, attributes ) \
101
namespace namespace_name { \
102
INLINE class_name::class_name( const ers::Context & context \
103
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY base_attributes ) \
104
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY attributes ) ) \
105
: base_class_name( context ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME, ERS_EMPTY base_attributes ) ) \
106
{ \
107
ERS_PRINT_LIST( ERS_ATTRIBUTE_SERIALIZATION, ERS_EMPTY attributes ) \
108
BOOST_PP_EXPR_IF( BOOST_PP_NOT( ERS_IS_EMPTY( ERS_EMPTY message ) ), ERS_SET_MESSAGE( ERS_EMPTY message ) )\
109
} \
110
\
111
INLINE class_name::class_name( const ers::Context & context, \
112
const std::string & msg \
113
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY base_attributes ) \
114
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY attributes ) ) \
115
: base_class_name( context, msg ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME, ERS_EMPTY base_attributes ) ) \
116
{ \
117
ERS_PRINT_LIST( ERS_ATTRIBUTE_SERIALIZATION, ERS_EMPTY attributes ) \
118
} \
119
\
120
INLINE class_name::class_name( const ers::Context & context, \
121
const std::string & msg \
122
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY base_attributes ) \
123
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY attributes ), \
124
const std::exception & cause ) \
125
: base_class_name( context, msg ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME, ERS_EMPTY base_attributes ), cause ) \
126
{ \
127
ERS_PRINT_LIST( ERS_ATTRIBUTE_SERIALIZATION, ERS_EMPTY attributes ) \
128
} \
129
INLINE class_name::class_name( const ers::Context & context \
130
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY base_attributes ) \
131
ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME_TYPE, ERS_EMPTY attributes ), \
132
const std::exception & cause ) \
133
: base_class_name( context ERS_PRINT_LIST( ERS_ATTRIBUTE_NAME, ERS_EMPTY base_attributes ), cause ) \
134
{ \
135
ERS_PRINT_LIST( ERS_ATTRIBUTE_SERIALIZATION, ERS_EMPTY attributes ) \
136
BOOST_PP_EXPR_IF( BOOST_PP_NOT( ERS_IS_EMPTY( ERS_EMPTY message ) ), ERS_SET_MESSAGE( ERS_EMPTY message ) )\
137
} \
138
} \
139
namespace { \
140
ers::IssueRegistrator<namespace_name::class_name> namespace_name##_##class_name##_instance; \
141
}
142
143
#define ERS_DECLARE_ISSUE_BASE_HPP( namespace_name, class_name, base_class_name, message, base_attributes, attributes ) \
144
__ERS_DECLARE_ISSUE_BASE__( namespace_name, class_name, base_class_name, ERS_EMPTY message, ERS_EMPTY base_attributes, ERS_EMPTY attributes )
145
146
#define ERS_DEFINE_ISSUE_BASE_CXX( namespace_name, class_name, base_class_name, message, base_attributes, attributes ) \
147
__ERS_DEFINE_ISSUE_BASE__( ERS_EMPTY, namespace_name, class_name, base_class_name, ERS_EMPTY message, ERS_EMPTY base_attributes, ERS_EMPTY attributes )
148
149
#define ERS_DECLARE_ISSUE_HPP( namespace_name, class_name, message, attributes ) \
150
ERS_DECLARE_ISSUE_BASE_HPP( namespace_name, class_name, ers::Issue, ERS_EMPTY message, ERS_EMPTY, ERS_EMPTY attributes )
151
152
#define ERS_DEFINE_ISSUE_CXX( namespace_name, class_name, message, attributes ) \
153
ERS_DEFINE_ISSUE_BASE_CXX( namespace_name, class_name, ers::Issue, ERS_EMPTY message, ERS_EMPTY, ERS_EMPTY attributes )
154
155
#define ERS_DECLARE_ISSUE_BASE( namespace_name, class_name, base_class_name, message, base_attributes, attributes ) \
156
__ERS_DECLARE_ISSUE_BASE__( namespace_name, class_name, base_class_name, message, base_attributes, attributes ) \
157
__ERS_DEFINE_ISSUE_BASE__( inline, namespace_name, class_name, base_class_name, message, base_attributes, attributes )
158
159
#define ERS_DECLARE_ISSUE( namespace_name, class_name, message, attributes ) \
160
__ERS_DECLARE_ISSUE_BASE__( namespace_name, class_name, ers::Issue, ERS_EMPTY message, ERS_EMPTY, attributes ) \
161
__ERS_DEFINE_ISSUE_BASE__( inline, namespace_name, class_name, ers::Issue, ERS_EMPTY message, ERS_EMPTY, attributes )
162
163
#endif
Generated on
for DUNE-DAQ by
1.17.0