Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals

RuleContext Class Reference

Context in that rules are executed. More...

#include <rulecontext.h>

Inheritance diagram for RuleContext:

MultiContext NamedContext SingleContext

Public Member Functions

 RuleContext (RuleList &irules, NameSpace &inameSpace)
 Constructes a context with given rules.

virtual ~RuleContext ()
 Destroys the context.

void insert (int priority, Rule *rule)
 Inserts a Rule with given priority in to the context.

void insert (PriorityRulePair *rulePair)
 Inserts a Rule with given priority in to the context.

void execute (Node *phpIn, List *phpOut, List *tplOut)
 Executes all rules of the context on php.

void assignVariableNames (List *phpList, List *tplList)
 Assigns appropriate names to variables appearing in given lists.

virtual void generateVariableNames (const Node::VariableList &vlist, Node::Assignment &phpAssign, Node::Assignment &tplAssign)=0
 Generates appropriate names to variables and stores them in assignments.

virtual const string generateVariableName ()=0
 Generates one variable name.

virtual void processSmartyAssign (SmartyAssign *smartyAssign)=0
 Processes one SmartyAssign.

virtual void enterContext (List *phpOut, List *tplOut)
 Run at the begining of RuleContext::execute.

virtual void leaveContext (List *phpOut, List *tplOut)
 Run at the end of RuleContext::execute.

virtual void registerSmartyVariable (const string &variable)=0
 Registers smarty varaible in the context.

virtual const string getVariableNameSufix (const bool stripControlVariableDollar)=0
 Returns a sufix for of a varaible name.

virtual const string getVariableNamePrefix ()=0
 Returns a sufix for of a varaible name.

virtual void processTemplate (Node *tpl) const=0
 Processes template after refactoring.

NameSpacegetNameSpace () const
 Returns nameContext.


Protected Attributes

RuleListrules
 List of rules.

NameSpacenameSpace
 A name space in which rules are executed.


Private Member Functions

bool executeOnPHP (List *phpIn, List *phpOut, List *tplOut)
 Namespace Tries to execute rules on php.

void executeOnPHPList (List *phpIn, List *phpOut, List *tplOut)
 Executes executeOnPHP unless the phpIn is empty.

void processSmartyAssignInPhpList (List *phpList)
 Sets appropriate strings in appearing ::SmartyAssing classes.


Private Attributes

list< RuleList::iterator > myRules
 List of rules belonging to the context.


Friends

class MultiContext
class SingleContext

Detailed Description

Context in that rules are executed.

Remembers the list of rules and executes tham on php. Takes care of assinging names to variables exported to template.

Definition at line 15 of file rulecontext.h.


Constructor & Destructor Documentation

RuleContext::RuleContext RuleList irules,
NameSpace inameSpace
 

Constructes a context with given rules.

Definition at line 37 of file rulecontext.cpp.

RuleContext::~RuleContext  )  [virtual]
 

Destroys the context.

Definition at line 39 of file rulecontext.cpp.

References myRules, and rules.


Member Function Documentation

void RuleContext::assignVariableNames List phpList,
List tplList
 

Assigns appropriate names to variables appearing in given lists.

Definition at line 70 of file rulecontext.cpp.

References generateVariableNames(), List::getVariables(), processSmartyAssignInPhpList(), List::substitute(), and Node::VariableList.

Referenced by SubstitutionRule::execute(), and ContextRule::execute().

void RuleContext::enterContext List phpOut,
List tplOut
[virtual]
 

Run at the begining of RuleContext::execute.

Reimplemented in MultiContext.

Definition at line 97 of file rulecontext.cpp.

Referenced by execute().

void RuleContext::execute Node phpIn,
List phpOut,
List tplOut
 

Executes all rules of the context on php.

Parameters:
phpIn input php
phpOut output php
tplOut output smarty template
During the execution phpIn is destroyed.

Definition at line 58 of file rulecontext.cpp.

References CStatementList, enterContext(), executeOnPHPList(), Node::getName(), and leaveContext().

Referenced by ContextRule::execute(), and NamedContextRule::runRules().

bool RuleContext::executeOnPHP List phpIn,
List phpOut,
List tplOut
[private]
 

Namespace Tries to execute rules on php.

Parameters:
phpIn input php
phpOut output php
tplOut output smarty template
Douring the execution the begining of phpIn is destroyed when the rules match.

Definition at line 5 of file rulecontext.cpp.

References List::print(), and rules.

Referenced by executeOnPHPList().

void RuleContext::executeOnPHPList List phpIn,
List phpOut,
List tplOut
[private]
 

Executes executeOnPHP unless the phpIn is empty.

Definition at line 29 of file rulecontext.cpp.

References executeOnPHP(), List::getLength(), and Node::toString().

Referenced by execute().

virtual const string RuleContext::generateVariableName  )  [pure virtual]
 

Generates one variable name.

Implemented in MultiContext, NamedContext, and SingleContext.

Referenced by SingleContext::generateVariableName().

virtual void RuleContext::generateVariableNames const Node::VariableList vlist,
Node::Assignment phpAssign,
Node::Assignment tplAssign
[pure virtual]
 

Generates appropriate names to variables and stores them in assignments.

Implemented in MultiContext, NamedContext, and SingleContext.

Referenced by assignVariableNames(), and SingleContext::generateVariableNames().

NameSpace& RuleContext::getNameSpace  )  const [inline]
 

Returns nameContext.

Definition at line 113 of file rulecontext.h.

References nameSpace.

Referenced by SubstitutionRule::execute(), NamedContextRule::execute(), RuleWithActionRule::execute(), and ActionRule::execute().

virtual const string RuleContext::getVariableNamePrefix  )  [pure virtual]
 

Returns a sufix for of a varaible name.

Implemented in MultiContext, NamedContext, and SingleContext.

Referenced by SingleContext::getVariableNamePrefix().

virtual const string RuleContext::getVariableNameSufix const bool  stripControlVariableDollar  )  [pure virtual]
 

Returns a sufix for of a varaible name.

In case of control variables e.g. in for statement, a leading dollar may be skiped, when exporting control variable to template.

Implemented in MultiContext, NamedContext, and SingleContext.

Referenced by MultiContext::generateVariableNames(), SingleContext::getVariableNameSufix(), and MultiContext::getVariableNameSufix().

void RuleContext::insert PriorityRulePair rulePair  ) 
 

Inserts a Rule with given priority in to the context.

Definition at line 54 of file rulecontext.cpp.

References PriorityList< Rule >::insert(), myRules, and rules.

void RuleContext::insert int  priority,
Rule rule
 

Inserts a Rule with given priority in to the context.

Definition at line 50 of file rulecontext.cpp.

References PriorityList< Rule >::insert(), myRules, and rules.

void RuleContext::leaveContext List phpOut,
List tplOut
[virtual]
 

Run at the end of RuleContext::execute.

When living the context all registerd smarty variables are exported.

Reimplemented in NamedContext.

Definition at line 98 of file rulecontext.cpp.

Referenced by execute().

virtual void RuleContext::processSmartyAssign SmartyAssign smartyAssign  )  [pure virtual]
 

Processes one SmartyAssign.

Implemented in MultiContext, NamedContext, and SingleContext.

Referenced by SingleContext::processSmartyAssign(), and processSmartyAssignInPhpList().

void RuleContext::processSmartyAssignInPhpList List phpList  )  [private]
 

Sets appropriate strings in appearing ::SmartyAssing classes.

Definition at line 85 of file rulecontext.cpp.

References CSmartyAssign, and processSmartyAssign().

Referenced by assignVariableNames().

virtual void RuleContext::processTemplate Node tpl  )  const [pure virtual]
 

Processes template after refactoring.

Implemented in MultiContext, NamedContext, and SingleContext.

Referenced by ContextRule::execute(), and SingleContext::processTemplate().

virtual void RuleContext::registerSmartyVariable const string &  variable  )  [pure virtual]
 

Registers smarty varaible in the context.

Implemented in MultiContext, NamedContext, and SingleContext.

Referenced by SingleContext::registerSmartyVariable(), and MultiContext::registerSmartyVariable().


Friends And Related Function Documentation

friend class MultiContext [friend]
 

Definition at line 115 of file rulecontext.h.

friend class SingleContext [friend]
 

Definition at line 116 of file rulecontext.h.


Field Documentation

list<RuleList::iterator> RuleContext::myRules [private]
 

List of rules belonging to the context.

Every inserted rule is put to RuleContext::rules and an iterator is stored in myRules. When the context is destroyed the stored rules are removed from RuleContext::rules.

Definition at line 28 of file rulecontext.h.

Referenced by insert(), and ~RuleContext().

NameSpace& RuleContext::nameSpace [protected]
 

A name space in which rules are executed.

Definition at line 51 of file rulecontext.h.

Referenced by getNameSpace().

RuleList& RuleContext::rules [protected]
 

List of rules.

Definition at line 18 of file rulecontext.h.

Referenced by executeOnPHP(), insert(), and ~RuleContext().


The documentation for this class was generated from the following files:
Generated on Fri Nov 21 17:54:09 2003 for PHPX by doxygen 1.3.3