ZipPostProcessing.cc 1.49 KB
/*
 * ZipPostProcessing.cc
 *
 *  Created on: 25 sept. 2013
 *      Author: CS
 */

#include "ZipPostProcessing.hh"
#include "ArchiveWriter.hh"
#include "ZipNode.hh"
#include "PostProcessingRegistry.hh"

namespace postprocessing {

const std::string ZipPostProcessing::EXTENSION = ".zip";

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

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

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

}

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

}

ZipPostProcessing::~ZipPostProcessing() {
}

/**
 * Applies post-processing.
 */

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

std::string ZipPostProcessing::zip(const std::vector<std::string>& pFiles, const std::string& pPrefix,
		const std::string& pOutDir) {
	return ArchiveWriter::createArchive(ArchiveWriter::Formats::ZIP, EXTENSION,
			pFiles, pPrefix, pOutDir);
}

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

} /* namespace postprocessing */