ATLAS Offline Software
Loading...
Searching...
No Matches
Control
PyKernel
PyKernel
PyItPatch.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef PYANALYSISCORE_PYITPATCH_H
6
#define PYANALYSISCORE_PYITPATCH_H
7
8
// An utility class to remove '*' from a class type
9
template
<
class
T>
struct
NonPointer
10
{
11
typedef
T
Type
;
12
};
13
template
<
class
T>
struct
NonPointer
<T *>
14
{
15
typedef
T
Type
;
16
};
17
18
// An utility class to remove 'const' from a class type
19
template
<
class
T>
struct
NonConst
20
{
21
typedef
T
Type
;
22
};
23
template
<
class
T>
struct
NonConst
<
const
T>
24
{
25
typedef
T
Type
;
26
};
27
28
36
template
<
class
IT>
37
struct
PyItPatch
38
{
39
PyItPatch
() :
m_cache
(0) {}
40
PyItPatch
(IT &it) :
m_it
(it)
41
{
42
m_cache
=
new
typename
NonConst<typename NonPointer<typename IT::pointer>::Type
>
::Type
();
43
}
44
virtual
~PyItPatch
() {
if
(
m_cache
!=0)
delete
m_cache
; }
45
46
// next() for python iterator
47
typename
IT::reference
next
()
48
{
49
// this implementation is needed for LCG dict
50
// 'return *m_it++' doesn't compile
51
*
m_cache
= *
m_it
;
52
++
m_it
;
53
return
*
m_cache
;
54
}
55
56
// __eq__() for python iterator
57
bool
eq
(IT & rhs)
58
{
59
return
rhs ==
m_it
;
60
}
61
62
// __ne__() for python iterator
63
bool
ne
(IT & rhs)
64
{
65
return
!
eq
(rhs);
66
}
67
68
private
:
69
IT
m_it
;
70
typename
NonConst<typename NonPointer<typename IT::pointer>::Type
>
::Type
*
m_cache
;
71
};
72
73
#endif
74
Type
RootType Type
Definition
TrigTSerializer.h:33
const
NonConst< const T >::Type
T Type
Definition
PyItPatch.h:25
NonConst
Definition
PyItPatch.h:20
NonConst::Type
T Type
Definition
PyItPatch.h:21
NonPointer< T * >::Type
T Type
Definition
PyItPatch.h:15
NonPointer
Definition
PyItPatch.h:10
NonPointer::Type
T Type
Definition
PyItPatch.h:11
PyItPatch::~PyItPatch
virtual ~PyItPatch()
Definition
PyItPatch.h:44
PyItPatch::eq
bool eq(IT &rhs)
Definition
PyItPatch.h:57
PyItPatch::PyItPatch
PyItPatch(IT &it)
Definition
PyItPatch.h:40
PyItPatch::next
IT::reference next()
Definition
PyItPatch.h:47
PyItPatch::ne
bool ne(IT &rhs)
Definition
PyItPatch.h:63
PyItPatch::m_it
IT m_it
Definition
PyItPatch.h:69
PyItPatch::m_cache
NonConst< typenameNonPointer< typenameIT::pointer >::Type >::Type * m_cache
Definition
PyItPatch.h:70
PyItPatch::PyItPatch
PyItPatch()
Definition
PyItPatch.h:39
Type
Generated on
for ATLAS Offline Software by
1.14.0