DataMiningNode.cc 2.97 KB
/*
 * DataMiningNode.cc
 *
 *  Created on: 23 août 2013
 *      Author: CS
 */

#include <string.h>

// Common module includes
#include "OutputFormatTime.hh"

// Parameters module includes
#include "ServicesServer.hh"
#include "Parameter.hh"
#include "FileConfigurator.hh"
#include "ParameterManager.hh"

// XMLConfigurator module includes
#include "Constant.hh"

// DataMining module includes
#include "Config.hh"
#include "ParamNode.hh"
#include "DataMiningNode.hh"
#include "ParamOutputDataMining.hh"
#include "DataMiningType.hh"
#include "PostProcessingNode.hh"

using namespace AMDA::Parameters;
using namespace AMDA::XMLConfigurator;

namespace AMDA {
	namespace ParamOutputImpl {
		namespace DataMining {

			DataMiningNode::DataMiningNode(ParamOutputDataMining::PRIORITY pTaskPriority) : NodeGrpCfg(), _outputPriority(pTaskPriority) {
				/*
					<dataMining>
						<timeFormat/>
						<fileFormat/>
						<outputStructure/>
						<param id='imf'/>
					</dataMining>
				*/
				// Assign a class node on each parameter of Data Mining output to retrieve value.
				getChildList()["timeFormat"] = NodeCfgSPtr(new TimeFormatNode<ParamOutputDataMining>());
				getChildList()["fileFormat"] = NodeCfgSPtr(new FileFormatNode<ParamOutputDataMining>());
				getChildList()["outputStructure"] = NodeCfgSPtr(new OutputStructureNode<ParamOutputDataMining>());
				getChildList()["fileName"] = NodeCfgSPtr(new FileNameNode<ParamOutputDataMining>());
				getChildList()["param"] = NodeCfgSPtr(new ParamNode<ParamOutputDataMining>());
				getChildList()["postProcess"] = NodeCfgSPtr(new postprocessing::PostProcessingNode<ParamOutputDataMining>());
			}


			void DataMiningNode::proceed(xmlNodePtr pNode,
					const AMDA::Parameters::CfgContext& pContext) {

				// Get manager of the new output parameter for this node
				ParameterManager* lParameterManager = pContext.get<ParameterManager*>();
				CfgContext lContext;

				// Create DataMining instance
				boost::shared_ptr<ParamOutputDataMining> lParamOutputDataMining(new ParamOutputDataMining(*lParameterManager));

				// Set priority
				lParamOutputDataMining->setOutputPriority(_outputPriority);

				// Push data mining in the context
				lContext.push<ParamOutputDataMining*>(lParamOutputDataMining.get());

				// Go to next node
				NodeGrpCfg::proceed(pNode, lContext);
				// Set param output in parameter manager list to be executed
				lParameterManager->getParamOutputList().push_back(lParamOutputDataMining);

				// When Data Mining output is set in param tag, param id can be retrived automatically.
				// So it's not necessary to set param tag in Data Mining output to identify param id.
				if (_outputPriority == ParamOutputDataMining::PRIORITY::PARAM) {
					xmlChar* paramName = NULL;
					paramName = xmlGetProp(pNode->parent->parent, (const xmlChar *) "id");
					lParamOutputDataMining->setParamName(reinterpret_cast<const char*>(paramName));
					xmlFree(paramName);
				}

			}

		} // namespace Download
	} // namespace ParamOutputImpl
} // namespace AMDA