00001 #include "rtreeincluderule.h"
00002 #include "singlecontext.h"
00003 #include "config.h"
00004
00005 IncludeRule::IncludeRule(Constant *iname, RunRuleList &irunRuleList) :
00006 name(iname->getValue()),
00007 runRuleList(irunRuleList) {
00008 delete iname;
00009 };
00010
00011 IncludeRule::~IncludeRule(){
00012 };
00013
00014 bool IncludeRule::execute(RuleContext* context, List* phpIn, List* phpOut, List* tplOut, Node::Assignment& assign) const {
00015 RunRuleList::iterator ruleListIt = runRuleList.begin();
00016 RunRuleList::iterator ruleListEnd = runRuleList.end();
00017 if (verbose>2) cout << "Doing: " << (phpIn->front()) << endl;
00018 if (verbose>2) phpIn->front()->print(cout) << endl;
00019
00020 if (ruleListIt==ruleListEnd)
00021 throw "ERROR: IncludeRule::runRules - no rules provided for context " + name;
00022 while (ruleListIt != ruleListEnd){
00023 RuleList::const_iterator rulesIt = ruleListIt->second.begin();
00024 RuleList::const_iterator rulesEnd = ruleListIt->second.end();
00025 while (rulesIt!=rulesEnd){
00026 if (verbose>2) cout << "Trying:" << rulesIt->second << endl;
00027 if (rulesIt->second->execute(context,phpIn,phpOut,tplOut,assign)) {
00028 if (verbose>2) cout << " Success" << endl;
00029 return true;
00030 }
00031 if (verbose>2) cout << " Failed" << endl;
00032 rulesIt++;
00033 };
00034 ruleListIt++;
00035 };
00036 return false;
00037 };
00038
00039 ostream& IncludeRule::print(ostream& os) const{
00040 os << "IncludeRule - " << name;
00041 return os;
00042 };
00043
00044 Rule* IncludeRule::copy(){
00045 throw "ERROR: IncludeRule::copy called";
00046 };
00047
00048 Rule* IncludeRule::substitute(const Node::Assignment &assign){
00049 throw "ERROR: IncludeRule::substitute called";
00050 };