InfoParamNodeClass.php 2.59 KB
<?php

define ("INFOPARAM_TAGNAME", "info");
define ("INFOPARAM_NAME", "name");
define ("INFOPARAM_SHORTNAME", "short_name");
define ("INFOPARAM_COMPONENTS", "components");
define ("INFOPARAM_UNITS", "units");
define ("INFOPARAM_COORDSYS", "coordinates_system");
define ("INFOPARAM_TENSORORDER", "tensor_order");
define ("INFOPARAM_SICONV", "si_conversion");
define ("INFOPARAM_TABLE", "table");
define ("INFOPARAM_FILLVAL", "fill_value");
define ("INFOPARAM_UCD", "ucd");
//define ("INFOPARAM_STATUSDEF", "status_def");
define ("INFOPARAM_DATASETID", "dataset_id");

/**
 * 
 */
abstract class InfoParamTableTypeEnum
{
	const BOUNDS      = "Bounds";
	const MINMAX      = "MinMax";
	const CENTER      = "Center";
	const CENTERWIDTH = "CenterWidth";
}

/**
 * @class InfoParamNodeClass
 * @brief Definition of information about a parameter
 * @details
 */
class InfoParamNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(INFOPARAM_TAGNAME);
		
		$this->getChildInstanceByName(INFOPARAM_NAME,true);
		$this->getChildInstanceByName(INFOPARAM_SHORTNAME,true);
		$this->getChildInstanceByName(INFOPARAM_COMPONENTS,true);
		$this->getChildInstanceByName(INFOPARAM_UNITS,true);
		$this->getChildInstanceByName(INFOPARAM_COORDSYS,true);
		$this->getChildInstanceByName(INFOPARAM_TENSORORDER,true);
		$this->getChildInstanceByName(INFOPARAM_SICONV,true);
		$this->getChildInstanceByName(INFOPARAM_TABLE,true);
		$this->getChildInstanceByName(INFOPARAM_FILLVAL,true);
		$this->getChildInstanceByName(INFOPARAM_UCD,true);
		//$this->getChildInstanceByName(INFOPARAM_STATUSDEF,true);
		$this->getChildInstanceByName(INFOPARAM_DATASETID,true);
	}

	public function setName($name)
	{
		$node = $this->getChildInstanceByName(INFOPARAM_NAME,true);
		$node->setValue($sampling);
	}
	
	public function addTable($type, $name)
	{
		$node = $this->getChildInstanceByName(INFOPARAM_TABLE, true);
		
		switch ($type)
		{
			case InfoParamTableTypeEnum::BOUNDS :
				$tableDef = new InfoParamTableDefBoundsNodeClass();
				break;
			case InfoParamTableTypeEnum::MINMAX :
				$tableDef = new InfoParamTableDefMinMaxNodeClass();
				break;
			case InfoParamTableTypeEnum::CENTER :
				$tableDef = new InfoParamTableDefCenterNodeClass();
				break;
			case InfoParamTableTypeEnum::CENTERWIDTH :
				$tableDef = new InfoParamTableDefCenterWidthNodeClass();
				break;
			default :
				throw new Exception('Table definition node not implemented');
		}
		
		$tableDef->setTableName($name);
		
		$node->addChild($tableDef);
		
		return $tableDef;
	}
}

?>