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 "errut/errorbase.h"
10 #include <stdio.h>
11 
13 class LogFile : public errut::ErrorBase
14 {
15 public:
16  LogFile();
17  ~LogFile();
18 
20  bool open(const std::string &fileName);
21 
23  std::string getFileName() const { return m_fileName; }
24 
26  void print(const char *format, ...);
27 
29  void printNoNewLine(const char *format, ...);
30 
32  void close();
33 private:
34  FILE *m_pFile;
35  std::string m_fileName;
36 };
37 
38 #endif // LOGFILE_H
bool open(const std::string &fileName)
Opens the specified file for writing.
Definition: logfile.cpp:18
Base class which allows an error message to be set.
Definition: errorbase.h:49
Helper class to write to a log file.
Definition: logfile.h:13
void close()
Finalizes and closes the log file.
Definition: logfile.cpp:47
std::string getFileName() const
Returns the filename from the 'open' call.
Definition: logfile.h:23
void print(const char *format,...)
Writes the specified parameters (similar to printf) to the logfile, automatically appending a newline...
Definition: logfile.cpp:56
void printNoNewLine(const char *format,...)
Writes the specified parameters (similar to printf) to the logfile.
Definition: logfile.cpp:70