ParamGetConstantNodeClass.php 1.37 KB
<?php

require_once "ParamGetConstantParamNodeClass.php";

define ("PARAMGETCONSTANT_VI", "constant");

/**
 * @class ParamGetConstantNodeClass
 * @brief Definition of a constant getter for AMDA_Kernel
 * @details
*/
class ParamGetConstantNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(PARAMGETCONSTANT_VI);
	}

	public function getConstant($sampling = "60", $type = "int", $dim1 = "1", $dim2 = "1", $value = "1")
	{
		$nodes = $this->getChildrenByName(PARAMGETCONSTANTPARAM_NAME);
	
		foreach ($nodes as $node)
			if (($node->getSampling() == $sampling) && ($node->getType() == $type) && ($node->getConstValue() == $value) &&
				($node->getDim1() == $dim1) && ($node->getDim2() == $dim2))
			return $node;
		return NULL;
	}
	
	public function addConstant($sampling = "60", $type = "int", $dim1 = "1", $dim2 = "1", $value = "1")
	{
		$constantNode = new ParamGetConstantParamNodeClass();
		
		$constantNode->setSampling($sampling);
		$constantNode->setType($type);
		$constantNode->setDim1($dim1);
		$constantNode->setDim2($dim2);
		$constantNode->setConstValue($value);

		$this->addChild($constantNode);
		
		return $constantNode;
	}
	
	public function loadFromNode($xmlNode)
	{
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, PARAMGETCONSTANTPARAM_NAME) as $constantXmlNode) {
			$this->addConstant()->loadFromNode($constantXmlNode);
		}
	}
}

?>