RequestOutputPlotNodeClass.php 2.6 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);
		}

		$node->addPostProcessing($process);
	}

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

		if ($node == NULL)
			return false;
			
		return $node->isPostProcessing($process);
	}
}

?>