DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
include
dbe
convenience.hpp
Go to the documentation of this file.
1
// DUNE DAQ modification notice:
2
// This file has been modified from the original ATLAS dbe source for the DUNE DAQ project.
3
// Fork baseline commit: dbe-02-12-17 (2022-05-12).
4
// Renamed since fork: yes (from dbe/convenience.hpp to include/dbe/convenience.hpp).
5
6
/************************************************************
7
* convenience.hpp *
8
* *
9
* Created on: 1 Mar 2014 *
10
* Author: Leonidas Georgopoulos *
11
*
12
* Copyright (C) 2014 Leonidas Georgopoulos
13
* Distributed under the Boost Software License, Version 1.0.
14
* (See accompanying file LICENSE_1_0.txt or
15
* copy at http://www.boost.org/LICENSE_1_0.txt)
16
*
17
************************************************************/
18
19
#ifndef LUTILS_CONVENIENCE_HPP_
20
#define LUTILS_CONVENIENCE_HPP_
21
22
/*
23
* STL inclusions
24
*/
25
#include <memory>
26
#include <string>
27
#include <typeinfo>
28
29
/*
30
* G++ demangle
31
*/
32
#ifdef __GNUG__
33
#include <cstdlib>
34
#include <cxxabi.h>
35
#endif
36
37
namespace
tools
{
38
//------------------------------------------------------------------------------
42
template
<
typename
T>
43
class
gentraits
44
{
45
public
:
46
typedef
std::string
t_is
;
47
48
static
t_is
constexpr
isnot
();
49
50
static
t_is
constexpr
isa
();
51
52
#ifdef __GNUG__
53
static
t_is
constexpr
filt
();
54
#endif
55
};
56
//------------------------------------------------------------------------------
57
58
//------------------------------------------------------------------------------
64
template
<
typename
T>
65
typename
gentraits<T>::t_is
constexpr
filt
(T*)
66
{
67
return
gentraits<T>::filt
();
68
}
69
//------------------------------------------------------------------------------
70
71
//------------------------------------------------------------------------------
76
template
<
typename
T>
77
typename
gentraits<T>::t_is
constexpr
gentraits<T>::isnot
()
78
{
79
return
t_is
(
"ISNOT"
);
80
}
81
//------------------------------------------------------------------------------
82
83
//------------------------------------------------------------------------------
88
template
<
typename
T>
89
typename
gentraits<T>::t_is
constexpr
gentraits<T>::isa
()
90
{
91
return
typeid
(T).name();
92
}
93
//------------------------------------------------------------------------------
94
95
//------------------------------------------------------------------------------
96
#ifdef __GNUG__
97
template
<
typename
T>
98
typename
gentraits<T>::t_is
constexpr
gentraits<T>::filt
()
99
{
100
int
status = -42;
101
char
* res = abi::__cxa_demangle(
typeid
(T).name(), NULL, NULL, &status);
102
103
if
(status != 0) {
104
::free(res);
105
return
isnot();
106
}
else
{
107
typename
gentraits<T>::t_is
result = res;
108
::free(res);
109
return
result;
110
}
111
}
112
#endif
113
//------------------------------------------------------------------------------
114
115
//------------------------------------------------------------------------------
121
template
<
typename
A,
typename
B>
122
typename
gentraits<A>::t_is
const
123
isa
(B
const
&)
124
{
125
return
typeid
(A).name() ==
typeid
(B).name() ?
typeid
(A).name() :
gentraits<A>::isnot
();
126
}
127
//------------------------------------------------------------------------------
128
129
}
/* namespace tools */
130
131
#endif
tools::gentraits
Definition
convenience.hpp:44
tools::gentraits::t_is
std::string t_is
Definition
convenience.hpp:46
tools::gentraits::isnot
static t_is constexpr isnot()
Definition
convenience.hpp:77
tools::gentraits::isa
static t_is constexpr isa()
Definition
convenience.hpp:89
tools
Definition
convenience.hpp:37
tools::filt
gentraits< T >::t_is constexpr filt(T *)
Definition
convenience.hpp:65
tools::isa
gentraits< A >::t_is const isa(B const &)
Definition
convenience.hpp:123
Generated on
for DUNE-DAQ by
1.18.0