DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
include
dbe
convenience.hpp
Go to the documentation of this file.
1
/************************************************************
2
* convenience.hpp *
3
* *
4
* Created on: 1 Mar 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_CONVENIENCE_HPP_
15
#define LUTILS_CONVENIENCE_HPP_
16
17
/*
18
* STL inclusions
19
*/
20
#include <memory>
21
#include <string>
22
#include <typeinfo>
23
24
/*
25
* G++ demangle
26
*/
27
#ifdef __GNUG__
28
#include <cstdlib>
29
#include <cxxabi.h>
30
#endif
31
32
namespace
tools
33
{
34
//------------------------------------------------------------------------------
38
template
<
typename
T>
class
gentraits
39
{
40
public
:
41
typedef
std::string
t_is
;
42
43
static
t_is
constexpr
isnot
();
44
45
static
t_is
constexpr
isa
();
46
47
#ifdef __GNUG__
48
static
t_is
constexpr
filt
();
49
#endif
50
};
51
//------------------------------------------------------------------------------
52
53
//------------------------------------------------------------------------------
59
template
<
typename
T>
typename
gentraits<T>::t_is
constexpr
filt
(T *)
60
{
61
return
gentraits<T>::filt
();
62
}
63
//------------------------------------------------------------------------------
64
65
//------------------------------------------------------------------------------
70
template
<
typename
T>
typename
gentraits<T>::t_is
constexpr
gentraits<T>::isnot
()
71
{
72
return
t_is
(
"ISNOT"
);
73
}
74
//------------------------------------------------------------------------------
75
76
//------------------------------------------------------------------------------
81
template
<
typename
T>
typename
gentraits<T>::t_is
constexpr
gentraits<T>::isa
()
82
{
83
return
typeid
(T).name();
84
}
85
//------------------------------------------------------------------------------
86
87
//------------------------------------------------------------------------------
88
#ifdef __GNUG__
89
template
<
typename
T>
typename
gentraits<T>::t_is
constexpr
gentraits<T>::filt
()
90
{
91
int
status = -42;
92
char
*res = abi::__cxa_demangle(
typeid
(T).name(), NULL, NULL, &status);
93
94
if
(status != 0) {
95
::free(res);
96
return
isnot();
97
}
else
{
98
typename
gentraits<T>::t_is
result = res;
99
::free(res);
100
return
result;
101
}
102
}
103
#endif
104
//------------------------------------------------------------------------------
105
106
//------------------------------------------------------------------------------
112
template
<
typename
A,
typename
B>
typename
gentraits<A>::t_is
const
isa
(
113
B
const
&)
114
{
115
return
typeid
(A).name() ==
typeid
(B).name() ?
typeid
(A).name() :
116
gentraits<A>::isnot
();
117
}
118
//------------------------------------------------------------------------------
119
120
}
/* namespace tools */
121
122
#endif
tools::gentraits
Definition
convenience.hpp:39
tools::gentraits::isnot
static t_is constexpr isnot()
Definition
convenience.hpp:70
tools::gentraits::isa
static t_is constexpr isa()
Definition
convenience.hpp:81
tools::gentraits::t_is
std::string t_is
Definition
convenience.hpp:41
tools
Definition
convenience.hpp:33
tools::filt
gentraits< T >::t_is constexpr filt(T *)
Definition
convenience.hpp:59
tools::isa
gentraits< A >::t_is const isa(B const &)
Definition
convenience.hpp:112
Generated on Sat Jun 28 2025 for DUNE-DAQ by
1.12.0