CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
DDQuery Class Reference

Base class for querying for nodes in the DDExpandedView. More...

#include <DDQuery.h>

Public Member Functions

virtual void addFilter (const DDFilter &)
 
 DDQuery (const DDCompactView &)
 sets up a query More...
 
virtual const std::vector< DDExpandedNode > & exec ()
 
virtual void setScope (const DDScope &)
 
virtual ~DDQuery ()
 

Protected Attributes

std::vector< std::pair< bool, DDFilter * > > criteria_
 
DDExpandedView epv_
 
std::vector< DDExpandedNoderesult_
 
const DDScopescope_
 

Detailed Description

Base class for querying for nodes in the DDExpandedView.

Definition at line 17 of file DDQuery.h.

Constructor & Destructor Documentation

DDQuery::DDQuery ( const DDCompactView cpv)

sets up a query

Definition at line 10 of file DDQuery.cc.

11  : epv_(cpv), scope_(0)
12 { }
const DDScope * scope_
Definition: DDQuery.h:33
DDExpandedView epv_
Definition: DDQuery.h:32
DDQuery::~DDQuery ( )
virtual

Definition at line 15 of file DDQuery.cc.

16 { }

Member Function Documentation

void DDQuery::addFilter ( const DDFilter f)
virtual

the standard DDQuery only support one single filter. Memory management of DDFilter* is NOT delegated to DDQuery

Definition at line 22 of file DDQuery.cc.

References criteria_, and f.

23 {
24  // cheating a bit with const ....
25  // Filters have a non-const ::accept(..) member function to allow
26  // a possible internal state change in a particular filter implementation ...
27  DDFilter * nonConstFilter = const_cast<DDFilter *>(&f);
28  criteria_.push_back(std::make_pair(false,nonConstFilter));
29 }
double f[11][100]
A Filter accepts or rejects a DDExpandedNode based on a user-coded decision rule. ...
Definition: DDFilter.h:16
std::vector< std::pair< bool, DDFilter * > > criteria_
Definition: DDQuery.h:35
const std::vector< DDExpandedNode > & DDQuery::exec ( )
virtual

Definition at line 38 of file DDQuery.cc.

References DDFilter::accept(), begin, criteria_, particleFlowClusterECALTimeSelected_cfi::depth, DDScope::depth(), end, epv_, ALCARECOTkAlBeamHalo_cff::filter, DDExpandedView::geoHistory(), DDExpandedView::next(), DDExpandedView::reset(), mps_fire::result, result_, findQualityFiles::run, SimDataFormats::CaloAnalysis::sc, DDScope::scope(), scope_, DDExpandedView::setScope(), and DDExpandedView::specifics().

39 {
40  result_.clear();
41  epv_.reset();
42 
43  // currently at least one filter must be set, because
44  // the query simply consists in applying at least one filter!
45  if(criteria_.size()) { // <- remove the 'if' when implementing 'the QUERY'
46  int depth = 0;
47  bool scoped = false;
49  DDScope::scope_type::const_iterator it = dummy.begin();
50  DDScope::scope_type::const_iterator it_end = dummy.end();
51  if (scope_) {
52  const DDScope & sc = *scope_;
53  it = sc.scope().begin();
54  depth = sc.depth();
55  scoped = bool(sc.scope().end()-it);
56  }
57 
58  bool runonce = scoped ? false : true;
59 
60  while (runonce || (it != it_end) ) {
61  if (scoped) epv_.setScope(*it,depth); // set the subtree-scope & depth within
62  bool run = true;
63  while(run) {
64  std::vector<const DDsvalues_type *> specs = epv_.specifics();
65  // loop over all user-supplied criteria (==filters)
66  bool result=true;
67  for( auto it = begin(criteria_); it != end(criteria_); ++it) {
68  DDFilter * filter = it->second;
69  if (filter->accept(epv_)) {
70  it->first=true;
71  }
72  else {
73  it->first=false;
74  }
75 
76  result &= it->first;
77  if(! result) {
78  break;
79  }
80  } // <-- loop over filters
81  if (result) {
82  // HERE THE ACTUAL QUERY SHOULD BE INVOKED!!!
83  result_.push_back(epv_.geoHistory().back());
84  }
85  //} <-- loop over std::vector of specifics_type ...
86  run = epv_.next();
87  }
88  if (scoped)
89  ++it;
90  else
91  runonce=false;
92  }
93  }
94  return result_;
95 }
bool next()
set current node to the next node in the expanded tree
std::vector< const DDsvalues_type * > specifics() const
User specific data attached to the current node.
std::vector< DDExpandedNode > result_
Definition: DDQuery.h:36
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
std::vector< DDGeoHistory > scope_type
Definition: DDScope.h:33
int depth(void) const
return the depth to wich the subtrees are restricted
Definition: DDScope.cc:108
const DDScope * scope_
Definition: DDQuery.h:33
#define end
Definition: vmac.h:37
bool setScope(const DDGeoHistory &hist, int depth=0)
sets the scope of the expanded view
defines subtrees in the expanded-view
Definition: DDScope.h:28
void reset()
true, if a call to firstChild() would succeed (current node has at least one child) ...
DDExpandedView epv_
Definition: DDQuery.h:32
#define begin
Definition: vmac.h:30
A Filter accepts or rejects a DDExpandedNode based on a user-coded decision rule. ...
Definition: DDFilter.h:16
std::vector< std::pair< bool, DDFilter * > > criteria_
Definition: DDQuery.h:35
virtual bool accept(const DDExpandedView &) const =0
true, if the DDExpandedNode fulfills the filter criteria
const scope_type & scope(void) const
returns the scope container
Definition: DDScope.cc:114
void DDQuery::setScope ( const DDScope s)
virtual

Definition at line 32 of file DDQuery.cc.

References alignCSCRings::s, and scope_.

33 {
34  scope_ = &s;
35 }
const DDScope * scope_
Definition: DDQuery.h:33

Member Data Documentation

std::vector<std::pair<bool, DDFilter *> > DDQuery::criteria_
protected

Definition at line 35 of file DDQuery.h.

Referenced by addFilter(), and exec().

DDExpandedView DDQuery::epv_
protected

Definition at line 32 of file DDQuery.h.

Referenced by exec().

std::vector<DDExpandedNode> DDQuery::result_
protected

Definition at line 36 of file DDQuery.h.

Referenced by exec().

const DDScope* DDQuery::scope_
protected

Definition at line 33 of file DDQuery.h.

Referenced by exec(), and setScope().