MercuryDPM  Beta
 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 119 of file File.cc.

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

120 {
121  saveCount_ = 0;
122 
123  // file name has to be set by the user
124  name_ = "";
125 
126  // file closed by default
127 
128  // output into a single file by default
130 
131  // file counter set to 0 by default
132  counter_ = 0;
133  nextSavedTimeStep_ = 0;
134 
135  // file output file by default
136  openMode_ = std::fstream::out;
137 }
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 142 of file File.cc.

143 {
144 }

Member Function Documentation

void File::close ( )

Closes the file by calling fstream_.close()

Definition at line 360 of file File.cc.

References fstream_.

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

361 {
362  fstream_.close();
363  //std::cerr << "Closing " << getFullName() << std::endl;
364 }
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 216 of file File.cc.

References counter_.

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

217 {
218  return counter_;
219 }
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 202 of file File.cc.

References fileType_.

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

203 {
204  return fileType_;
205 }
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 150 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().

151 {
152  return fstream_;
153 }
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 170 of file File.cc.

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

Referenced by open(), and write().

171 {
172  //get the full file name
173  std::stringstream fullFileName("");
174  fullFileName << name_;
176  {
177  fullFileName << "." << getCounter();
178  }
180  {
181  fullFileName << ".";
182  if (getCounter() < 1000)
183  fullFileName << "0";
184  if (getCounter() < 100)
185  fullFileName << "0";
186  if (getCounter() < 10)
187  fullFileName << "0";
188  fullFileName << getCounter();
189  }
190  return fullFileName.str();
191 }
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:202
unsigned int getCounter() const
In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next fil...
Definition: File.cc:216
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 162 of file File.cc.

References name_.

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

163 {
164  return name_;
165 }
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 290 of file File.cc.

References nextSavedTimeStep_.

291 {
292  return nextSavedTimeStep_;
293 }
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 260 of file File.cc.

References openMode_.

261 {
262  return openMode_;
263 }
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 274 of file File.cc.

References saveCount_.

275 {
276  return saveCount_;
277 }
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 318 of file File.cc.

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

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

319 {
320  if (getName().compare("") == 0)
321  {
322  std::cerr << "Error: Name must be set before opening file" << std::endl;
323  throw;
324  }
325 
326  //close old file if multi-file output
328  fstream_.close();
329 
330  //open new file for multi-file output
331 
332  if (!fstream_.is_open())
333  {
334  fstream_.open(getFullName().c_str(), openMode_);
335  if (!fstream_.is_open())
336  {
337  std::cerr << "Error in opening " << getFullName() <<" with open mode "<< openMode_ << std::endl;
338  return false;
339  }
340  }
342  #ifdef DEBUG_OUTPUT
343  std::cout << "open " << getFullName() << std::endl;
344  #endif
346  counter_++;
347  return true;
348 }
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:170
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
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:162
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 352 of file File.cc.

References open(), and setOpenMode().

353 {
354  setOpenMode(openMode);
355  return open();
356 }
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
Definition: File.cc:318
void setOpenMode(std::fstream::openmode openMode)
Allows the user to Sets File::openMode_.
Definition: File.cc:267
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 230 of file File.cc.

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

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

231 {
232  //++counter_;
233 
235  {
236  File::close();
237  return File::open();
238  }
239 // else if (getFileType() == FileType::ONE_FILE && !getFstream().is_open())
240 // {
241 // return File::open();
242 // }
243  else
244  {
245  return true;
246  }
247 }
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:202
void close()
Closes the file by calling fstream_.close()
Definition: File.cc:360
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
Definition: File.cc:318
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 252 of file File.cc.

References openNextFile(), and setOpenMode().

253 {
254  setOpenMode(openMode);
255  return openNextFile();
256 }
bool openNextFile()
This function should be called before a data corresponding to the new time step is written or read...
Definition: File.cc:230
void setOpenMode(std::fstream::openmode openMode)
Allows the user to Sets File::openMode_.
Definition: File.cc:267
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 370 of file File.cc.

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

Referenced by operator>>().

371 {
372  std::string dummy;
373  is >> dummy;
374  if (!dummy.compare("name"))
375  is >> name_ >> dummy;
376  is >> fileType_;
377  is >> dummy >> saveCount_;
378  is >> dummy >> counter_;
379  is >> dummy >> nextSavedTimeStep_;
380 }
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 307 of file File.cc.

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

Referenced by DPMBase::writeOutputFiles().

308 {
309  //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
310  //std::cout << (ntimeSteps>=nextSavedTimeStep_) << " " << (getFileType()!= FileType::NO_FILE) << std::endl;
311  return ntimeSteps>=nextSavedTimeStep_ && getFileType()!= FileType::NO_FILE && open();
312 }
FileType getFileType() const
Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_.
Definition: File.cc:202
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:318
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 223 of file File.cc.

References counter_.

Referenced by Files::resetFileCounter().

224 {
225  counter_ = counter;
226 }
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 209 of file File.cc.

References fileType_.

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

210 {
211  fileType_ = fileType;
212 }
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 195 of file File.cc.

References name_.

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

196 {
197  this->name_ = name;
198 }
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 298 of file File.cc.

References nextSavedTimeStep_.

Referenced by Files::setNextSavedTimeStep().

299 {
300  nextSavedTimeStep_ = nextSavedTimeStep;
301 }
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 267 of file File.cc.

References openMode_.

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

268 {
269  openMode_ = openMode;
270 }
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

Definition at line 282 of file File.cc.

References saveCount_.

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

283 {
284  saveCount_ = saveCount;
285 }
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 386 of file File.cc.

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

Referenced by operator<<().

387 {
388  //only write name if it differs from the default name
389  if (getFullName().compare(name_))
390  os << "name " << name_ << " ";
391  os << "fileType " << fileType_;
392  os << " saveCount " << saveCount_;
393  os << " counter " << counter_;
394  os << " nextSavedTimeStep " << nextSavedTimeStep_;
396 }
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:170
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

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 402 of file File.cc.

403 {
404  o.write(os);
405  return os;
406 }
void write(std::ostream &os) const
print function, which accepts an std::stringstream as input.
Definition: File.cc:386
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 412 of file File.cc.

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

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: