102 const std::string&
getName()
const;
113 void setName(
const std::string& name);
173 void read(std::istream& is);
178 void write(std::ostream& os)
const;
203 bool open(std::fstream::openmode openMode);
FileType fileType_
fileType_ indicates the type of the files. Whether it is No file, one file or multiple file as descri...
each time-step will be written into/read from separate files numbered consecutively, with numbers padded by zeros to a minimum of four digits: name_.0000, name_.0001, ..
FileType getFileType() const
Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_.
std::fstream::openmode getOpenMode() const
Allows the user to know the file mode i.e. gets File::openMode_.
std::string to_string_padded(unsigned int value)
Pads the number This function tries to pad the number to 4 digits, which is used when you create mult...
void read(std::istream &is)
read function, which accepts an input stream std::istream.
void setCounter(unsigned int counter)
Allows the user to set the file counter according to his need. Sets File::counter_.
const std::string getFullName() const
Also allows to access the file name, however with additional information which is the file counter...
unsigned int nextSavedTimeStep_
the time step at which the next write or read operation has to happen.
bool openNextFile()
This function should be called before a data corresponding to the new time step is written or read...
FileType
With FileType options, one is able to choose if data is to be read/written from/into no or single or ...
unsigned int counter_
counts the number of the next file to be opened; needed if multiple files are written/read ...
unsigned int getSaveCount() const
Gets File::saveCount_.
void close()
Closes the file by calling fstream_.close()
std::istream & operator>>(std::istream &is, FileType &fileType)
Reads the FileType from an input stream 'is'.
std::fstream::openmode openMode_
A variable to indicate how the file should be opened i.e. in, out, ... see http://en.cppreference.com (std::fstream::out by default)
unsigned int getCounter() const
In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next fil...
std::ostream & operator<<(std::ostream &os, FileType fileType)
Writes the FileType as a human-readable string into the output stream 'os'.
file will not be created/read
std::fstream & getFstream()
Allows to access the member variable File::fstream_.
void setNextSavedTimeStep(unsigned int nextSavedTimeStep)
Sets File::nextSavedTimeStep_.
all data will be written into/ read from a single file called name_
unsigned int getNextSavedTimeStep() const
Gets File::nextSavedTimeStep_.
unsigned int saveCount_
Allows one to define the number of timesteps to be skipped to make a snap shot. E.g. TMax = 100, saveCount_ = 10, timeStep = 1; It stores data at t={0,10,20,30,40...100}. And if TMax =101, it stores data at t={0,10,20,30,...100,101}.
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_.
friend std::ostream & operator<<(std::ostream &os, const File &o)
Operator overloading used to write data obtained from an object of class File into an output stream...
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
bool saveCurrentTimestep(unsigned int ntimeSteps)
friend std::istream & operator>>(std::istream &is, File &o)
Operator overloading used to read data from the input stream into member variables of an object of cl...
std::string name_
name of the file.
virtual ~File()
destructor
each time-step will be written into/read from separate files numbered consecutively: name_...
void setName(const std::string &name)
Sets the file name, e.g. "Name.data".
void write(std::ostream &os) const
print function, which accepts an std::stringstream as input.
const std::string & getName() const
Allows to access the file name, e.g., "problem.data".
std::fstream fstream_
Stream object used to read/write data files.
void setOpenMode(std::fstream::openmode openMode)
Allows the user to Sets File::openMode_.