test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 &, DDLogOp op=DDLogOp::AND)
 
 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< DDLogOplogOps_
 
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,
DDLogOp  op = DDLogOp::AND 
)
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_, f, and logOps_.

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  logOps_.push_back(op);
30 }
double f[11][100]
A Filter accepts or rejects a DDExpandedNode based on a user-coded decision rule. ...
Definition: DDFilter.h:19
std::vector< std::pair< bool, DDFilter * > > criteria_
Definition: DDQuery.h:35
std::vector< DDLogOp > logOps_
Definition: DDQuery.h:36
const std::vector< DDExpandedNode > & DDQuery::exec ( )
virtual

Definition at line 39 of file DDQuery.cc.

References DDFilter::accept(), AND, begin, criteria_, DDScope::depth(), HLT_25ns10e33_v2_cff::depth, end, epv_, alcazmumu_cfi::filter, DDExpandedView::geoHistory(), logOps_, DDExpandedView::next(), DDExpandedView::reset(), mps_fire::result, result_, DTTTrigCorrFirst::run, SimDataFormats::CaloAnalysis::sc, DDScope::scope(), scope_, DDExpandedView::setScope(), and DDExpandedView::specifics().

40 {
41  result_.clear();
42  epv_.reset();
43 
44  // currently at least one filter must be set, because
45  // the query simply consists in applying at least one filter!
46  if(criteria_.size()) { // <- remove the 'if' when implementing 'the QUERY'
47  int depth = 0;
48  bool scoped = false;
49  DDScope::scope_type dummy;
50  DDScope::scope_type::const_iterator it = dummy.begin();
51  DDScope::scope_type::const_iterator it_end = dummy.end();
52  if (scope_) {
53  const DDScope & sc = *scope_;
54  it = sc.scope().begin();
55  depth = sc.depth();
56  scoped = bool(sc.scope().end()-it);
57  }
58 
59  bool runonce = scoped ? false : true;
60 
61  while (runonce || (it != it_end) ) {
62  if (scoped) epv_.setScope(*it,depth); // set the subtree-scope & depth within
63  bool run = true;
64  while(run) {
65  std::vector<const DDsvalues_type *> specs = epv_.specifics();
66  auto logOpIt = logOps_.begin();
67  // loop over all user-supplied criteria (==filters)
68  bool result=true;
69  for( auto it = begin(criteria_); it != end(criteria_); ++it, ++logOpIt) {
70  DDFilter * filter = it->second;
71  if (filter->accept(epv_)) {
72  it->first=true;
73  }
74  else {
75  it->first=false;
76  }
77 
78  // now do the logical-operations on the results encountered so far:
79  if (*logOpIt == DDLogOp::AND) { // AND
80  result &= it->first;
81  }
82  else { // OR
83  result |= it->first;
84  }
85  } // <-- loop over filters
86  if (result) {
87  // HERE THE ACTUAL QUERY SHOULD BE INVOKED!!!
88  result_.push_back(epv_.geoHistory().back());
89  }
90  //} <-- loop over std::vector of specifics_type ...
91  run = epv_.next();
92  }
93  if (scoped)
94  ++it;
95  else
96  runonce=false;
97  }
98  }
99  return result_;
100 }
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:37
tuple result
Definition: mps_fire.py:84
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:19
virtual bool accept(const DDExpandedView &) const =0
true, if the DDExpandedNode fulfills the filter criteria
std::vector< std::pair< bool, DDFilter * > > criteria_
Definition: DDQuery.h:35
const scope_type & scope(void) const
returns the scope container
Definition: DDScope.cc:114
std::vector< DDLogOp > logOps_
Definition: DDQuery.h:36
void DDQuery::setScope ( const DDScope s)
virtual

Definition at line 33 of file DDQuery.cc.

References alignCSCRings::s, and scope_.

34 {
35  scope_ = &s;
36 }
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<DDLogOp> DDQuery::logOps_
protected

Definition at line 36 of file DDQuery.h.

Referenced by addFilter(), and exec().

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

Definition at line 37 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().