00001 #include "rtreetriggeredrule.h" 00002 00003 TriggeredRule::TriggeredRule(PriorityRulePair* iinRulePair, PriorityRulePair* ioutRulePair) 00004 : inRulePair(iinRulePair), outRulePair(ioutRulePair) {}; 00005 00006 TriggeredRule::~TriggeredRule(){ 00007 delete inRulePair->second; 00008 delete outRulePair->second; 00009 delete inRulePair; 00010 delete outRulePair; 00011 }; 00012 00013 bool TriggeredRule::execute(RuleContext* context, List* phpIn, List* phpOut, List* tplOut, Node::Assignment &assign)const{ 00014 if (inRulePair->second->execute(context,phpIn,phpOut,tplOut,assign)){ 00015 context->insert(outRulePair->first,outRulePair->second->copy()->substitute(assign)); 00016 return true; 00017 } else return false; 00018 }; 00019 00020 Rule* TriggeredRule::copy(){ 00021 return new TriggeredRule(new PriorityRulePair(inRulePair->first,inRulePair->second->copy()), 00022 new PriorityRulePair(outRulePair->first,outRulePair->second->copy())); 00023 }; 00024 Rule* TriggeredRule::substitute(const Node::Assignment &assign){ 00025 inRulePair->second->substitute(assign); 00026 outRulePair->second->substitute(assign); 00027 return this; 00028 }; 00029 00030 ostream& TriggeredRule::print(ostream& os) const{ 00031 os << "TriggeredRule - " << inRulePair->second; 00032 return os; 00033 };