Simpact Cyan
Population based event driven simulation using mNRM
logfile.h
Go to the documentation of this file.
1 #ifndef LOGFILE_H
2 
3 #define LOGFILE_H
4 
9 #include "booltype.h"
10 #include <stdio.h>
11 #include <vector>
12 
14 class LogFile
15 {
16 public:
17  LogFile();
18  virtual ~LogFile();
19 
21  bool_t open(const std::string &fileName);
22 
23  bool isOpen() const { return m_pFile != 0; }
24 
26  std::string getFileName() const { return m_fileName; }
27 
29  void print(const char *format, ...);
30 
32  void printNoNewLine(const char *format, ...);
33 
35  void close();
36 
39  static void writeToAllLogFiles(const std::string &str);
40 private:
41  FILE *m_pFile;
42  std::string m_fileName;
43 
44  static std::vector<LogFile *> s_allLogFiles;
45 };
46 
47 #endif // LOGFILE_H
bool_t open(const std::string &fileName)
Opens the specified file for writing.
Definition: logfile.cpp:32
Type to return true/false with error description.
Definition: booltype.h:25
Helper class to write to a log file.
Definition: logfile.h:14
void close()
Finalizes and closes the log file.
Definition: logfile.cpp:54
static void writeToAllLogFiles(const std::string &str)
Method to write something to all currently open log files, useful when program aborts and a message s...
Definition: logfile.cpp:91
std::string getFileName() const
Returns the filename from the 'open' call.
Definition: logfile.h:26
void print(const char *format,...)
Writes the specified parameters (similar to printf) to the logfile, automatically appending a newline...
Definition: logfile.cpp:63
void printNoNewLine(const char *format,...)
Writes the specified parameters (similar to printf) to the logfile.
Definition: logfile.cpp:77