RequestOutputPlotNodeClass.php 3.57 KB
<?php

require_once("RequestOutputPlotPageNodeClass.php");
require_once("RequestOutputPostProcessingNodeClass.php");

define ("REQUESTOUTPUTPLOT_NAME", "plot");
define ("REQUESTOUTPUTPLOT_WRITECONTEXTFILE", "writeContextFile");
define ("REQUESTOUTPUTPLOT_STRUCTURE", "outputStructure");
define ("REQUESTOUTPUTPLOT_FILEPREFIX", "filePrefix");

abstract class RequestOutputPlotStructureEnum
{
	const ONE_FILE              = "one-file";
	const ONE_FILE_PER_INTERVAL = "one-file-per-interval";
}

/**
 * @class RequestOutputPlotNodeClass
 * @brief Definition of a request plot output node for AMDA_Kernel
 * @details
 */
class RequestOutputPlotNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTPLOT_NAME);
		//default properties
		$this->setStructure(RequestOutputPlotStructureEnum::ONE_FILE);
		//default prefix
		$this->setFilePrefix("plot");
		//force page construction
		$this->getPage();
	}

	public function setStructure($type)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTPLOT_STRUCTURE, true);
		$node->setValue($type);
	}

	public function getStructure()
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTPLOT_STRUCTURE);
		return (($node == NULL) ? RequestOutputPlotStructureEnum::ONE_FILE : $node->getValue());
	}
	
	public function setWriteContextFile($write)
	{
		$this->setAttribute(REQUESTOUTPUTPLOT_WRITECONTEXTFILE, $write);
	}
	
	public function getWriteContextFile()
	{
		return $this->getAttribute(REQUESTOUTPUTPLOT_WRITECONTEXTFILE);
	}

	public function setFilePrefix($prefix)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTPLOT_FILEPREFIX, true);
		$node->setValue($prefix);
	}
	
	public function getFilePrefix()
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTPLOT_FILEPREFIX);
		return (($node == NULL) ? "" : $node->getValue());
	}
	
	public function getPage()
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTPAGE_NAME);
		if (!isset($node))
		{
			$node = new RequestOutputPlotPageNodeClass();
			$this->addChild($node);
		}
		return $node;
	}

	public function addPostProcessing($process = "")
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTPOSTPROCESSING_NAME);
		if ($node == NULL)
		{
			$node = new RequestOutputPostProcessingNodeClass();
			$this->addChild($node);
		}

		if ($process == "")
			$node->addPostProcessing($process);
		
		return $node;
	}

	public function isPostProcessing($process)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTPOSTPROCESSING_NAME);

		if ($node == NULL)
			return false;
			
		return $node->isPostProcessing($process);
	}
	
	public function loadFromNode($xmlNode)
	{
		$structureXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOT_STRUCTURE);
		if (isset($structureXmlNode))
			$this->setStructure($this->getXmlNodeValue($structureXmlNode));
		
		$this->setWriteContextFile($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOT_WRITECONTEXTFILE));
		
		$fileprefixXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOT_FILEPREFIX);
		if (isset($fileprefixXmlNode))
			$this->setFilePrefix($this->getXmlNodeValue($fileprefixXmlNode));
		
		$pageXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTPAGE_NAME);
		if (isset($pageXmlNode))
			$this->getPage()->loadFromNode($pageXmlNode);
		
		$postprocessingXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPOSTPROCESSING_NAME);
		if (isset($postprocessingXmlNode))
			$this->addPostProcessing()->loadFromNode($postprocessingXmlNode);
	}
}

?>