ATLAS Offline Software
Loading...
Searching...
No Matches
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
9template <class T> struct NonPointer
10{
11 typedef T Type;
12};
13template <class T> struct NonPointer<T *>
14{
15 typedef T Type;
16};
17
18// An utility class to remove 'const' from a class type
19template <class T> struct NonConst
20{
21 typedef T Type;
22};
23template <class T> struct NonConst<const T>
24{
25 typedef T Type;
26};
27
28
36template <class IT>
38{
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
68private:
69 IT m_it;
71};
72
73#endif
74
RootType Type
virtual ~PyItPatch()
Definition PyItPatch.h:44
bool eq(IT &rhs)
Definition PyItPatch.h:57
PyItPatch(IT &it)
Definition PyItPatch.h:40
IT::reference next()
Definition PyItPatch.h:47
bool ne(IT &rhs)
Definition PyItPatch.h:63
NonConst< typenameNonPointer< typenameIT::pointer >::Type >::Type * m_cache
Definition PyItPatch.h:70