ParamGetDDBaseBaseParamNodeClass.php 2.08 KB
<?php

define ("PARAMGETDDBASEBASEPARAM_NAME", "baseParam");
define ("PARAMGETDDBASEBASEPARAM_NAMEATT", "name");
define ("PARAMGETDDBASEBASEPARAM_TENSORORDER", "tensor_order");
define ("PARAMGETDDBASEBASEPARAM_CALIB", "clb");
define ("PARAMGETDDBASEBASEPARAM_CALIBNAME", "name");

/**
 * @class ParamGetDDBaseBaseParamNodeClass
 * @brief Definition of a DDBase parameter
 * @details
*/
class ParamGetDDBaseBaseParamNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(PARAMGETDDBASEBASEPARAM_NAME);
	}

	public function setParamName($name)
	{
		$this->setAttribute(PARAMGETDDBASEBASEPARAM_NAMEATT, $name);
	}

	public function getParamName()
	{
		return $this->getAttribute(PARAMGETDDBASEBASEPARAM_NAMEATT);
	}

	public function setTensorOrder($tensor_order)
	{
		$tensorNode = $this->getChildInstanceByName(PARAMGETDDBASEBASEPARAM_TENSORORDER, true);
		$tensorNode->setValue($tensor_order);
	}

	public function addCalibInfo($calibInfo = "")
	{
		if ($this->calibInfoExist($calibInfo))
			return NULL;

		$node = new NodeClass(PARAMGETDDBASEBASEPARAM_CALIB);
		$node->setAttribute(PARAMGETDDBASEBASEPARAM_CALIBNAME,$calibInfo);
		$this->addChild($node);
		
		return $node;
	}

	public function calibInfoExist($calibInfo)
	{
		$calibNodes = $this->getChildrenByName(PARAMGETDDBASEBASEPARAM_CALIB);

		foreach ($calibNodes as $calibNode)
		if ($calibNode->getAttribute(PARAMGETDDBASEBASEPARAM_CALIBNAME) == $calibInfo)
			return true;

		return false;
	}
	
	public function loadFromNode($xmlNode)
	{
		$this->setParamName($this->getXmlNodeAttribute($xmlNode, PARAMGETDDBASEBASEPARAM_NAMEATT));
		
		$tensorOrderXmlNode = $this->getXmlNodeChildByTagName($xmlNode, PARAMGETDDBASEBASEPARAM_TENSORORDER);
		if (isset($tensorOrderXmlNode))
			$this->setTensorOrder($this->getXmlNodeValue($tensorOrderXmlNode));
		
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, PARAMGETDDBASEBASEPARAM_CALIB) as $clbXmlNode) {
			$this->addCalibInfo($this->getXmlNodeAttribute($xmlNode, PARAMGETDDBASEBASEPARAM_CALIBNAME));
		}
	}
}

?>