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 12 of file DDQuery.h.

Constructor & Destructor Documentation

DDQuery::DDQuery ( const DDCompactView cpv)

sets up a query

Definition at line 4 of file DDQuery.cc.

5  : epv_(cpv), scope_(0)
6 { }
const DDScope * scope_
Definition: DDQuery.h:28
DDExpandedView epv_
Definition: DDQuery.h:27
DDQuery::~DDQuery ( )
virtual

Definition at line 9 of file DDQuery.cc.

10 { }

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 16 of file DDQuery.cc.

References criteria_, f, and logOps_.

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

Definition at line 33 of file DDQuery.cc.

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

34 {
35  result_.clear();
36  epv_.reset();
37 
38  // currently at least one filter must be set, because
39  // the query simply consists in applying at least one filter!
40  if(criteria_.size()) { // <- remove the 'if' when implementing 'the QUERY'
41  int depth = 0;
42  bool scoped = false;
43  DDScope::scope_type dummy;
44  DDScope::scope_type::const_iterator it = dummy.begin();
45  DDScope::scope_type::const_iterator it_end = dummy.end();
46  if (scope_) {
47  const DDScope & sc = *scope_;
48  it = sc.scope().begin();
49  depth = sc.depth();
50  scoped = bool(sc.scope().end()-it);
51  }
52 
53  bool runonce = scoped ? false : true;
54 
55  while (runonce || (it != it_end) ) {
56  if (scoped) epv_.setScope(*it,depth); // set the subtree-scope & depth within
57  bool run = true;
58  while(run) {
59  std::vector<const DDsvalues_type *> specs = epv_.specifics();
60  auto logOpIt = logOps_.begin();
61  // loop over all user-supplied criteria (==filters)
62  bool result=true;
63  for( auto it = begin(criteria_); it != end(criteria_); ++it, ++logOpIt) {
64  DDFilter * filter = it->second;
65  if (filter->accept(epv_)) {
66  it->first=true;
67  }
68  else {
69  it->first=false;
70  }
71 
72  // now do the logical-operations on the results encountered so far:
73  if (*logOpIt == DDLogOp::AND) { // AND
74  result &= it->first;
75  }
76  else { // OR
77  result |= it->first;
78  }
79  } // <-- loop over filters
80  if (result) {
81  // HERE THE ACTUAL QUERY SHOULD BE INVOKED!!!
82  result_.push_back(epv_.geoHistory().back());
83  }
84  //} <-- loop over std::vector of specifics_type ...
85  run = epv_.next();
86  }
87  if (scoped)
88  ++it;
89  else
90  runonce=false;
91  }
92  }
93  return result_;
94 }
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:32
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:31
int depth(void) const
return the depth to wich the subtrees are restricted
Definition: DDScope.cc:106
const DDScope * scope_
Definition: DDQuery.h:28
tuple result
Definition: query.py:137
#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:26
void reset()
true, if a call to firstChild() would succeed (current node has at least one child) ...
DDExpandedView epv_
Definition: DDQuery.h:27
#define begin
Definition: vmac.h:30
A Filter accepts or rejects a DDExpandedNode based on a user-coded decision rule. ...
Definition: DDFilter.h:18
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:30
const scope_type & scope(void) const
returns the scope container
Definition: DDScope.cc:112
std::vector< DDLogOp > logOps_
Definition: DDQuery.h:31
void DDQuery::setScope ( const DDScope s)
virtual

Definition at line 27 of file DDQuery.cc.

References alignCSCRings::s, and scope_.

28 {
29  scope_ = &s;
30 }
const DDScope * scope_
Definition: DDQuery.h:28

Member Data Documentation

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

Definition at line 30 of file DDQuery.h.

Referenced by addFilter(), and exec().

DDExpandedView DDQuery::epv_
protected

Definition at line 27 of file DDQuery.h.

Referenced by exec().

std::vector<DDLogOp> DDQuery::logOps_
protected

Definition at line 31 of file DDQuery.h.

Referenced by addFilter(), and exec().

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

Definition at line 32 of file DDQuery.h.

Referenced by exec().

const DDScope* DDQuery::scope_
protected

Definition at line 28 of file DDQuery.h.

Referenced by exec(), and setScope().