OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
FileSink.h
Go to the documentation of this file.
1 #ifndef __TRACE_FILE_SINK_H__
2 #define __TRACE_FILE_SINK_H__
3 
4 #include <sstream>
5 #include <iostream>
6 #include <fstream>
7 
9 
10 class FileSink : public TraceComponent {
11 
12 public:
13 
14 
15  FileSink(std::string filename)
16  : TraceComponent("FileSink")
17  , filename_(filename)
18  {}
19 
20  virtual ~FileSink()
21  {}
22 
23  void execute(std::ostringstream &dump) {
24  std::ofstream file;
25  file.open(filename_.c_str(), std::ios::app);
26  file << dump.str() << std::flush;
27  file.close();
28  }
29 
30 private:
31 
32  std::string filename_;
33 
34 };
35 
36 #endif
void execute(std::ostringstream &dump)
Definition: FileSink.h:23
std::string filename_
Definition: FileSink.h:32
FileSink(std::string filename)
Definition: FileSink.h:15
virtual ~FileSink()
Definition: FileSink.h:20