2010-09-18 11:11:44 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Moserware\Skills\FactorGraphs;
|
|
|
|
|
2010-09-25 10:15:51 -04:00
|
|
|
require_once(dirname(__FILE__) . "/Variable.php");
|
2010-09-18 21:19:51 -04:00
|
|
|
|
2010-09-18 11:11:44 -04:00
|
|
|
class VariableFactory
|
|
|
|
{
|
|
|
|
// using a Func<TValue> to encourage fresh copies in case it's overwritten
|
|
|
|
private $_variablePriorInitializer;
|
|
|
|
|
|
|
|
public function __construct($variablePriorInitializer)
|
|
|
|
{
|
|
|
|
$this->_variablePriorInitializer = $variablePriorInitializer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function createBasicVariable()
|
|
|
|
{
|
|
|
|
$newVar = new Variable($this->_variablePriorInitializer());
|
|
|
|
return $newVar;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function createKeyedVariable($key)
|
|
|
|
{
|
|
|
|
$newVar = new KeyedVariable($key, $this->_variablePriorInitializer());
|
|
|
|
return $newVar;
|
|
|
|
}
|
2010-09-18 21:19:51 -04:00
|
|
|
}
|
2010-09-18 11:11:44 -04:00
|
|
|
|
|
|
|
?>
|