aboutsummaryrefslogtreecommitdiffstats
path: root/Model
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2012-12-20 15:12:35 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2012-12-20 15:12:35 +0100
commit8c99caaa0f6c215ab4efc1c2e6a5389fd2f9fa20 (patch)
tree262f9bf470f15b0e6ba8aba1aa5ac30d8e049549 /Model
parent02449c063ed21b60d8e19065d90e27469df2b626 (diff)
downloadPraspel-8c99caaa0f6c215ab4efc1c2e6a5389fd2f9fa20.zip
Praspel-8c99caaa0f6c215ab4efc1c2e6a5389fd2f9fa20.tar.gz
Praspel-8c99caaa0f6c215ab4efc1c2e6a5389fd2f9fa20.tar.bz2
Propagate constraints each time we got a new one.
Diffstat (limited to 'Model')
-rw-r--r--Model/Variable.php51
1 files changed, 41 insertions, 10 deletions
diff --git a/Model/Variable.php b/Model/Variable.php
index 6e61305..1ff9da7 100644
--- a/Model/Variable.php
+++ b/Model/Variable.php
@@ -76,49 +76,65 @@ class Variable
*
* @var \Hoa\Praspel\Model\Variable string
*/
- protected $_name = null;
+ protected $_name = null;
/**
* Clause that contains this variable.
*
* @var \Hoa\Praspel\Model\Clause object
*/
- protected $_clause = null;
+ protected $_clause = null;
/**
* Variable value.
*
* @var \Hoa\Praspel\Model\Variable mixed
*/
- protected $_value = null;
+ protected $_value = null;
/**
* Domains that describe the variable.
*
* @var \Hoa\Realdom\Disjunction object
*/
- protected $_domains = null;
+ protected $_domains = null;
/**
* References domains.
*
* @var \Hoa\Realdom\Disjunction object
*/
- protected $_refDomains = null;
+ protected $_refDomains = null;
/**
* Alias variable (please, see “domainof”).
*
* @var \Hoa\Praspel\Model\Variable object
*/
- protected $_alias = null;
+ protected $_alias = null;
/**
* Constraints.
*
* @var \Hoa\Praspel\Model\Variable array
*/
- protected $_constraints = array();
+ protected $_constraints = array();
+
+ /**
+ * Temporary constraints type.
+ * Useful when propagate new constraints.
+ *
+ * @var \Hoa\Praspel\Model\Variable string
+ */
+ protected $_tmpConstraintsType = null;
+
+ /**
+ * Temporary constraints index.
+ * Useful when propagate new constraints.
+ *
+ * @var \Hoa\Praspel\Model\Variable string
+ */
+ protected $_tmpConstraintsIndex = null;
@@ -206,6 +222,17 @@ class Variable
$this->_refDomains = $value;
+ if(false === $onDomains) {
+
+ $this->_domains->propagateConstraints(
+ $this->_tmpConstraintsType,
+ $this->_tmpConstraintsIndex
+ );
+
+ $this->_tmpConstraintsType = null;
+ $this->_tmpConstraintsIndex = null;
+ }
+
unset($this->_refDomains);
$this->_refDomains = &$this->_domains;
@@ -272,9 +299,13 @@ class Variable
$this->_constraints['key'] = array();
unset($this->_refDomains);
- $handle = &$this->_constraints['key'][];
- $handle[0] = realdom()->const($scalar);
- $this->_refDomains = &$handle[1];
+ $handle = &$this->_constraints['key'][];
+ $handle[0] = realdom()->const($scalar);
+ $this->_refDomains = &$handle[1];
+
+ end($this->_constraints['key']);
+ $this->_tmpConstraintsType = 'key';
+ $this->_tmpConstraintsIndex = key($this->_constraints['key']);
return $this;
}