All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SimulationLogger.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 
33 
34 /**
35  @file
36 
37  @author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
38 */
39 
40 
41 #ifndef __SIMULATIONLOGGER_HPP__
42 #define __SIMULATIONLOGGER_HPP__
43 
44 #include <string>
45 #include <fstream>
46 
47 #include <openfluid/dllexport.hpp>
50 
52 
53 
54 namespace openfluid { namespace base {
55 
56 /**
57  Class for managing messages during execution
58 
59  @author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
60 */
62 {
63 
64  private:
65 
66  std::ofstream m_LogFile;
67 
68  bool m_WarningFlag;
69 
70  unsigned int m_RealWarningsCount;
71 
72  void addLog(const std::string& Prefix,
73  const std::string& Sender,
74  const std::string& Source,
75  const openfluid::core::TimeIndex_t& TimeIndex,
76  const std::string& Msg);
77 
78  void addLog(const std::string& Prefix,
79  const std::string& Sender,
80  const openfluid::core::TimeIndex_t& TimeIndex,
81  const std::string& Msg);
82 
83  void addLog(const std::string& Prefix,
84  const std::string& Sender,
85  const std::string& Source,
86  const std::string& Msg);
87 
88  void addLog(const std::string& Prefix,
89  const std::string& Sender,
90  const std::string& Msg);
91 
92  void addLog(const std::string& Prefix,
93  const std::string& Msg);
94 
95 
96  public:
97 
98  SimulationLogger(const std::string& LogFilePath);
99 
100 
101  ~SimulationLogger();
102 
103 
104  void addWarning(const std::string& Sender, const std::string& Source, const openfluid::core::TimeIndex_t& TimeIndex, const std::string& Msg)
105  { addLog("[Warning]",Sender,Source, TimeIndex, Msg); m_WarningFlag = true; m_RealWarningsCount++; };
106 
107 
108  void addWarning(const std::string& Sender, const openfluid::core::TimeIndex_t& TimeIndex, const std::string& Msg)
109  { addLog("[Warning]",Sender,TimeIndex, Msg); m_WarningFlag = true; m_RealWarningsCount++; };
110 
111 
112  void addWarning(const std::string& Sender, const std::string& Source, const std::string& Msg)
113  { addLog("[Warning]",Sender,Source,Msg); m_WarningFlag = true; m_RealWarningsCount++; };
114 
115 
116  void addWarning(const std::string& Sender, const std::string& Msg)
117  { addLog("[Warning]",Sender,Msg); m_WarningFlag = true; m_RealWarningsCount++; };
118 
119 
120  void addMessage(const std::string& Sender, const std::string& Source, const openfluid::core::TimeIndex_t& TimeIndex, const std::string& Msg)
121  { addLog("[Message]",Sender,Source, TimeIndex, Msg); };
122 
123 
124  void addMessage(const std::string& Sender, const openfluid::core::TimeIndex_t& TimeIndex, const std::string& Msg)
125  { addLog("[Message]",Sender, TimeIndex, Msg); };
126 
127 
128  void addMessage(const std::string& Sender, const std::string& Source, const std::string& Msg)
129  { addLog("[Message]",Sender,Source, Msg); };
130 
131 
132  void addMessage(const std::string& Sender, const std::string& Msg)
133  { addLog("[Message]",Sender,Msg); };
134 
135 
136  void addInfo(const std::string& Sender, const std::string& Msg)
137  { addLog("[Info]",Sender,Msg); };
138 
139 
140  void addInfo(const std::string& Msg)
141  { addLog("[Info]",Msg); };
142 
143 
144  inline void resetWarningFlag() { m_WarningFlag = false; };
145 
146 
147  inline bool isWarningFlag() const { return m_WarningFlag; };
148 
149 
150  inline unsigned int getWarningsCount() const { return m_RealWarningsCount; };
151 
152 };
153 
154 
155 } } // namespaces
156 
157 
158 #endif /*__SIMULATIONLOGGER_HPP__*/
159 
void addWarning(const std::string &Sender, const std::string &Source, const std::string &Msg)
Definition: SimulationLogger.hpp:112
unsigned long long TimeIndex_t
Definition: DateTime.hpp:62
void resetWarningFlag()
Definition: SimulationLogger.hpp:144
void addInfo(const std::string &Sender, const std::string &Msg)
Definition: SimulationLogger.hpp:136
void addWarning(const std::string &Sender, const std::string &Msg)
Definition: SimulationLogger.hpp:116
Definition: SimulationLogger.hpp:61
void addMessage(const std::string &Sender, const std::string &Msg)
Definition: SimulationLogger.hpp:132
void addWarning(const std::string &Sender, const openfluid::core::TimeIndex_t &TimeIndex, const std::string &Msg)
Definition: SimulationLogger.hpp:108
unsigned int getWarningsCount() const
Definition: SimulationLogger.hpp:150
void addWarning(const std::string &Sender, const std::string &Source, const openfluid::core::TimeIndex_t &TimeIndex, const std::string &Msg)
Definition: SimulationLogger.hpp:104
void addInfo(const std::string &Msg)
Definition: SimulationLogger.hpp:140
bool isWarningFlag() const
Definition: SimulationLogger.hpp:147
void addMessage(const std::string &Sender, const std::string &Source, const openfluid::core::TimeIndex_t &TimeIndex, const std::string &Msg)
Definition: SimulationLogger.hpp:120
void addMessage(const std::string &Sender, const std::string &Source, const std::string &Msg)
Definition: SimulationLogger.hpp:128
void addMessage(const std::string &Sender, const openfluid::core::TimeIndex_t &TimeIndex, const std::string &Msg)
Definition: SimulationLogger.hpp:124
#define DLLEXPORT
Definition: dllexport.hpp:51