Go to the documentation of this file.00001
00002 #include "DetectorDescription/Core/interface/DDQuery.h"
00003 #include "DetectorDescription/Core/interface/DDCompactView.h"
00004
00005
00006 DDQuery::DDQuery(const DDCompactView & cpv)
00007 : epv_(cpv), scope_(0)
00008 { }
00009
00010
00011 DDQuery::~DDQuery()
00012 { }
00013
00014
00018 void DDQuery::addFilter(const DDFilter & f, log_op op)
00019 {
00020
00021
00022
00023 DDFilter * nonConstFilter = const_cast<DDFilter *>(&f);
00024 criteria_.push_back(std::make_pair(false,nonConstFilter));
00025 logOps_.push_back(op);
00026
00027 }
00028
00029
00030 void DDQuery::setScope(const DDScope & s)
00031 {
00032 scope_ = &s;
00033 }
00034
00035
00036 const std::vector<DDExpandedNode> & DDQuery::exec()
00037 {
00038 result_.clear();
00039 epv_.reset();
00040
00041
00042
00043
00044
00045
00046 if(criteria_.size()) {
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);
00063 bool run = true;
00064 while(run) {
00065
00066
00067 std::vector<const DDsvalues_type *> specs = epv_.specifics();
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 criteria_type::iterator it = criteria_.begin();
00080 logops_type::iterator logOpIt = logOps_.begin();
00081
00082 bool result=true;
00083 for (; it != criteria_.end(); ++it, ++logOpIt) {
00084 DDFilter * filter = it->second;
00085 if (filter->accept(epv_)) {
00086
00087
00088
00089
00090 it->first=true;
00091
00092 }
00093 else {
00094 it->first=false;
00095 }
00096
00097
00098 if (*logOpIt==AND) {
00099 result &= it->first;
00100 }
00101 else {
00102 result |= it->first;
00103 }
00104 }
00105
00106 if (result) {
00107
00108 result_.push_back(epv_.geoHistory().back());
00109 }
00110
00111 run = epv_.next();
00112 }
00113 if (scoped)
00114 ++it;
00115 else
00116 runonce=false;
00117 }
00118 }
00119 return result_;
00120 }