ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDMaker
D3PDMakerRoot
src
FakeProxy.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// $Id: FakeProxy.cxx 487276 2012-03-08 11:04:56Z krasznaa $
6
7
// ROOT include(s):
8
#include <TClass.h>
9
#include <TROOT.h>
10
11
// Gaudi/Athena include(s):
12
#include "
AthenaKernel/errorcheck.h
"
13
14
// Local include(s):
15
#include "
FakeProxy.h
"
16
17
namespace
D3PD
{
18
28
FakeProxy::FakeProxy
(
void
*
object
,
const
std::type_info& ti )
29
:
m_clearType
(
ZERO
),
m_object
( object ),
m_type
( ti ),
30
m_clear
(),
m_dict
( 0 ) {
31
32
// Handle the case when it's an object that we received:
33
m_dict
=
getClass
(
m_type
);
34
if
(
m_dict
) {
35
// Check if there is a "clear" function defined for this object:
36
TMethodCall method(
m_dict
,
"clear"
,
""
);
37
if
( method.IsValid() ) {
38
m_clearType
=
CLEAR
;
39
m_clear
= method;
40
}
41
}
42
}
43
48
FakeProxy::~FakeProxy
() {
49
50
if
(
m_dict
&&
m_object
) {
51
m_dict
->Destructor(
m_object
);
52
}
else
if
(
m_object
) {
53
deletePrimitive
(
m_object
,
m_type
);
54
}
55
}
56
61
void
FakeProxy::clear
() {
62
63
// Execute the clear function if it is defined:
64
if
(
m_clearType
==
CLEAR
) {
65
m_clear
.Execute(
m_object
);
66
}
67
68
return
;
69
}
70
79
::TClass*
FakeProxy::getClass
(
const
std::type_info& ti ) {
80
81
TClass* cls = gROOT->GetClass( ti );
82
if
( ! cls ) {
83
cls = gROOT->GetClass( System::typeinfoName( ti ).c_str() );
84
}
85
86
if
( ! cls ) {
87
REPORT_MESSAGE_WITH_CONTEXT
( MSG::DEBUG,
"D3PD::FakeProxy"
)
88
<<
"Can't find class for typeinfo "
<< ti.name();
89
}
90
91
return
cls;
92
}
93
101
void
*
FakeProxy::newPrimitive
(
const
std::type_info& ti ) {
102
103
if
( ti ==
typeid
(
bool
) ) {
104
return
new
bool;
105
}
else
if
( ti ==
typeid
(
char
) ) {
106
return
new
char;
107
}
else
if
( ti ==
typeid
(
short
) ) {
108
return
new
short;
109
}
else
if
( ti ==
typeid
(
unsigned
short
) ) {
110
return
new
unsigned
short;
111
}
else
if
( ti ==
typeid
(
int
) ) {
112
return
new
int;
113
}
else
if
( ti ==
typeid
(
unsigned
int
) ) {
114
return
new
unsigned
int;
115
}
else
if
( ti ==
typeid
(
long
) ) {
116
return
new
long;
117
}
else
if
( ti ==
typeid
(
unsigned
long
) ) {
118
return
new
unsigned
long;
119
}
else
if
( ti ==
typeid
(
unsigned
long
long
) ) {
120
return
new
unsigned
long
long;
121
}
else
if
( ti ==
typeid
(
float
) ) {
122
return
new
float;
123
}
else
if
( ti ==
typeid
(
double
) ) {
124
return
new
double;
125
}
126
127
REPORT_MESSAGE_WITH_CONTEXT
( MSG::WARNING,
"D3PD::FakeProxy"
)
128
<<
"Type '"
<< ti.name() <<
"' is not a known primitive"
;
129
130
return
0;
131
}
132
140
void
FakeProxy::deletePrimitive
(
void
* ptr,
const
std::type_info& ti ) {
141
142
if
( ti ==
typeid
(
bool
) ) {
143
delete
reinterpret_cast<
bool
*
>
( ptr );
144
}
else
if
( ti ==
typeid
(
char
) ) {
145
delete
reinterpret_cast<
char
*
>
( ptr );
146
}
else
if
( ti ==
typeid
(
short
) ) {
147
delete
reinterpret_cast<
short
*
>
( ptr );
148
}
else
if
( ti ==
typeid
(
unsigned
short
) ) {
149
delete
reinterpret_cast<
unsigned
short
*
>
( ptr );
150
}
else
if
( ti ==
typeid
(
int
) ) {
151
delete
reinterpret_cast<
int
*
>
( ptr );
152
}
else
if
( ti ==
typeid
(
unsigned
int
) ) {
153
delete
reinterpret_cast<
unsigned
int
*
>
( ptr );
154
}
else
if
( ti ==
typeid
(
long
) ) {
155
delete
reinterpret_cast<
long
*
>
( ptr );
156
}
else
if
( ti ==
typeid
(
unsigned
long
) ) {
157
delete
reinterpret_cast<
unsigned
long
*
>
( ptr );
158
}
else
if
( ti ==
typeid
(
unsigned
long
long
) ) {
159
delete
reinterpret_cast<
unsigned
long
long
*
>
( ptr );
160
}
else
if
( ti ==
typeid
(
float
) ) {
161
delete
reinterpret_cast<
float
*
>
( ptr );
162
}
else
if
( ti ==
typeid
(
double
) ) {
163
delete
reinterpret_cast<
double
*
>
( ptr );
164
}
else
{
165
REPORT_MESSAGE_WITH_CONTEXT
( MSG::WARNING,
"D3PD::FakeProxy"
)
166
<<
"Couldn't delete type: "
<< ti.name() <<
"; There is a mistake "
167
<<
"in the code!"
;
168
}
169
170
return
;
171
}
172
173
}
// namespace D3PD
errorcheck.h
Helpers for checking error return status codes and reporting errors.
REPORT_MESSAGE_WITH_CONTEXT
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:345
FakeProxy.h
D3PD::FakeProxy::deletePrimitive
static void deletePrimitive(void *ptr, const std::type_info &ti)
Delete a primitive.
Definition
FakeProxy.cxx:140
D3PD::FakeProxy::m_object
void * m_object
The owned object.
Definition
FakeProxy.h:65
D3PD::FakeProxy::~FakeProxy
~FakeProxy()
Destructor deleting the encapsulated object.
Definition
FakeProxy.cxx:48
D3PD::FakeProxy::clear
void clear()
Clear the contents of this variable.
Definition
FakeProxy.cxx:61
D3PD::FakeProxy::m_dict
::TClass * m_dict
Dictionary for class types.
Definition
FakeProxy.h:68
D3PD::FakeProxy::m_type
const std::type_info & m_type
The type of the owned object.
Definition
FakeProxy.h:66
D3PD::FakeProxy::newPrimitive
static void * newPrimitive(const std::type_info &ti)
Create a new instance of a primitive.
Definition
FakeProxy.cxx:101
D3PD::FakeProxy::m_clearType
ClearType m_clearType
The variable clearing type for this object.
Definition
FakeProxy.h:63
D3PD::FakeProxy::getClass
::TClass * getClass(const std::type_info &ti)
Access the dictionary of a specific object.
Definition
FakeProxy.cxx:79
D3PD::FakeProxy::ZERO
@ ZERO
Clear the variable by filling it with zeroes.
Definition
FakeProxy.h:60
D3PD::FakeProxy::CLEAR
@ CLEAR
Clear the variable by calling clear() on it.
Definition
FakeProxy.h:61
D3PD::FakeProxy::FakeProxy
FakeProxy(void *object, const std::type_info &ti)
Constructor taking ownership of an object.
Definition
FakeProxy.cxx:28
D3PD::FakeProxy::m_clear
::TMethodCall m_clear
Method calling clear on the object.
Definition
FakeProxy.h:67
D3PD
Block filler tool for noisy FEB information.
Definition
CaloCellDetailsFillerTool.cxx:29
Generated on
for ATLAS Offline Software by
1.17.0