Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
PLMD::FileBase Class Referenceabstract

Base class for dealing with files. More...

#include <FileBase.h>

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

Classes

class  FieldBase
 Internal tool. More...
 

Public Member Functions

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...
 
FileBaseenforceSuffix (const std::string &suffix)
 Enforce suffix. More...
 
virtual FileBaseflush ()
 Flushes the file to disk. More...
 
void close ()
 Closes the file Should be used only for explicitely opened files. More...
 
virtual ~FileBase ()
 Virtual destructor (allows inheritance) More...
 
 operator bool () const
 Check for error/eof. More...
 
void setHeavyFlush ()
 Set heavyFlush flag. More...
 
virtual FileBaseopen (const std::string &name)=0
 Opens the file. More...
 
bool FileExist (const std::string &path)
 Check if the file exists. More...
 
bool isOpen ()
 Check if a file is open. More...
 
std::string getPath () const
 Retrieve the path. More...
 
std::string getMode () const
 Retrieve the mode. More...
 
std::string getSuffix () const
 Get the file suffix. More...
 

Static Public Member Functions

static std::string appendSuffix (const std::string &path, const std::string &suffix)
 Append suffix. More...
 
static void test ()
 Runs a small testcase. More...
 

Protected Member Functions

 FileBase ()
 Private constructor. More...
 

Protected Attributes

FILE * fp
 file pointer More...
 
void * gzfp
 zip 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...
 
std::string mode
 mode of the opened file More...
 
bool heavyFlush
 Set to true if you want flush to be heavy (close/reopen) More...
 

Private Member Functions

 FileBase (const FileBase &)
 Copy constructor is disabled (private and unimplemented) More...
 
FileBaseoperator= (const FileBase &)
 Assignment operator is disabled (private and unimplemented) More...
 

Private Attributes

std::string enforcedSuffix
 Enforced suffix: More...
 
bool enforcedSuffix_
 If true, use enforcedSuffix, else get it from PlumedMain. More...
 

Detailed Description

Base class for dealing with files.

This class just provides things which are common among OFile and IFile

Constructor & Destructor Documentation

PLMD::FileBase::FileBase ( const FileBase )
explicitprivate

Copy constructor is disabled (private and unimplemented)

PLMD::FileBase::FileBase ( )
protected

Private constructor.

In this manner one cannot instantiate a FileBase object

PLMD::FileBase::~FileBase ( )
virtual

Virtual destructor (allows inheritance)

Member Function Documentation

std::string PLMD::FileBase::appendSuffix ( const std::string &  path,
const std::string &  suffix 
)
static

Append suffix.

It appends the desired suffix to the string. Notice that it conserves some suffix (e.g. gz/xtc/trr).

void PLMD::FileBase::close ( )

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

FileBase & PLMD::FileBase::enforceSuffix ( const std::string &  suffix)

Enforce suffix.

Overrides the one set in PlumedMain&

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

Check if the file exists.

FileBase & PLMD::FileBase::flush ( )
virtual

Flushes the file to disk.

Reimplemented in PLMD::OFile.

std::string PLMD::FileBase::getMode ( ) const
inline

Retrieve the mode.

std::string PLMD::FileBase::getPath ( ) const
inline

Retrieve the path.

std::string PLMD::FileBase::getSuffix ( ) const

Get the file suffix.

bool PLMD::FileBase::isOpen ( )

Check if a file is open.

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

Link to an already open filed.

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

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

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

Link to a Communicator object.

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

Link to an Action object.

Automatically links also the corresponding PlumedMain and Communicator.

virtual FileBase& PLMD::FileBase::open ( const std::string &  name)
pure virtual

Opens the file.

Implemented in PLMD::OFile, and PLMD::IFile.

PLMD::FileBase::operator bool ( ) const

Check for error/eof.

FileBase& PLMD::FileBase::operator= ( const FileBase )
private

Assignment operator is disabled (private and unimplemented)

void PLMD::FileBase::setHeavyFlush ( )
inline

Set heavyFlush flag.

void PLMD::FileBase::test ( )
static

Runs a small testcase.

Member Data Documentation

Action* PLMD::FileBase::action
protected

pointer to corresponding action. NULL if not linked

bool PLMD::FileBase::cloned
protected

Control closing on destructor.

If true, file will not be closed in destructor

Communicator* PLMD::FileBase::comm
protected

communicator. NULL if not set

std::string PLMD::FileBase::enforcedSuffix
private

Enforced suffix:

bool PLMD::FileBase::enforcedSuffix_
private

If true, use enforcedSuffix, else get it from PlumedMain.

bool PLMD::FileBase::eof
protected

Set to true when end of file is encountered.

bool PLMD::FileBase::err
protected

Set to true when error is encountered.

FILE* PLMD::FileBase::fp
protected

file pointer

void* PLMD::FileBase::gzfp
protected

zip file pointer.

bool PLMD::FileBase::heavyFlush
protected

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

std::string PLMD::FileBase::mode
protected

mode of the opened file

std::string PLMD::FileBase::path
protected

path of the opened file

PlumedMain* PLMD::FileBase::plumed
protected

pointer to main plumed object. NULL if not linked


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