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
00038
00039
00040
00041 #ifndef __SIMULATIONLOGGER_HPP__
00042 #define __SIMULATIONLOGGER_HPP__
00043
00044 #include <string>
00045 #include <fstream>
00046
00047 #include <openfluid/dllexport.hpp>
00048 #include <openfluid/core/TypeDefs.hpp>
00049 #include <openfluid/core/DateTime.hpp>
00050
00051 #include <openfluid/tools/SwissTools.hpp>
00052
00053
00054 namespace openfluid { namespace base {
00055
00056
00057
00058
00059
00060
00061 class DLLEXPORT SimulationLogger
00062 {
00063
00064 private:
00065
00066 std::ofstream m_LogFile;
00067
00068 bool m_WarningFlag;
00069
00070 unsigned int m_RealWarningsCount;
00071
00072 void addLog(const std::string& Prefix,
00073 const std::string& Sender,
00074 const std::string& Source,
00075 const openfluid::core::TimeIndex_t& TimeIndex,
00076 const std::string& Msg);
00077
00078 void addLog(const std::string& Prefix,
00079 const std::string& Sender,
00080 const openfluid::core::TimeIndex_t& TimeIndex,
00081 const std::string& Msg);
00082
00083 void addLog(const std::string& Prefix,
00084 const std::string& Sender,
00085 const std::string& Source,
00086 const std::string& Msg);
00087
00088 void addLog(const std::string& Prefix,
00089 const std::string& Sender,
00090 const std::string& Msg);
00091
00092 void addLog(const std::string& Prefix,
00093 const std::string& Msg);
00094
00095
00096 public:
00097
00098 SimulationLogger(const std::string& LogFilePath);
00099
00100
00101 ~SimulationLogger();
00102
00103
00104 void addWarning(const std::string& Sender, const std::string& Source, const openfluid::core::TimeIndex_t& TimeIndex, const std::string& Msg)
00105 { addLog("[Warning]",Sender,Source, TimeIndex, Msg); m_WarningFlag = true; m_RealWarningsCount++; };
00106
00107
00108 void addWarning(const std::string& Sender, const openfluid::core::TimeIndex_t& TimeIndex, const std::string& Msg)
00109 { addLog("[Warning]",Sender,TimeIndex, Msg); m_WarningFlag = true; m_RealWarningsCount++; };
00110
00111
00112 void addWarning(const std::string& Sender, const std::string& Source, const std::string& Msg)
00113 { addLog("[Warning]",Sender,Source,Msg); m_WarningFlag = true; m_RealWarningsCount++; };
00114
00115
00116 void addWarning(const std::string& Sender, const std::string& Msg)
00117 { addLog("[Warning]",Sender,Msg); m_WarningFlag = true; m_RealWarningsCount++; };
00118
00119
00120 void addMessage(const std::string& Sender, const std::string& Source, const openfluid::core::TimeIndex_t& TimeIndex, const std::string& Msg)
00121 { addLog("[Message]",Sender,Source, TimeIndex, Msg); };
00122
00123
00124 void addMessage(const std::string& Sender, const openfluid::core::TimeIndex_t& TimeIndex, const std::string& Msg)
00125 { addLog("[Message]",Sender, TimeIndex, Msg); };
00126
00127
00128 void addMessage(const std::string& Sender, const std::string& Source, const std::string& Msg)
00129 { addLog("[Message]",Sender,Source, Msg); };
00130
00131
00132 void addMessage(const std::string& Sender, const std::string& Msg)
00133 { addLog("[Message]",Sender,Msg); };
00134
00135
00136 void addInfo(const std::string& Sender, const std::string& Msg)
00137 { addLog("[Info]",Sender,Msg); };
00138
00139
00140 void addInfo(const std::string& Msg)
00141 { addLog("[Info]",Msg); };
00142
00143
00144 inline void resetWarningFlag() { m_WarningFlag = false; };
00145
00146
00147 inline bool isWarningFlag() const { return m_WarningFlag; };
00148
00149
00150 inline unsigned int getWarningsCount() const { return m_RealWarningsCount; };
00151
00152 };
00153
00154
00155 } }
00156
00157
00158 #endif
00159