CMS 3D CMS Logo

IterWithDict.cc
Go to the documentation of this file.
2 #include <cassert>
3 
4 namespace edm {
5 
7  if (atEnd_) {
8  return;
9  }
10  TObject* obj = iter_.Next();
11  if (obj == nullptr) {
12  atEnd_ = true;
13  }
14  }
15 
16  TIter const& IterWithDictBase::iter() const { return iter_; }
17 
18  IterWithDictBase::IterWithDictBase() : iter_(static_cast<TList*>(nullptr)), atEnd_(true) {
19  // This ctor is used by the framework for the end of a range,
20  // or for any type that does not have a TClass.
21  // An iterator constructed by this ctor must not be used
22  // as the left hand argument of operator!=().
23  }
24 
25  IterWithDictBase::IterWithDictBase(TList* list) : iter_(list), atEnd_(false) {
26  // With a TIter, you must call Next() once to point to the first element.
27  TObject* obj = iter_.Next();
28  if (obj == nullptr) {
29  atEnd_ = true;
30  }
31  }
32 
34  // The special cases are needed because TIter::operator!=()
35  // dereferences a null pointer (i.e. segfaults) if the left hand TIter
36  // was constucted with a nullptr argument (the first constructor above).
37  if (atEnd_ != rhs.atEnd_) {
38  // one iterator at end, but not both
39  return true;
40  }
41  if (atEnd_) {
42  // both iterators at end
43  return false;
44  }
45  // neither iterator at end
46  return iter_ != rhs.iter_;
47  }
48 
49 } // namespace edm
funct::false
false
Definition: Factorize.h:29
edm::IterWithDictBase::iter
TIter const & iter() const
Definition: IterWithDict.cc:16
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::IterWithDictBase::atEnd_
bool atEnd_
Definition: IterWithDict.h:17
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
IterWithDict.h
funct::true
true
Definition: Factorize.h:173
edm::IterWithDictBase
Definition: IterWithDict.h:14
edm::IterWithDictBase::operator!=
bool operator!=(IterWithDictBase const &) const
Definition: IterWithDict.cc:33
edm::IterWithDictBase::advance
void advance()
Definition: IterWithDict.cc:6
edm::IterWithDictBase::iter_
TIter iter_
Definition: IterWithDict.h:16
edm::IterWithDictBase::IterWithDictBase
IterWithDictBase()
Definition: IterWithDict.cc:18