Source for file Rulecontext.php

Documentation is available at Rulecontext.php

  1. <?php  if defined('BASEPATH')) exit('No direct script access allowed');
  2. /** 
  3.  * Rulecontext.php
  4.  * @author Greg Swindle <greg@swindle.net>
  5.  * @version 0.2
  6.  * @package Phprules
  7.  */
  8. require_once"Ruleelement.php" );
  9. /**
  10.  * Contains the informational context for the execution of a Rule. It represents
  11.  * this information as a collection of RuleElements that may be Propositions or
  12.  * Variables but not Operators.
  13.  * @package Phprules
  14.  */
  15. class RuleContext {
  16.     public $name;
  17.     public $elements;
  18.     
  19.     function RuleContext$name='' {
  20.         $this->name = $name;
  21.         // elements is a dictionary - a set of {name, value} pairs
  22.         // The names are Proposition or Variable names and
  23.         // the values are the Propositions or Variables themselves
  24.         $this->elements = array();
  25.     }
  26.     
  27.     function __construct$name='' {
  28.         $this->name = $name;
  29.         // elements is a dictionary - a set of {name, value} pairs
  30.         // The names are Proposition or Variable names and
  31.         // the values are the Propositions or Variables themselves
  32.         $this->elements = array();
  33.     }
  34. /**
  35.  * Adds a Proposition to the array of {@link $elements}.
  36.  * @access public
  37.  * @param string $statement The Proposition's statement.
  38.  * @param boolean $value Whether the Proposition is TRUE or FALSE.
  39.  */    
  40.     function addProposition$statement$value {
  41.         $this->elements$statement new Proposition$statement$value );
  42.     }
  43. /**
  44.  * Adds a Variable to the array of {@link $elements}.
  45.  * @access public
  46.  * @param string $name The Variable's name.
  47.  * @param mixed $value The Variable's value.
  48.  */    
  49.     function addVariable$name$value {
  50.         $this->elements$name new Variable$name$value );
  51.     }
  52. /**
  53.  * Find and return a RuleElement by name, if it exists.
  54.  * @access public
  55.  * @param string $name The name (i.e., "key") of the RuleElement.
  56.  * @return RuleElement 
  57.  */        
  58.     function findElement$name {
  59.         return $this->elements$name ];
  60.     }
  61.     
  62.     function append$ruleContext {
  63.         foreach$ruleContext->elements as $e {
  64.             $this->elements$e->name $e;
  65.         }
  66.     }
  67. /**
  68.  * Returns an infixed, readable representation of the RuleContext.
  69.  * @access public
  70.  * @return string 
  71.  */    
  72.     function toString({
  73.         $result "";
  74.         foreacharray_values$this->elements as $e {
  75.             $result $result $e->toString("\n";
  76.         }
  77.         return $result;
  78.     }
  79. }
  80.  
  81. /* End of file Rulecontext.php */
  82. /* Location: ./system/application/libraries/php-rules/Rulecontext.php */

Documentation generated on Thu, 24 Mar 2011 21:27:40 -0500 by phpDocumentor 1.4.1