00001 #ifndef _RTREEACTIONRULE_H_
00002 #define _RTREEACTIONRULE_H_
00003
00004 #include "rulecontext.h"
00005
00007 class Action{
00008 public:
00009 virtual ~Action() {};
00010 virtual void execute(NameSpace &nameSpace) = 0;
00011 virtual Action* copy() const = 0;
00012 virtual Action* substitute(const Node::Assignment &assign) = 0;
00013 };
00014
00016 class ActionWrite : public Action{
00018 Node* expr;
00019 public:
00021 ActionWrite(Node* iexpr);
00022 virtual ~ActionWrite();
00023
00024 virtual void execute(NameSpace &nameSpace);
00025 virtual Action* copy() const;
00026 virtual Action* substitute(const Node::Assignment &assign);
00027 };
00029 class ActionSet : public Action{
00031 Node* name;
00033 const string attribute;
00035 Node* expr;
00037 const bool global;
00038 public:
00040 ActionSet(Node* iname, Constant* iattribute, Node* iexpr, bool iglobal);
00041 virtual ~ActionSet();
00042
00043 virtual void execute(NameSpace &nameSpace);
00044 virtual Action* copy() const;
00045 virtual Action* substitute(const Node::Assignment &assign);
00046 };
00047
00049 class ActionList : public list<Action*> {
00050 public:
00051 ActionList() {};
00052 ActionList(Action* action) { push_back(action); };
00053 ~ActionList();
00054
00055 ActionList* push_back(Action* action);
00056
00057 ActionList* copy() const;
00058 ActionList* substitute(const Node::Assignment &assign);
00059
00060 virtual void execute(NameSpace &nameSpace) const;
00061 };
00062
00064 class ActionRule : public Rule{
00066 List* phpInPattern;
00068 ActionList* actions;
00069 public:
00070
00072 ActionRule(List* iphpInPattern, ActionList* iactions);
00073
00074 virtual ~ActionRule();
00075
00076 virtual bool execute(RuleContext* context, List* phpIn, List* phpOut, List* tplOut, Node::Assignment& assign) const;
00077
00078 virtual Rule* copy();
00079 virtual Rule* substitute(const Node::Assignment &assign);
00080
00081 virtual ostream& print(ostream& os) const;
00082 };
00083
00085 class RuleWithActionRule : public Rule{
00087 Rule* rule;
00089 ActionList* actions;
00090 public:
00091
00093 RuleWithActionRule(Rule* irule, ActionList* iactions);
00094
00095 virtual ~RuleWithActionRule();
00096
00097 virtual bool execute(RuleContext* context, List* phpIn, List* phpOut, List* tplOut, Node::Assignment& assign) const;
00098
00099 virtual Rule* copy();
00100 virtual Rule* substitute(const Node::Assignment &assign);
00101
00102 virtual ostream& print(ostream& os) const;
00103 };
00104
00105 #endif