CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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.

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

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 }
TPRegexp parents
Definition: eve_filter.cc:21
std::vector< TEveElement * >::iterator iter
std::vector< TEveElement * > elements
#define fwLog(_level_)
Definition: fwLog.h:45
void addElement(TEveElement *)

Member Function Documentation

◆ addElement()

void TEveElementIter::addElement ( TEveElement *  element)
private

Definition at line 63 of file TEveElementIter.cc.

References elements, and regexp.

Referenced by TEveElementIter().

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 }
std::vector< TEveElement * > elements

◆ current()

TEveElement * TEveElementIter::current ( )

Definition at line 51 of file TEveElementIter.cc.

References elements, and iter.

Referenced by next(), and reset().

51  {
52  if (iter == elements.end())
53  return nullptr;
54  else
55  return *iter;
56 }
std::vector< TEveElement * >::iterator iter
std::vector< TEveElement * > elements

◆ next()

TEveElement * TEveElementIter::next ( void  )

Definition at line 44 of file TEveElementIter.cc.

References current(), elements, and iter.

44  {
45  if (iter == elements.end())
46  return nullptr;
47  ++iter;
48  return current();
49 }
TEveElement * current()
std::vector< TEveElement * >::iterator iter
std::vector< TEveElement * > elements

◆ reset()

TEveElement * TEveElementIter::reset ( void  )

Definition at line 58 of file TEveElementIter.cc.

References current(), elements, and iter.

58  {
59  iter = elements.begin();
60  return current();
61 }
TEveElement * current()
std::vector< TEveElement * >::iterator iter
std::vector< TEveElement * > elements

◆ size()

unsigned int TEveElementIter::size ( void  )
inline

Definition at line 25 of file TEveElementIter.h.

References elements.

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

25 { return elements.size(); }
std::vector< TEveElement * > elements

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().