File NPOptionManager.h
File List > core > NPOptionManager.h
Go to the documentation of this file
#ifndef NPOptionManager_h
#define NPOptionManager_h
// C++ headers
#include <iostream>
#include <map>
#include <string>
#include <vector>
namespace nptool {
class OptionManager {
public:
// Constructor
OptionManager(){};
OptionManager(int argc, char** argv);
OptionManager(std::string arg);
~OptionManager(){};
public:
// Read the input argument
void ReadArgument(int argc = 0, char** argv = NULL);
void ReadArgument(std::string arg);
// Look for and Read the project config file if existing
void ReadProjectConfigFile(std::string app_name);
private:
void DisplayHelp();
private:
// A map of <flag,arg>
std::map<std::string, std::string> m_option;
std::map<std::string, bool> m_used;
int m_argc;
char** m_argv;
private:
std::string m_app_name;
std::string m_ConversionOutputPath; // output path of converted tree
std::string m_AnalysisOutputPath; // output path of analysed tree
std::string m_SimulationOutputPath; // output path of simulated tree
std::string m_DefaultOutputPath; // output path of non standard app
std::string m_EnergyLossPath; // input/output path of energy loss table
std::string m_OnlineMacroPath; // input/output path of energy loss table
public: // Access to the option
unsigned int NumberOfFlags();
bool HasFlag(std::string flag);
std::string GetArg(std::string flag);
std::vector<std::string> GetVectorArg(std::string flag);
int GetIntArg(std::string flag);
std::vector<std::string> ListIgnoredFlag();
void PrintIgnoredFlag();
std::string GetConversionOutputPath() { return m_ConversionOutputPath; };
std::string GetAnalysisOutputPath() { return m_AnalysisOutputPath; };
std::string GetSimulationOutputPath() { return m_SimulationOutputPath; };
std::string GetDefaultOutputPath() { return m_DefaultOutputPath; };
std::string GetEnergyLossPath() { return m_EnergyLossPath; };
std::string GetOnlineMacroPath() { return m_OnlineMacroPath; };
// return outpath based on app name
std::string GetOutputPath() {
if (m_app_name == "npconversion") {
return m_ConversionOutputPath;
}
else if (m_app_name == "npanalysis") {
return m_AnalysisOutputPath;
}
else if (m_app_name == "npsimulation") {
return m_SimulationOutputPath;
}
else {
return m_DefaultOutputPath;
}
};
int GetArgcArgv(char**& argv) {
argv = m_argv;
return m_argc;
};
};
} // namespace nptool
#endif