00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef __ONIKIRI_ENV_H
00038 #define __ONIKIRI_ENV_H
00039
00040 #include "Utility/String.h"
00041 #include "Env/Param/ParamExchange.h"
00042
00043 namespace Onikiri
00044 {
00045
00046 class Environment : public ParamExchange
00047 {
00048 std::vector<String> m_cmdLineArgs;
00049 std::vector<String> m_cfgXmlFiles;
00050 String m_startupPath;
00051
00052 u64 m_execBeginTime;
00053 u64 m_execPeriod;
00054 String m_versionString;
00055 String m_sessionName;
00056 String m_errorMsg;
00057 bool m_error;
00058 bool m_dumpSuccess;
00059
00060 void BeginExec();
00061 void EndExec();
00062 void DumpResult();
00063
00064 class Path : public ParamExchangeChild
00065 {
00066 String m_execFilePath;
00067 String m_startupPath;
00068
00069 String m_path;
00070 bool m_useXMLFile;
00071 bool m_useSimulatorExecFile;
00072 public:
00073
00074 BEGIN_PARAM_MAP("")
00075 PARAM_ENTRY( "@Path", m_path )
00076 PARAM_ENTRY( "@UseXMLFilePath", m_useXMLFile )
00077 PARAM_ENTRY( "@UseSimulatorExecFilePath", m_useSimulatorExecFile )
00078 END_PARAM_MAP()
00079
00080 Path();
00081 String Get();
00082 void Initialize( Environment& env );
00083 };
00084 Path m_hostWorkPath;
00085 String m_outputXMLFileName;
00086 String m_outputXMLLevel;
00087 String m_outputXMLFilter;
00088
00089 bool m_outputPrintToSTDOUT;
00090 String m_outputPrintFileName;
00091 std::ofstream m_outputPrintStream;
00092
00093 bool m_suppressInternalMessage;
00094 bool m_suppressWarning;
00095 bool m_paramDBInitialized;
00096 public:
00097 BEGIN_PARAM_MAP("/Session/")
00098 PARAM_ENTRY("@Name", m_sessionName)
00099 PARAM_ENTRY("Result/@ExecutionPeriod", m_execPeriod)
00100 PARAM_ENTRY("Result/@VersionNumber", m_versionString)
00101 PARAM_ENTRY("Result/@Error", m_error)
00102 PARAM_ENTRY("Environment/OutputXML/@FileName", m_outputXMLFileName)
00103 PARAM_ENTRY("Environment/OutputXML/@Level", m_outputXMLLevel)
00104 PARAM_ENTRY("Environment/OutputXML/@Filter", m_outputXMLFilter)
00105 PARAM_ENTRY("Environment/Print/@FileName", m_outputPrintFileName)
00106 PARAM_ENTRY("Environment/Print/@SuppressInternalMessage", m_suppressInternalMessage)
00107 PARAM_ENTRY("Environment/Print/@SuppressWarningMessage", m_suppressWarning)
00108 CHAIN_PARAM_MAP("Environment/HostWorkPath/", m_hostWorkPath)
00109 END_PARAM_MAP()
00110
00111 Environment();
00112 ~Environment();
00113 void Initialize(int argc, char* argv[], const std::vector<String>& defaultParams = std::vector<String>());
00114 void Finalize();
00115
00116 void Print(const std::string& str);
00117 void Print(const char* str, ...);
00118 void PrintInternal(const char* str, ...);
00119
00120 void SetError( bool error, const std::string& msg );
00121 void SetWarning(bool warning);
00122 bool IsDumpSuccess();
00123 void PrintFatalErrorXML();
00124
00125 const std::vector<String>& GetCmdLineArgs();
00126 const std::vector<String>& GetCfgXmlFiles();
00127 String GetStartupPath();
00128 String GetHostWorkPath();
00129
00130 bool IsSuppressedInternalMessage();
00131 };
00132
00133 extern Environment g_env;
00134
00135 }
00136
00137 #endif
00138