CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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=0)
 

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 ( TEveElement *  element,
const char *  regular_expression = 0 
)

Definition at line 7 of file TEveElementIter.cc.

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

8 {
9  if ( regular_expression ) 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  {
19  addElement( parents.top().first );
20  parents.pop();
21  if ( !parents.empty() ) ++(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:24
std::vector< TEveElement * >::iterator iter
std::vector< TEveElement * > elements
#define fwLog(_level_)
Definition: fwLog.h:51
void addElement(TEveElement *)

Member Function Documentation

void TEveElementIter::addElement ( TEveElement *  element)
private

Definition at line 65 of file TEveElementIter.cc.

References elements, and regexp.

Referenced by TEveElementIter().

66 {
67  if (!element ) return;
68  TNamed* named = dynamic_cast<TNamed*>(element);
69  if ( named && !regexp.MatchB(named->GetName()) ) return;
70  elements.push_back( element );
71 }
std::vector< TEveElement * > elements
TEveElement * TEveElementIter::current ( )

Definition at line 51 of file TEveElementIter.cc.

References elements, and iter.

Referenced by next(), and reset().

52 {
53  if ( iter == elements.end() )
54  return 0;
55  else
56  return *iter;
57 }
std::vector< TEveElement * >::iterator iter
std::vector< TEveElement * > elements
TEveElement * TEveElementIter::next ( void  )

Definition at line 44 of file TEveElementIter.cc.

References current(), elements, and iter.

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

Definition at line 59 of file TEveElementIter.cc.

References current(), elements, and iter.

60 {
61  iter = elements.begin();
62  return current();
63 }
TEveElement * current()
std::vector< TEveElement * >::iterator iter
std::vector< TEveElement * > elements
unsigned int TEveElementIter::size ( void  )
inline

Definition at line 25 of file TEveElementIter.h.

References elements.

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

Member Data Documentation

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

Definition at line 18 of file TEveElementIter.h.

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

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

Definition at line 19 of file TEveElementIter.h.

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

TPRegexp TEveElementIter::regexp
private

Definition at line 17 of file TEveElementIter.h.

Referenced by addElement(), and TEveElementIter().