CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TEveElementIter Class Reference

#include <TEveElementIter.h>

Public Member Functions

TEveElement * current ()
 
TEveElement * next ()
 
TEveElement * reset ()
 
unsigned int size ()
 
 TEveElementIter (TEveElement *, const char *regular_expression=nullptr)
 

Private Member Functions

void addElement (TEveElement *)
 

Private Attributes

std::vector< TEveElement * > elements
 
std::vector< TEveElement * >::iterator iter
 
TPRegexp regexp
 

Detailed Description

Definition at line 15 of file TEveElementIter.h.

Constructor & Destructor Documentation

◆ TEveElementIter()

TEveElementIter::TEveElementIter ( TEveElement *  element,
const char *  regular_expression = nullptr 
)

Definition at line 7 of file TEveElementIter.cc.

7  {
8  if (regular_expression)
9  regexp = TPRegexp(regular_expression);
10  std::stack<std::pair<TEveElement*, TEveElement::List_i> > parents;
11  parents.push(std::pair<TEveElement*, TEveElement::List_i>(element, element->BeginChildren()));
12 
13  unsigned int index = 0; // index number to prevent endless loops
14  unsigned int indexLimit = 1000000;
15  while (!parents.empty() && ++index < indexLimit) {
16  // take care of finished loop
17  if (parents.top().second == parents.top().first->EndChildren()) {
18  addElement(parents.top().first);
19  parents.pop();
20  if (!parents.empty())
21  ++(parents.top().second);
22  continue;
23  }
24 
25  // find element without children
26  if ((*parents.top().second)->NumChildren() > 0) {
27  parents.push(std::pair<TEveElement*, TEveElement::List_i>(*(parents.top().second),
28  (*parents.top().second)->BeginChildren()));
29  continue;
30  }
31 
32  // we have a leaf element (no children) to process
33  addElement(*(parents.top().second));
34  ++(parents.top().second);
35  }
36  if (index >= indexLimit) {
37  fwLog(fwlog::kError) << " tree loop limit is reached!\n"
38  << "You either have a tree with loops or navigation logic is broken." << std::endl;
39  elements.clear();
40  }
41  iter = elements.begin();
42 }

References addElement(), elements, fwLog, iter, fwlog::kError, parents, and regexp.

Member Function Documentation

◆ addElement()

void TEveElementIter::addElement ( TEveElement *  element)
private

Definition at line 63 of file TEveElementIter.cc.

63  {
64  if (!element)
65  return;
66  TNamed* named = dynamic_cast<TNamed*>(element);
67  if (named && !regexp.MatchB(named->GetName()))
68  return;
69  elements.push_back(element);
70 }

References elements, and regexp.

Referenced by TEveElementIter().

◆ current()

TEveElement * TEveElementIter::current ( )

Definition at line 51 of file TEveElementIter.cc.

51  {
52  if (iter == elements.end())
53  return nullptr;
54  else
55  return *iter;
56 }

References elements, and iter.

Referenced by next(), and reset().

◆ next()

TEveElement * TEveElementIter::next ( void  )

Definition at line 44 of file TEveElementIter.cc.

44  {
45  if (iter == elements.end())
46  return nullptr;
47  ++iter;
48  return current();
49 }

References current(), elements, and iter.

◆ reset()

TEveElement * TEveElementIter::reset ( void  )

Definition at line 58 of file TEveElementIter.cc.

58  {
59  iter = elements.begin();
60  return current();
61 }

References current(), elements, and iter.

◆ size()

unsigned int TEveElementIter::size ( void  )
inline

Definition at line 25 of file TEveElementIter.h.

25 { return elements.size(); }

References elements.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

Member Data Documentation

◆ elements

std::vector<TEveElement*> TEveElementIter::elements
private

Definition at line 17 of file TEveElementIter.h.

Referenced by addElement(), current(), next(), reset(), size(), and TEveElementIter().

◆ iter

std::vector<TEveElement*>::iterator TEveElementIter::iter
private

Definition at line 18 of file TEveElementIter.h.

Referenced by current(), next(), reset(), and TEveElementIter().

◆ regexp

TPRegexp TEveElementIter::regexp
private

Definition at line 16 of file TEveElementIter.h.

Referenced by addElement(), and TEveElementIter().

fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
TEveElementIter::addElement
void addElement(TEveElement *)
Definition: TEveElementIter.cc:63
TEveElementIter::elements
std::vector< TEveElement * > elements
Definition: TEveElementIter.h:17
TEveElementIter::regexp
TPRegexp regexp
Definition: TEveElementIter.h:16
TEveElementIter::iter
std::vector< TEveElement * >::iterator iter
Definition: TEveElementIter.h:18
TEveElementIter::current
TEveElement * current()
Definition: TEveElementIter.cc:51
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
fwlog::kError
Definition: fwLog.h:35
parents
TPRegexp parents
Definition: eve_filter.cc:21