All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
PLMD::IFile Class Reference

Class for input files. More...

#include <IFile.h>

Inheritance diagram for PLMD::IFile:
Inheritance graph
[legend]

Classes

class  Field
 

Public Member Functions

 IFile ()
 Constructor. More...
 
 ~IFile ()
 Destructor. More...
 
IFileopen (const std::string &name)
 Opens the file. More...
 
IFilescanFieldList (std::vector< std::string > &)
 Gets the list of all fields. More...
 
IFilescanField (const std::string &, double &)
 Read a double field. More...
 
IFilescanField (const std::string &, int &)
 Read a int field. More...
 
IFilescanField (const std::string &, std::string &)
 Read a string field. More...
 
IFilescanField ()
 Ends a field-formatted line. More...
 
IFilegetline (std::string &)
 Get a full line as a string. More...
 
void reset (bool)
 Reset end of file. More...
 
bool FieldExist (const std::string &s)
 Check if a field exist. More...
 
IFilescanField (Value *val)
 Read in a value. More...
 
void allowIgnoredFields ()
 Allow some of the fields in the input to be ignored. More...
 
FileBaselink (FILE *)
 Link to an already open filed. More...
 
FileBaselink (PlumedMain &)
 Link to a PlumedMain object Automatically links also the corresponding Communicator. More...
 
FileBaselink (Communicator &)
 Link to a Communicator object. More...
 
FileBaselink (Action &)
 Link to an Action object. More...
 
FileBaseflush ()
 Flushes the file to disk. More...
 
void close ()
 Closes the file Should be used only for explicitely opened files. More...
 
 operator bool () const
 Check for error/eof. More...
 
void setHeavyFlush ()
 Set heavyFlush flag. More...
 
FileBaseopen (const std::string &name, const std::string &mode)
 Opens the file (without auto-backup) More...
 
bool FileExist (const std::string &path)
 Check if the file exists. More...
 
bool isOpen ()
 Check if a file is open. More...
 

Static Public Member Functions

static void test ()
 Runs a small testcase. More...
 

Protected Attributes

FILE * fp
 file pointer More...
 
Communicatorcomm
 communicator. NULL if not set More...
 
PlumedMainplumed
 pointer to main plumed object. NULL if not linked More...
 
Actionaction
 pointer to corresponding action. NULL if not linked More...
 
bool cloned
 Control closing on destructor. More...
 
bool eof
 Set to true when end of file is encountered. More...
 
bool err
 Set to true when error is encountered. More...
 
std::string path
 path of the opened file More...
 
bool heavyFlush
 Set to true if you want flush to be heavy (close/reopen) More...
 

Private Member Functions

size_t llread (char *, size_t)
 Low-level read. More...
 
IFileadvanceField ()
 Advance to next field (= read one line) More...
 
unsigned findField (const std::string &name) const
 Find field index by name. More...
 

Private Attributes

std::vector< Fieldfields
 All the defined fields. More...
 
bool inMiddleOfField
 Flag set in the middle of a field reading. More...
 
bool ignoreFields
 Set to true if you want to allow fields to be ignored in the read in file. More...
 

Detailed Description

Class for input files.

This class provides features similar to those in the standard C "FILE*" type, but only for sequential input. See OFile for sequential output.

Definition at line 40 of file IFile.h.

Constructor & Destructor Documentation

PLMD::IFile::IFile ( )

Constructor.

Definition at line 159 of file IFile.cpp.

PLMD::IFile::~IFile ( )

Destructor.

Definition at line 165 of file IFile.cpp.

Member Function Documentation

IFile & PLMD::IFile::advanceField ( )
private

Advance to next field (= read one line)

Definition at line 46 of file IFile.cpp.

void PLMD::IFile::allowIgnoredFields ( )

Allow some of the fields in the input to be ignored.

Definition at line 199 of file IFile.cpp.

void PLMD::FileBase::close ( )
inherited

Closes the file Should be used only for explicitely opened files.

Definition at line 140 of file FileBase.cpp.

bool PLMD::IFile::FieldExist ( const std::string &  s)

Check if a field exist.

Definition at line 104 of file IFile.cpp.

bool PLMD::FileBase::FileExist ( const std::string &  path)
inherited

Check if the file exists.

Definition at line 118 of file FileBase.cpp.

unsigned PLMD::IFile::findField ( const std::string &  name) const
private

Find field index by name.

Definition at line 185 of file IFile.cpp.

FileBase & PLMD::FileBase::flush ( )
inherited

Flushes the file to disk.

Definition at line 70 of file FileBase.cpp.

IFile & PLMD::IFile::getline ( std::string &  str)

Get a full line as a string.

Definition at line 169 of file IFile.cpp.

bool PLMD::FileBase::isOpen ( )
inherited

Check if a file is open.

Definition at line 134 of file FileBase.cpp.

FileBase & PLMD::FileBase::link ( FILE *  fp)
inherited

Link to an already open filed.

Definition at line 64 of file FileBase.cpp.

FileBase & PLMD::FileBase::link ( PlumedMain plumed)
inherited

Link to a PlumedMain object Automatically links also the corresponding Communicator.

Definition at line 85 of file FileBase.cpp.

FileBase & PLMD::FileBase::link ( Communicator comm)
inherited

Link to a Communicator object.

Definition at line 79 of file FileBase.cpp.

FileBase & PLMD::FileBase::link ( Action action)
inherited

Link to an Action object.

Automatically links also the corresponding PlumedMain and Communicator.

Definition at line 92 of file FileBase.cpp.

size_t PLMD::IFile::llread ( char *  ptr,
size_t  s 
)
private

Low-level read.

Note: in parallel, all processes read

Definition at line 37 of file IFile.cpp.

IFile & PLMD::IFile::open ( const std::string &  name)

Opens the file.

Definition at line 90 of file IFile.cpp.

FileBase & PLMD::FileBase::open ( const std::string &  name,
const std::string &  mode 
)
inherited

Opens the file (without auto-backup)

Definition at line 99 of file FileBase.cpp.

PLMD::FileBase::operator bool ( ) const
inherited

Check for error/eof.

Definition at line 166 of file FileBase.cpp.

void PLMD::IFile::reset ( bool  reset)

Reset end of file.

Definition at line 192 of file IFile.cpp.

IFile & PLMD::IFile::scanField ( const std::string &  name,
double &  x 
)

Read a double field.

Definition at line 121 of file IFile.cpp.

IFile & PLMD::IFile::scanField ( const std::string &  name,
int &  x 
)

Read a int field.

Definition at line 128 of file IFile.cpp.

IFile & PLMD::IFile::scanField ( const std::string &  name,
std::string &  str 
)

Read a string field.

Definition at line 112 of file IFile.cpp.

IFile & PLMD::IFile::scanField ( )

Ends a field-formatted line.

Typically used as

  if.scanField("a",a).scanField("b",b).scanField();

Definition at line 149 of file IFile.cpp.

IFile & PLMD::IFile::scanField ( Value val)

Read in a value.

Definition at line 135 of file IFile.cpp.

IFile & PLMD::IFile::scanFieldList ( std::vector< std::string > &  s)

Gets the list of all fields.

Definition at line 95 of file IFile.cpp.

void PLMD::FileBase::setHeavyFlush ( )
inlineinherited

Set heavyFlush flag.

Definition at line 101 of file FileBase.h.

void PLMD::FileBase::test ( )
staticinherited

Runs a small testcase.

Definition at line 37 of file FileBase.cpp.

Member Data Documentation

Action* PLMD::FileBase::action
protectedinherited

pointer to corresponding action. NULL if not linked

Definition at line 63 of file FileBase.h.

bool PLMD::FileBase::cloned
protectedinherited

Control closing on destructor.

If true, file will not be closed in destructor

Definition at line 66 of file FileBase.h.

Communicator* PLMD::FileBase::comm
protectedinherited

communicator. NULL if not set

Definition at line 59 of file FileBase.h.

bool PLMD::FileBase::eof
protectedinherited

Set to true when end of file is encountered.

Definition at line 71 of file FileBase.h.

bool PLMD::FileBase::err
protectedinherited

Set to true when error is encountered.

Definition at line 73 of file FileBase.h.

std::vector<Field> PLMD::IFile::fields
private

All the defined fields.

Definition at line 53 of file IFile.h.

FILE* PLMD::FileBase::fp
protectedinherited

file pointer

Definition at line 57 of file FileBase.h.

bool PLMD::FileBase::heavyFlush
protectedinherited

Set to true if you want flush to be heavy (close/reopen)

Definition at line 77 of file FileBase.h.

bool PLMD::IFile::ignoreFields
private

Set to true if you want to allow fields to be ignored in the read in file.

Definition at line 57 of file IFile.h.

bool PLMD::IFile::inMiddleOfField
private

Flag set in the middle of a field reading.

Definition at line 55 of file IFile.h.

std::string PLMD::FileBase::path
protectedinherited

path of the opened file

Definition at line 75 of file FileBase.h.

PlumedMain* PLMD::FileBase::plumed
protectedinherited

pointer to main plumed object. NULL if not linked

Definition at line 61 of file FileBase.h.


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