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
{
39
//------------------------------------------------------------------------------
43
template
<
typename
T>
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>
typename
gentraits<T>::t_is
constexpr
filt
(T *)
65
{
66
return
gentraits<T>::filt
();
67
}
68
//------------------------------------------------------------------------------
69
70
//------------------------------------------------------------------------------
75
template
<
typename
T>
typename
gentraits<T>::t_is
constexpr
gentraits<T>::isnot
()
76
{
77
return
t_is
(
"ISNOT"
);
78
}
79
//------------------------------------------------------------------------------
80
81
//------------------------------------------------------------------------------
86
template
<
typename
T>
typename
gentraits<T>::t_is
constexpr
gentraits<T>::isa
()
87
{
88
return
typeid
(T).name();
89
}
90
//------------------------------------------------------------------------------
91
92
//------------------------------------------------------------------------------
93
#ifdef __GNUG__
94
template
<
typename
T>
typename
gentraits<T>::t_is
constexpr
gentraits<T>::filt
()
95
{
96
int
status = -42;
97
char
*res = abi::__cxa_demangle(
typeid
(T).name(), NULL, NULL, &status);
98
99
if
(status != 0) {
100
::free(res);
101
return
isnot();
102
}
else
{
103
typename
gentraits<T>::t_is
result = res;
104
::free(res);
105
return
result;
106
}
107
}
108
#endif
109
//------------------------------------------------------------------------------
110
111
//------------------------------------------------------------------------------
117
template
<
typename
A,
typename
B>
typename
gentraits<A>::t_is
const
isa
(
118
B
const
&)
119
{
120
return
typeid
(A).name() ==
typeid
(B).name() ?
typeid
(A).name() :
121
gentraits<A>::isnot
();
122
}
123
//------------------------------------------------------------------------------
124
125
}
/* namespace tools */
126
127
#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:75
tools::gentraits::isa
static t_is constexpr isa()
Definition
convenience.hpp:86
tools
Definition
convenience.hpp:38
tools::filt
gentraits< T >::t_is constexpr filt(T *)
Definition
convenience.hpp:64
tools::isa
gentraits< A >::t_is const isa(B const &)
Definition
convenience.hpp:117
Generated on
for DUNE-DAQ by
1.17.0