MolSim
Loading...
Searching...
No Matches
FileWriter.h
Go to the documentation of this file.
1
10#pragma once
12#include <fstream>
13#include <string>
14
17 protected:
19 std::ofstream m_file;
20
21 public:
24
30 explicit FileWriter(const std::string &filename);
31
33 virtual ~FileWriter();
34
40 void openFile(const std::string &filename);
41
43 void closeFile();
44
53 static void initializeFolder(const std::string &dirname);
54
65 void writeFile(const std::string &content, const std::string &filename = "", int iteration = -1, int total = -1);
66
75 virtual void writeParticles(const ParticleContainer &particles, int iteration, int total) = 0;
76};
Class for encapsulating and iterating over multiple Particle objects.
Superclass which implements functionality to output data to a file on disk.
Definition FileWriter.h:16
std::ofstream m_file
Output stream containing the file to write contents to.
Definition FileWriter.h:19
void closeFile()
Closes the opened file if it exists, otherwise does nothing.
FileWriter(const std::string &filename)
Creates a new FileWriter and opens the file with the given name.
static void initializeFolder(const std::string &dirname)
(Re)initializes the output directory.
virtual void writeParticles(const ParticleContainer &particles, int iteration, int total)=0
Interface function for writing the type, mass, position, velocity and force of a ParticleContainer to...
FileWriter()
Creates a new FileWriter with no file initialized.
virtual ~FileWriter()
Closes the opened file and destroys the FileWriter object.
void openFile(const std::string &filename)
Opens / creates the file with the given name.
void writeFile(const std::string &content, const std::string &filename="", int iteration=-1, int total=-1)
Overwrites the contents of the file opened in m_file with a given string. On error,...
Class for encapsulating multiple Particle objects..
Definition ParticleContainer.h:17