MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
File Class Reference

#include <File.h>

Public Member Functions

 File ()
 constructor More...
 
virtual ~File ()
 destructor More...
 
std::fstream & getFstream ()
 Allows to access the member variable File::fstream_. More...
 
const std::string & getName () const
 Allows to access the file name, e.g., "problem.data". More...
 
const std::string getFullName () const
 Also allows to access the file name, however with additional information which is the file counter, e.g., "problem.data.0000". More...
 
void setName (const std::string &name)
 Sets the file name, e.g. "Name.data". More...
 
FileType getFileType () const
 Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_. More...
 
void setFileType (FileType fileType)
 Sets the type of file needed to write into or read from. File::fileType_. More...
 
unsigned int getCounter () const
 In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next file i.e. to be opened for reading or writing; NOTE: needed only if FILE::fileType_ is multiple files. More...
 
void setCounter (unsigned int counter)
 Allows the user to set the file counter according to his need. Sets File::counter_. More...
 
std::fstream::openmode getOpenMode () const
 Allows the user to know the file mode i.e. gets File::openMode_. More...
 
void setOpenMode (std::fstream::openmode openMode)
 Allows the user to Sets File::openMode_. More...
 
unsigned int getSaveCount () const
 Gets File::saveCount_. More...
 
void setSaveCount (unsigned int saveCount)
 Sets File::saveCount_. More...
 
unsigned int getNextSavedTimeStep () const
 Gets File::nextSavedTimeStep_. More...
 
void setNextSavedTimeStep (unsigned int nextSavedTimeStep)
 Sets File::nextSavedTimeStep_. More...
 
bool saveCurrentTimestep (unsigned int ntimeSteps)
 
void read (std::istream &is)
 read function, which accepts an input stream std::istream. More...
 
void write (std::ostream &os) const
 print function, which accepts an std::stringstream as input. More...
 
bool open ()
 Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the nextSavedTimeStep and the counter. the counter is useful when the fileType_ is set to Multiple or Multiple with padded. More...
 
bool open (std::fstream::openmode openMode)
 First calls setOpenMode(openMode), then open(). More...
 
bool openNextFile ()
 This function should be called before a data corresponding to the new time step is written or read. It is essential in case of multiple files, as it opens a new file for every increment in the File::counter_. More...
 
bool openNextFile (std::fstream::openmode openMode)
 Similar to File::openNextFile(), but also lets the user set the mode of opening, see std::fstream::openmode More...
 
void close ()
 Closes the file by calling fstream_.close() More...
 

Private Attributes

std::string name_
 name of the file. More...
 
std::fstream fstream_
 Stream object used to read/write data files. More...
 
FileType fileType_
 fileType_ indicates the type of the files. Whether it is No file, one file or multiple file as described in the description of the class. More...
 
unsigned int counter_
 counts the number of the next file to be opened; needed if multiple files are written/read More...
 
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) More...
 
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}. More...
 
unsigned int nextSavedTimeStep_
 the time step at which the next write or read operation has to happen. More...
 

Friends

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. It also returns a reference to the output stream. More...
 
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 class File. It also returns a reference of type std::istream&. More...
 

Detailed Description

The instance of class File, for e.g. member variables of class Files (objects of type File) in Files.h, allows to manipulate the the input and output stream. In layman terms: In MercuryDPM, in order to read and write data into or from files we use the methods defined in Files.h. These methods implicitly calls the methods of class File and thereby allowing us to write or read data.

Definition at line 78 of file File.h.

Constructor & Destructor Documentation

File::File ( )

constructor

A File constructor which initialises FILE::saveCount_=0, sets the default filename as FILE::name_ = "", sets the default FileType to be as FileType::ONE_FILE and few other variables as listed below.

Definition at line 120 of file File.cc.

References counter_, fileType_, name_, nextSavedTimeStep_, ONE_FILE, openMode_, and saveCount_.

121 {
122  saveCount_ = 0;
123 
124  // file name has to be set by the user
125  name_ = "out";
126 
127  // file closed by default
128 
129  // output into a single file by default
131 
132  // file counter set to 0 by default
133  counter_ = 0;
134  nextSavedTimeStep_ = 0;
135 
136  // file output file by default
137  openMode_ = std::fstream::out;
138 }
FileType fileType_
fileType_ indicates the type of the files. Whether it is No file, one file or multiple file as descri...
Definition: File.h:236
unsigned int nextSavedTimeStep_
the time step at which the next write or read operation has to happen.
Definition: File.h:257
unsigned int counter_
counts the number of the next file to be opened; needed if multiple files are written/read ...
Definition: File.h:241
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)
Definition: File.h:246
all data will be written into/ read from a single file called name_
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}.
Definition: File.h:252
std::string name_
name of the file.
Definition: File.h:225
File::~File ( )
virtual

destructor

Definition at line 143 of file File.cc.

144 {
145 }

Member Function Documentation

void File::close ( )

Closes the file by calling fstream_.close()

Definition at line 362 of file File.cc.

References fstream_.

Referenced by Files::closeFiles(), openNextFile(), DPMBase::readDataFile(), DPMBase::readRestartFile(), and DPMBase::writeOutputFiles().

363 {
364  fstream_.close();
365  //std::cerr << "Closing " << getFullName() << std::endl;
366 }
std::fstream fstream_
Stream object used to read/write data files.
Definition: File.h:230
unsigned int File::getCounter ( ) const

In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next file i.e. to be opened for reading or writing; NOTE: needed only if FILE::fileType_ is multiple files.

Returns
unsigned int counter_

Definition at line 217 of file File.cc.

References counter_.

Referenced by DPMBase::findNextExistingDataFile(), getFullName(), and DPMBase::writeOutputFiles().

218 {
219  return counter_;
220 }
unsigned int counter_
counts the number of the next file to be opened; needed if multiple files are written/read ...
Definition: File.h:241
FileType File::getFileType ( ) const

Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_.

Returns
Returns the FileType (File::fileType_)

Definition at line 203 of file File.cc.

References fileType_.

Referenced by DPMBase::findNextExistingDataFile(), getFullName(), openNextFile(), DPMBase::readDataFile(), saveCurrentTimestep(), and DPMBase::writeOutputFiles().

204 {
205  return fileType_;
206 }
FileType fileType_
fileType_ indicates the type of the files. Whether it is No file, one file or multiple file as descri...
Definition: File.h:236
std::fstream & File::getFstream ( )

Allows to access the member variable File::fstream_.

Returns fstream (file stream) of any file for input and output tasks.

Returns
std::fstream&

Definition at line 151 of file File.cc.

References fstream_.

Referenced by Files::Files(), DPMBase::findNextExistingDataFile(), DPMBase::readDataFile(), Mercury3DRestart::readNextArgument(), DPMBase::readNextDataFile(), DPMBase::readRestartFile(), DPMBase::writeOutputFiles(), and DPMBase::writeRestartFile().

152 {
153  return fstream_;
154 }
std::fstream fstream_
Stream object used to read/write data files.
Definition: File.h:230
const std::string File::getFullName ( ) const

Also allows to access the file name, however with additional information which is the file counter, e.g., "problem.data.0000".

In case of FileType:fileType_== multiple files or multiple files padded, multiple files are generated and are named as problem.data.0, problem.data.1 or problem.data.0000, problem.data.0001

Returns
Returns a constant of type std::string

Definition at line 171 of file File.cc.

References getCounter(), getFileType(), MULTIPLE_FILES, MULTIPLE_FILES_PADDED, and name_.

Referenced by open(), and write().

172 {
173  //get the full file name
174  std::stringstream fullFileName("");
175  fullFileName << name_;
177  {
178  fullFileName << "." << getCounter();
179  }
181  {
182  fullFileName << ".";
183  if (getCounter() < 1000)
184  fullFileName << "0";
185  if (getCounter() < 100)
186  fullFileName << "0";
187  if (getCounter() < 10)
188  fullFileName << "0";
189  fullFileName << getCounter();
190  }
191  return fullFileName.str();
192 }
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_.
Definition: File.cc:203
unsigned int getCounter() const
In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next fil...
Definition: File.cc:217
std::string name_
name of the file.
Definition: File.h:225
each time-step will be written into/read from separate files numbered consecutively: name_...
const std::string & File::getName ( ) const

Allows to access the file name, e.g., "problem.data".

Returns
Returns a constant reference of type const std::string&

Definition at line 163 of file File.cc.

References name_.

Referenced by DPMBase::findNextExistingDataFile(), main(), open(), DPMBase::readDataFile(), and Mercury3DRestart::readNextArgument().

164 {
165  return name_;
166 }
std::string name_
name of the file.
Definition: File.h:225
unsigned int File::getNextSavedTimeStep ( ) const

Gets File::nextSavedTimeStep_.

Returns the time step at which the next write or read operation has to happen

Returns
unsigned int nextSaveTimeStep_

Definition at line 292 of file File.cc.

References nextSavedTimeStep_.

293 {
294  return nextSavedTimeStep_;
295 }
unsigned int nextSavedTimeStep_
the time step at which the next write or read operation has to happen.
Definition: File.h:257
std::fstream::openmode File::getOpenMode ( ) const

Allows the user to know the file mode i.e. gets File::openMode_.

Returns
std::fstream::openmode

Definition at line 261 of file File.cc.

References openMode_.

262 {
263  return openMode_;
264 }
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)
Definition: File.h:246
unsigned int File::getSaveCount ( ) const

Gets File::saveCount_.

Returns
unsigned int saveCount_

Definition at line 275 of file File.cc.

References saveCount_.

Referenced by DPMBase::readNextArgument().

276 {
277  return saveCount_;
278 }
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}.
Definition: File.h:252
bool File::open ( )

Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the nextSavedTimeStep and the counter. the counter is useful when the fileType_ is set to Multiple or Multiple with padded.

Returns a bool to check if the file is open or closed. It also increments the nextSavedTimeStep with the saveCount

Returns
bool (True or False)
Bug:
Deepak checked by using fstream_.fail() instead of !fstrea_.is_open(), however this breaks selftests, Thomas will look at this
Todo:
tw: DEBUG_OUTPUT is currently only defined in DPMBase.h

Definition at line 320 of file File.cc.

References helpers::compare(), counter_, fileType_, fstream_, getFullName(), getName(), MULTIPLE_FILES, MULTIPLE_FILES_PADDED, nextSavedTimeStep_, openMode_, and saveCount_.

Referenced by main(), open(), Files::openFiles(), openNextFile(), DPMBase::readDataFile(), DPMBase::readRestartFile(), and saveCurrentTimestep().

321 {
322  if (getName().compare("") == 0)
323  {
324  std::cerr << "Error: Name must be set before opening file" << std::endl;
325  throw;
326  }
327 
328  //close old file if multi-file output
330  fstream_.close();
331 
332  //open new file for multi-file output
333 
334  if (!fstream_.is_open())
335  {
336  fstream_.open(getFullName().c_str(), openMode_);
337  if (!fstream_.is_open())
338  {
339  //logger(WARN, "Could not open % with open mode %", getFullName(), openMode_);
340  return false;
341  }
342  }
344  #ifdef DEBUG_OUTPUT
345  std::cout << "open " << getFullName() << std::endl;
346  #endif
348  counter_++;
349  return true;
350 }
FileType fileType_
fileType_ indicates the type of the files. Whether it is No file, one file or multiple file as descri...
Definition: File.h:236
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, ..
const std::string getFullName() const
Also allows to access the file name, however with additional information which is the file counter...
Definition: File.cc:171
unsigned int nextSavedTimeStep_
the time step at which the next write or read operation has to happen.
Definition: File.h:257
unsigned int counter_
counts the number of the next file to be opened; needed if multiple files are written/read ...
Definition: File.h:241
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)
Definition: File.h:246
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}.
Definition: File.h:252
bool compare(std::istream &is, std::string s)
Definition: Helpers.cc:754
each time-step will be written into/read from separate files numbered consecutively: name_...
const std::string & getName() const
Allows to access the file name, e.g., "problem.data".
Definition: File.cc:163
std::fstream fstream_
Stream object used to read/write data files.
Definition: File.h:230
bool File::open ( std::fstream::openmode  openMode)

First calls setOpenMode(openMode), then open().

Parameters
[in]openMode

Definition at line 354 of file File.cc.

References open(), and setOpenMode().

355 {
356  setOpenMode(openMode);
357  return open();
358 }
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
Definition: File.cc:320
void setOpenMode(std::fstream::openmode openMode)
Allows the user to Sets File::openMode_.
Definition: File.cc:268
bool File::openNextFile ( )

This function should be called before a data corresponding to the new time step is written or read. It is essential in case of multiple files, as it opens a new file for every increment in the File::counter_.

Returns
bool (True or False)

Definition at line 231 of file File.cc.

References close(), getFileType(), MULTIPLE_FILES, MULTIPLE_FILES_PADDED, and open().

Referenced by DPMBase::findNextExistingDataFile(), openNextFile(), and DPMBase::readNextDataFile().

232 {
233  //++counter_;
234 
236  {
237  File::close();
238  return File::open();
239  }
240 // else if (getFileType() == FileType::ONE_FILE && !getFstream().is_open())
241 // {
242 // return File::open();
243 // }
244  else
245  {
246  return true;
247  }
248 }
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_.
Definition: File.cc:203
void close()
Closes the file by calling fstream_.close()
Definition: File.cc:362
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
Definition: File.cc:320
each time-step will be written into/read from separate files numbered consecutively: name_...
bool File::openNextFile ( std::fstream::openmode  openMode)

Similar to File::openNextFile(), but also lets the user set the mode of opening, see std::fstream::openmode

Parameters
[in]openmode
Returns
bool

Definition at line 253 of file File.cc.

References openNextFile(), and setOpenMode().

254 {
255  setOpenMode(openMode);
256  return openNextFile();
257 }
bool openNextFile()
This function should be called before a data corresponding to the new time step is written or read...
Definition: File.cc:231
void setOpenMode(std::fstream::openmode openMode)
Allows the user to Sets File::openMode_.
Definition: File.cc:268
void File::read ( std::istream &  is)

read function, which accepts an input stream std::istream.

Read function, which accepts an input stream object as input and assigns the member variables i.e. name_, fileType_, saveCount_, counter_ and nextSavedTimeStep_

Parameters
[in,out]is

Definition at line 372 of file File.cc.

References counter_, fileType_, name_, nextSavedTimeStep_, and saveCount_.

Referenced by operator>>().

373 {
374  std::string dummy;
375  is >> dummy;
376  if (!dummy.compare("name"))
377  is >> name_ >> dummy;
378  is >> fileType_;
379  is >> dummy >> saveCount_;
380  is >> dummy >> counter_;
381  is >> dummy >> nextSavedTimeStep_;
382 }
FileType fileType_
fileType_ indicates the type of the files. Whether it is No file, one file or multiple file as descri...
Definition: File.h:236
unsigned int nextSavedTimeStep_
the time step at which the next write or read operation has to happen.
Definition: File.h:257
unsigned int counter_
counts the number of the next file to be opened; needed if multiple files are written/read ...
Definition: File.h:241
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}.
Definition: File.h:252
std::string name_
name of the file.
Definition: File.h:225
bool File::saveCurrentTimestep ( unsigned int  ntimeSteps)
Parameters
[in]ntimeSteps
Returns
True or False (a bool)

Definition at line 309 of file File.cc.

References getFileType(), nextSavedTimeStep_, NO_FILE, and open().

Referenced by DPMBase::writeOutputFiles().

310 {
311  //check if this timestep should be written, if the file type is not NO_FILE, then open the file and check if the file was successfully opened
312  //std::cout << (ntimeSteps>=nextSavedTimeStep_) << " " << (getFileType()!= FileType::NO_FILE) << std::endl;
313  return ntimeSteps>=nextSavedTimeStep_ && getFileType()!= FileType::NO_FILE && open();
314 }
FileType getFileType() const
Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_.
Definition: File.cc:203
unsigned int nextSavedTimeStep_
the time step at which the next write or read operation has to happen.
Definition: File.h:257
file will not be created/read
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
Definition: File.cc:320
void File::setCounter ( unsigned int  counter)

Allows the user to set the file counter according to his need. Sets File::counter_.

Parameters
[in]counter

Definition at line 224 of file File.cc.

References counter_.

Referenced by main(), and Files::resetFileCounter().

225 {
226  counter_ = counter;
227 }
unsigned int counter_
counts the number of the next file to be opened; needed if multiple files are written/read ...
Definition: File.h:241
void File::setFileType ( FileType  fileType)

Sets the type of file needed to write into or read from. File::fileType_.

Parameters
[in]fileType

Definition at line 210 of file File.cc.

References fileType_.

Referenced by ChuteBottom::constructor(), DPMBase::readDataFile(), DPMBase::readNextArgument(), DPMBase::readOld(), and Files::setFileType().

211 {
212  fileType_ = fileType;
213 }
FileType fileType_
fileType_ indicates the type of the files. Whether it is No file, one file or multiple file as descri...
Definition: File.h:236
void File::setName ( const std::string &  name)

Sets the file name, e.g. "Name.data".

Note the file name is usually set by MD::setName(), which sets names for all file types (data, restart, fstat, stat, ene)

Parameters
[in]name(Takes in the to be name of the File)

Definition at line 196 of file File.cc.

References name_.

Referenced by main(), DPMBase::readDataFile(), DPMBase::readRestartFile(), and Files::setName().

197 {
198  this->name_ = name;
199 }
std::string name_
name of the file.
Definition: File.h:225
void File::setNextSavedTimeStep ( unsigned int  nextSavedTimeStep)

Sets File::nextSavedTimeStep_.

Allows one to set the time step at which the next write or read operation has to happen

Parameters
[in]nextSavedTimeStep

Definition at line 300 of file File.cc.

References nextSavedTimeStep_.

Referenced by Files::setNextSavedTimeStep().

301 {
302  nextSavedTimeStep_ = nextSavedTimeStep;
303 }
unsigned int nextSavedTimeStep_
the time step at which the next write or read operation has to happen.
Definition: File.h:257
void File::setOpenMode ( std::fstream::openmode  openMode)

Allows the user to Sets File::openMode_.

Parameters
[in]openmode

Definition at line 268 of file File.cc.

References openMode_.

Referenced by open(), openNextFile(), Files::setOpenMode(), and DPMBase::solve().

269 {
270  openMode_ = openMode;
271 }
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)
Definition: File.h:246
void File::setSaveCount ( unsigned int  saveCount)

Sets File::saveCount_.

File::setSaveCount assigns the number of time steps to be skipped before the data is written to an existing file or a new file.

Parameters
[in]saveCount
Bug:
TW: should setSaveCount change nextSavedTimeStep_ as well?

Definition at line 283 of file File.cc.

References saveCount_.

Referenced by DPMBase::readNextArgument(), DPMBase::readOld(), DPMBase::readParAndIniFiles(), and Files::setSaveCount().

284 {
286  saveCount_ = saveCount;
287 }
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}.
Definition: File.h:252
void File::write ( std::ostream &  os) const

print function, which accepts an std::stringstream as input.

BaseParticle print function, which accepts an output stream object as input and writes the info to the std::ostream

Parameters
[in,out]os
Todo:
TW: openMode_ is not saved, maybe it should not even be stored but set every time you open a file

Definition at line 388 of file File.cc.

References helpers::compare(), counter_, fileType_, getFullName(), name_, nextSavedTimeStep_, and saveCount_.

Referenced by operator<<().

389 {
390  //only write name if it differs from the default name
391  if (getFullName().compare(name_))
392  os << "name " << name_ << " ";
393  os << "fileType " << fileType_;
394  os << " saveCount " << saveCount_;
395  os << " counter " << counter_;
396  os << " nextSavedTimeStep " << nextSavedTimeStep_;
398 }
FileType fileType_
fileType_ indicates the type of the files. Whether it is No file, one file or multiple file as descri...
Definition: File.h:236
const std::string getFullName() const
Also allows to access the file name, however with additional information which is the file counter...
Definition: File.cc:171
unsigned int nextSavedTimeStep_
the time step at which the next write or read operation has to happen.
Definition: File.h:257
unsigned int counter_
counts the number of the next file to be opened; needed if multiple files are written/read ...
Definition: File.h:241
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}.
Definition: File.h:252
bool compare(std::istream &is, std::string s)
Definition: Helpers.cc:754
std::string name_
name of the file.
Definition: File.h:225

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const File o 
)
friend

Operator overloading used to write data obtained from an object of class File into an output stream. It also returns a reference to the output stream.

Parameters
[in,out]os
[in]o
Returns
std::ostream& os

Definition at line 404 of file File.cc.

405 {
406  o.write(os);
407  return os;
408 }
void write(std::ostream &os) const
print function, which accepts an std::stringstream as input.
Definition: File.cc:388
std::istream& operator>> ( std::istream &  is,
File o 
)
friend

Operator overloading used to read data from the input stream into member variables of an object of class File. It also returns a reference of type std::istream&.

Parameters
[in,out]is
[in]o
Returns
std::istream&

Definition at line 414 of file File.cc.

415 {
416  o.read(is);
417  return (is);
418 }
void read(std::istream &is)
read function, which accepts an input stream std::istream.
Definition: File.cc:372

Member Data Documentation

unsigned int File::counter_
private

counts the number of the next file to be opened; needed if multiple files are written/read

Definition at line 241 of file File.h.

Referenced by File(), getCounter(), open(), read(), setCounter(), and write().

FileType File::fileType_
private

fileType_ indicates the type of the files. Whether it is No file, one file or multiple file as described in the description of the class.

Definition at line 236 of file File.h.

Referenced by File(), getFileType(), open(), read(), setFileType(), and write().

std::fstream File::fstream_
private

Stream object used to read/write data files.

Definition at line 230 of file File.h.

Referenced by close(), getFstream(), and open().

std::string File::name_
private

name of the file.

Definition at line 225 of file File.h.

Referenced by File(), getFullName(), getName(), read(), setName(), and write().

unsigned int File::nextSavedTimeStep_
private

the time step at which the next write or read operation has to happen.

Definition at line 257 of file File.h.

Referenced by File(), getNextSavedTimeStep(), open(), read(), saveCurrentTimestep(), setNextSavedTimeStep(), and write().

std::fstream::openmode File::openMode_
private

A variable to indicate how the file should be opened i.e. in, out, ... see http://en.cppreference.com (std::fstream::out by default)

Definition at line 246 of file File.h.

Referenced by File(), getOpenMode(), open(), and setOpenMode().

unsigned int File::saveCount_
private

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}.

Definition at line 252 of file File.h.

Referenced by File(), getSaveCount(), open(), read(), setSaveCount(), and write().


The documentation for this class was generated from the following files: