RequestOutputPlotFillsNodeClass.php 1.42 KB
<?php

require_once "RequestOutputPlotFillSerieConstantNodeClass.php";
require_once "RequestOutputPlotFillSerieSerieNodeClass.php";

define ("REQUESTOUTPUTPLOTFILLS_NAME", "fills");

abstract class RequestOutputPlotFillTypeEnum
{
	const SERIESERIE    = "serie-serie";
	const SERIECONSTANT = "serie-constant";
}

/**
 * @class RequestOutputPlotFillsNodeClass
 * @brief Definition of fills for a plot
 * @details
 */
class RequestOutputPlotFillsNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTPLOTFILLS_NAME);
	}
	
	public function addFill($type)
	{
		switch ($type)
		{
			case RequestOutputPlotFillTypeEnum::SERIECONSTANT :
				$node = new RequestOutputPlotFillSerieConstantNodeClass();
				break;
			case RequestOutputPlotFillTypeEnum::SERIESERIE :
			default :
				$node = new RequestOutputPlotFillSerieSerieNodeClass();
				break;
		}
		
		$this->addChild($node);
		return $node;
	}
	
	public function loadFromNode($xmlNode)
	{
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTOUTPUTPLOTFILLSERIECONSTANT_NAME) as $fillserieconstantXmlNode) {
			$this->addFill(RequestOutputPlotFillTypeEnum::SERIECONSTANT)->loadFromNode($fillserieconstantXmlNode);
		}
		
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTOUTPUTPLOTFILLSERIESERIE_NAME) as $fillserieserieXmlNode) {
			$this->addFill(RequestOutputPlotFillTypeEnum::SERIESERIE)->loadFromNode($fillserieserieXmlNode);
		}
	}
}

?>