ATLAS Offline Software
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  {
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;
71 };
72 
73 #endif
74 
NonPointer::Type
T Type
Definition: PyItPatch.h:11
PyItPatch::PyItPatch
PyItPatch()
Definition: PyItPatch.h:39
skel.it
it
Definition: skel.GENtoEVGEN.py:423
PyItPatch::m_cache
NonConst< typename NonPointer< typename IT::pointer >::Type >::Type * m_cache
Definition: PyItPatch.h:70
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
PyItPatch::~PyItPatch
virtual ~PyItPatch()
Definition: PyItPatch.h:44
NonConst< const T >::Type
T Type
Definition: PyItPatch.h:25
Type
RootType Type
Definition: TrigTSerializer.h:30
PyItPatch::ne
bool ne(IT &rhs)
Definition: PyItPatch.h:63
NonPointer< T * >::Type
T Type
Definition: PyItPatch.h:15
PyItPatch
This class provides some pathces for an iterator.
Definition: PyItPatch.h:38
NonConst::Type
T Type
Definition: PyItPatch.h:21
PyItPatch::next
IT::reference next()
Definition: PyItPatch.h:47
PyItPatch::PyItPatch
PyItPatch(IT &it)
Definition: PyItPatch.h:40
PyItPatch::eq
bool eq(IT &rhs)
Definition: PyItPatch.h:57
NonPointer
Definition: PyItPatch.h:10
dq_make_web_display.reference
reference
Definition: dq_make_web_display.py:44
NonConst
Definition: PyItPatch.h:20
PyItPatch::m_it
IT m_it
Definition: PyItPatch.h:69
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
TScopeAdapter
Definition: RootType.h:119