TarPostProcessing.cc 1.52 KB
/*
 * TarPostProcessing.cc
 *
 *  Created on: 26 sept. 2013
 *      Author: CS
 */

#include "TarPostProcessing.hh"
#include "ArchiveWriter.hh"
#include "TarNode.hh"
#include "PostProcessingRegistry.hh"

namespace postprocessing {

const std::string TarPostProcessing::EXTENSION = ".tar";

/**
 * Self-registering to post-processing factory
 */

std::string TarPostProcessing::_key =
		PostProcessingRegistry::getInstance().addElement(EXTENSION,
				new TarPostProcessing());

TarPostProcessing::TarPostProcessing() :
		PostProcessing(), _parentName(std::string()) {

}

TarPostProcessing::TarPostProcessing(const std::string& pParentName) :
		PostProcessing(), _parentName(pParentName) {

}

TarPostProcessing::~TarPostProcessing() {

}

/**
 * Applies post-processing.
 */

void TarPostProcessing::apply(PostProcessingAble* pOutput) {
	_outputDestination = pOutput->getDestination();
	_files.push_back(tar(pOutput->getOutputs(), _parentName, pOutput->getDestination()));
}

/**
 * Archives some files.
 */

std::string TarPostProcessing::tar(const std::vector<std::string>& pFiles, const std::string& pPrefix,
		const std::string& pOutDir) {
	return ArchiveWriter::createArchive(ArchiveWriter::Formats::TAR, EXTENSION, pFiles, pPrefix,
			pOutDir);
}

/**
 * Registers related node and process.
 */
void TarPostProcessing::registerChildList(
		std::map<std::string, boost::shared_ptr<AMDA::XMLConfigurator::NodeCfg>>& childList) {
	childList["tar"] = boost::shared_ptr<AMDA::XMLConfigurator::NodeCfg>(
			new TarNode());
}


} /* namespace postprocessing */