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

virtual ~FileBase ()
 Virtual destructor (allows inheritance) More...
 
void close ()
 Closes the file Should be used only for explicitely opened files. More...
 
FileBaseenforceSuffix (const std::string &suffix)
 Enforce suffix. More...
 
bool FileExist (const std::string &path)
 Check if the file exists. More...
 
virtual FileBaseflush ()
 Flushes the file to disk. More...
 
FILE * getFILE () const
 Get the underlying file pointer. More...
 
std::string getMode () const
 Retrieve the mode. More...
 
std::string getPath () const
 Retrieve the path. More...
 
std::string getSuffix () const
 Get the file suffix. More...
 
bool isOpen ()
 Check if a file is open. More...
 
FileBaselink (Action &)
 Link to an Action object. More...
 
FileBaselink (Communicator &)
 Link to a Communicator object. More...
 
FileBaselink (FILE *)
 Link to an already open filed. More...
 
FileBaselink (PlumedMain &)
 Link to a PlumedMain object Automatically links also the corresponding Communicator. More...
 
virtual FileBaseopen (const std::string &name)=0
 Opens the file. More...
 
 operator bool () const
 Check for error/eof. More...
 
void setHeavyFlush ()
 Set heavyFlush flag. More...
 

Static Public Member Functions

static std::string appendSuffix (const std::string &path, const std::string &suffix)
 Append suffix. More...
 

Protected Member Functions

 FileBase ()
 Private constructor. More...
 

Protected Attributes

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

Private Member Functions

 FileBase (const FileBase &)=delete
 Copy constructor is disabled. More...
 
FileBaseoperator= (const FileBase &)=delete
 Assignment operator is disabled. 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

◆ FileBase() [1/2]

PLMD::FileBase::FileBase ( const FileBase )
privatedelete

Copy constructor is disabled.

◆ FileBase() [2/2]

PLMD::FileBase::FileBase ( )
protected

Private constructor.

In this manner one cannot instantiate a FileBase object

◆ ~FileBase()

PLMD::FileBase::~FileBase ( )
virtual

Virtual destructor (allows inheritance)

Member Function Documentation

◆ appendSuffix()

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

◆ close()

void PLMD::FileBase::close ( )

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

◆ enforceSuffix()

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

Enforce suffix.

Overrides the one set in PlumedMain&

◆ FileExist()

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

Check if the file exists.

◆ flush()

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

Flushes the file to disk.

Reimplemented in PLMD::OFile.

◆ getFILE()

FILE * PLMD::FileBase::getFILE ( ) const
inline

Get the underlying file pointer.

It might be null even if the file is open, e.g. when the file was open as a gzipped file.

◆ getMode()

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

Retrieve the mode.

◆ getPath()

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

Retrieve the path.

◆ getSuffix()

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

Get the file suffix.

◆ isOpen()

bool PLMD::FileBase::isOpen ( )

Check if a file is open.

◆ link() [1/4]

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

Link to an Action object.

Automatically links also the corresponding PlumedMain and Communicator.

◆ link() [2/4]

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

Link to a Communicator object.

◆ link() [3/4]

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

Link to an already open filed.

◆ link() [4/4]

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

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

◆ open()

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

Opens the file.

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

◆ operator bool()

PLMD::FileBase::operator bool ( ) const

Check for error/eof.

◆ operator=()

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

Assignment operator is disabled.

◆ setHeavyFlush()

void PLMD::FileBase::setHeavyFlush ( )
inline

Set heavyFlush flag.

Member Data Documentation

◆ action

Action* PLMD::FileBase::action
protected

pointer to corresponding action. NULL if not linked

◆ cloned

bool PLMD::FileBase::cloned
protected

Control closing on destructor.

If true, file will not be closed in destructor

◆ comm

Communicator* PLMD::FileBase::comm
protected

communicator. NULL if not set

◆ enforcedSuffix

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

Enforced suffix:

◆ enforcedSuffix_

bool PLMD::FileBase::enforcedSuffix_
private

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

◆ eof

bool PLMD::FileBase::eof
protected

Set to true when end of file is encountered.

◆ err

bool PLMD::FileBase::err
protected

Set to true when error is encountered.

◆ fp

FILE* PLMD::FileBase::fp
protected

file pointer

◆ gzfp

void* PLMD::FileBase::gzfp
protected

zip file pointer.

◆ heavyFlush

bool PLMD::FileBase::heavyFlush
protected

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

◆ mode

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

mode of the opened file

◆ path

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

path of the opened file

◆ plumed

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: