#include <DetectorDescription/Core/interface/DDQuery.h>
Public Types | |
enum | log_op { AND, OR } |
Public Member Functions | |
virtual void | addFilter (const DDFilter &, log_op op=AND) |
the standard DDQuery only support one single filter. | |
DDQuery (const DDCompactView &) | |
sets up a query | |
virtual const std::vector < DDExpandedNode > & | exec () |
virtual void | setScope (const DDScope &) |
virtual | ~DDQuery () |
Protected Types | |
typedef std::vector < criterion_type > | criteria_type |
typedef std::pair< bool, DDFilter * > | criterion_type |
typedef std::vector< log_op > | logops_type |
Protected Attributes | |
criteria_type | criteria_ |
DDExpandedView | epv_ |
logops_type | logOps_ |
std::vector< DDExpandedNode > | result_ |
const DDScope * | scope_ |
Definition at line 15 of file DDQuery.h.
typedef std::vector<criterion_type> DDQuery::criteria_type [protected] |
typedef std::pair<bool, DDFilter *> DDQuery::criterion_type [protected] |
typedef std::vector<log_op> DDQuery::logops_type [protected] |
enum DDQuery::log_op |
DDQuery::DDQuery | ( | const DDCompactView & | cpv | ) |
DDQuery::~DDQuery | ( | ) | [virtual] |
the standard DDQuery only support one single filter.
Memory management of DDFilter* is NOT delegated to DDQuery
Definition at line 18 of file DDQuery.cc.
References criteria_, and logOps_.
00019 { 00020 // cheating a bit with const .... 00021 // Filters have a non-const ::accept(..) member function to allow 00022 // a possible internal state change in a particular filter implementation ... 00023 DDFilter * nonConstFilter = const_cast<DDFilter *>(&f); 00024 criteria_.push_back(std::make_pair(false,nonConstFilter)); 00025 logOps_.push_back(op); 00026 //DCOUT('F',"DDQuery::addFilter(): log-op=" << op ); 00027 }
const std::vector< DDExpandedNode > & DDQuery::exec | ( | ) | [virtual] |
Definition at line 36 of file DDQuery.cc.
References DDFilter::accept(), AND, criteria_, DDScope::depth(), dummy, epv_, filter, DDExpandedView::geoHistory(), it, logOps_, DDExpandedView::next(), DDExpandedView::reset(), HLT_VtxMuL3::result, result_, mergeAndRegister_online::run, DDScope::scope(), scope_, DDExpandedView::setScope(), and DDExpandedView::specifics().
00037 { 00038 result_.clear(); 00039 epv_.reset(); 00040 00041 //bool filtered = bool(filters_.size()); 00042 //bool unfiltered = !filtered; 00043 00044 // currently at least one filter must be set, because 00045 // the query simply consists in applying at least one filter! 00046 if(criteria_.size()) { // <- remove the 'if' when implementing 'the QUERY' 00047 int depth = 0; 00048 bool scoped = false; 00049 DDScope::scope_type dummy; 00050 DDScope::scope_type::const_iterator it = dummy.begin(); 00051 DDScope::scope_type::const_iterator it_end = dummy.end(); 00052 if (scope_) { 00053 const DDScope & sc = *scope_; 00054 it = sc.scope().begin(); 00055 depth = sc.depth(); 00056 scoped = bool(sc.scope().end()-it); 00057 } 00058 00059 bool runonce = scoped ? false : true; 00060 00061 while (runonce || (it != it_end) ) { 00062 if (scoped) epv_.setScope(*it,depth); // set the subtree-scope & depth within 00063 bool run = true; 00064 while(run) { 00065 //DCOUT('F', "DDQuery: examining " << epv_.geoHistory().back() ); 00066 00067 std::vector<const DDsvalues_type *> specs = epv_.specifics(); 00068 std::vector<const DDsvalues_type *>::const_iterator sit = specs.begin(); 00069 //FIXME: find a solution when more then one specifics_type is attached to 00070 //FIXME: particlular nodes ... (merging the specifics-map, etc ...) 00071 //FIXME: for (; sit != specs.end() ; ++sit) { 00072 DDsvalues_type dummy; 00073 const DDsvalues_type * specifics; 00074 if (sit==specs.end()) 00075 specifics = &dummy; 00076 else 00077 specifics = *sit; 00078 00079 criteria_type::iterator it = criteria_.begin(); 00080 logops_type::iterator logOpIt = logOps_.begin(); 00081 // loop over all user-supplied criteria (==filters) 00082 bool result=true; 00083 for (; it != criteria_.end(); ++it, ++logOpIt) { 00084 DDFilter * filter = it->second; 00085 if (filter->accept(epv_)) { 00086 //.geoHistory().back(), // expanded node 00087 //epv_.geoHistory(), 00088 //specifics)) { // geom.history 00089 00090 it->first=true; 00091 //DCOUT('F', " Filter(" << criteria_.end()-it << ") accepted: " << epv_.geoHistory().back()); 00092 } 00093 else { 00094 it->first=false; 00095 } 00096 00097 // now do the logical-operations on the results encountered so far: 00098 if (*logOpIt==AND) { // AND 00099 result &= it->first; 00100 } 00101 else { // OR 00102 result |= it->first; 00103 } 00104 } // <-- loop over filters 00105 //DCOUT('f', "-------------------"); 00106 if (result) { 00107 // HERE THE ACTUAL QUERY SHOULD BE INVOKED!!! 00108 result_.push_back(epv_.geoHistory().back()); 00109 } 00110 //} <-- loop over std::vector of specifics_type ... 00111 run = epv_.next(); 00112 } 00113 if (scoped) 00114 ++it; 00115 else 00116 runonce=false; 00117 } 00118 } 00119 return result_; 00120 }
criteria_type DDQuery::criteria_ [protected] |
DDExpandedView DDQuery::epv_ [protected] |
logops_type DDQuery::logOps_ [protected] |
std::vector<DDExpandedNode> DDQuery::result_ [protected] |
const DDScope* DDQuery::scope_ [protected] |