/**
 * OutputAnalyzer.hpp
 *
 *  Created on: Jan 22, 2019
 *      Author: vadims
 Abstract class, used to analyze ouput of the simulation software

 */
#include <fstream>
#include <stdexcept>
#include "OutputAnalyzer.hpp"
#include "cenos_exception.h"

OutputAnalyzer::OutputAnalyzer(MessageQueue_ messageQueue_) : messageQueue(messageQueue_)
{
	//read regexJson.json from config
	char const* tmp = getenv("CENOS_CONFIG");
	if (!tmp) {
		throw cenos_exception("variable CENOS_CONFIG not set ");
	}

	std::string cenos_env(tmp);
	std::string str;
	std::ifstream inFile;
	inFile.open(cenos_env + "\\jsons\\regexJson.json");
	if (inFile.is_open()) {
		std::stringstream strStream;
		strStream << inFile.rdbuf();
		str = strStream.str();
	}
	else {
		throw cenos_exception("No regex config file found. ");
	}
	inFile.close();

	std::istringstream iss(str);
	iss >> regexJson;
}

OutputAnalyzer::~OutputAnalyzer()
{
}