RequestFramesUpdate.cpp 2.16 KB
#include "RequestFramesUpdate.h"

#include "../FrameManager/FrameManager.h"
#include "../Transformation/TransformationCDPP3DView.h"

using namespace TREPS::FrameManager;
using namespace TREPS::Transformation;

namespace TREPS
{
	namespace RequestManager
	{
		RequestFramesUpdateClass::RequestFramesUpdateClass(void):RequestAbstractClass()
		{
			this->outputType = OUTPUT_XMLFILE;
		}

		RequestFramesUpdateClass::~RequestFramesUpdateClass(void)
		{
		}

		string RequestFramesUpdateClass::getRequestId(void)
                {
                        return "frames_update";
                }

		bool RequestFramesUpdateClass::load(RequestLoaderClass *loader)
		{
			//nothing to do
			return true;
		}

		bool RequestFramesUpdateClass::run(void)
		{
			this->updatedFile = "";

			//create a transformation manager
			TransformationAbstractClass *transMgr = new TransformationCDPP3DViewClass(this);

			//get the available frame list for this engine
			t_StringList frameList = transMgr->getAvailableFrameList();

			delete transMgr;

			if (frameList.empty())
			{
				LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Empty frame list");
				return false;
			}

			string framesFile = this->app->getConf()->getFramesFilePath();

			if (framesFile.compare("") == 0)
				return false;

			//create frame manager class
			FrameManagerClass *frameMgr = new FrameManagerClass();

			if (!frameMgr->init(framesFile.c_str()))
			{
				delete frameMgr;
				LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Cannot init frames manager");
				return false;
			}

			//create result file path
			string newFrameFile = framesFile;
			newFrameFile += ".new";

			//update frame list
			bool res = frameMgr->updateFrameList(frameList,newFrameFile.c_str());

			if (res)
				this->updatedFile = newFrameFile;

			delete frameMgr;

			return res;
		}
		
		void RequestFramesUpdateClass::writeResult(ResultWriterClass *writer)
		{
			//No result file for this request
		}

		string RequestFramesUpdateClass::getResultFileSuffix(void)
		{
			return "";
		}

		string RequestFramesUpdateClass::getXMLFilePath(void)
		{
			return this->updatedFile;
		}

		string RequestFramesUpdateClass::getStringResult(void)
		{
			return "";
		}
	}
}