/**
 *  \brief     SalomeModule  class.
 *  \details   Used to run Salome
 *  \author    vadims
 *  \date      Dec 17, 2019
 *  \bug       Not all memory is freed when deleting an object of this class.
 *  \warning   Improper use can crash your application
 *  \copyright CENOS LLC
 */

#ifndef SALOMEMODULE_H_
#define SALOMEMODULE_H_
#include <WinSock2.h>
#include <Windows.h>
#include <string>
#include <optional>
#include "Module.hpp"
#include "nlohmann/json.hpp"
#include "misc/messagedata.hpp"

using json = nlohmann::json;

class SalomeModule : public Module {
public:
	SalomeModule();
	~SalomeModule();
	enum RunMode 
	{
		GUI,
		BATCH,
		BATCH_NO_RESPONSE
	};

	void setWDir(std::string);
	void setGuid(std::string);
	void setRunMode(RunMode rm);

	messagedata runSalome();

	bool writeLoadCadScript(std::vector<std::string> cadfiles);
	void writeSalomeOpeningScript(std::optional<std::string> hdfFile = {});
	void writeUpdateSalomeScript(json geometryData);
	bool writeDumpScript(json params);
	void writeGenerateGeometryDataScript(std::vector<std::string> groupNames);
	void writeGenerateGroupsFromGeometryData(json geom_data_json, json phys_json);
	bool isSalomeRunning();
	void stop();

private:
	std::string wDir;
	std::string guid;
	std::optional<std::string> getSalomePath();
	bool stopRequired;
	RunMode run_mode;

};


#endif /* SALOMEMODULE_H_ */