All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | 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...
 
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...
 

Static Public Member Functions

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

Protected Member Functions

 FileBase ()
 Private constructor. More...
 

Static Protected Member Functions

static std::string appendSuffix (const std::string &path, const std::string &suffix)
 Append suffix. 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...
 
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...
 

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 )
private

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 
)
staticprotected

Append suffix.

It appends the desired suffix to the string. Notice that it conserves a possible ".gz" suffix.

void PLMD::FileBase::close ( )

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

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.

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

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::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: