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

Class containing the log stream. More...

#include <Log.h>

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

Public Member Functions

OFilelink (OFile &)
 Allows linking this OFile to another one. 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...
 
void setBackupString (const std::string &)
 Set the string name to be used for automatic backup. More...
 
void backupFile (const std::string &bstring, const std::string &fname)
 Backup a file by giving it a different name. More...
 
void backupAllFiles (const std::string &str)
 This backs up all the files that would have been created with the name str. More...
 
OFileopen (const std::string &name)
 Opens the file using automatic append/backup. More...
 
OFilesetLinePrefix (const std::string &)
 Set the prefix for output. More...
 
OFilefmtField (const std::string &)
 Set the format for writing double precision fields. More...
 
OFilefmtField ()
 Reset the format for writing double precision fields to its default. More...
 
OFileprintField (const std::string &, double)
 Set the value of a double precision field. More...
 
OFileprintField (const std::string &, int)
 Set the value of a int field. More...
 
OFileprintField (const std::string &, const std::string &)
 Set the value of a string field. More...
 
OFileprintField (Value *val, const double &v)
 Print a value. More...
 
OFileprintField ()
 Close a line. More...
 
OFileaddConstantField (const std::string &)
 
OFilesetupPrintValue (Value *val)
 Used to setup printing of values. More...
 
OFileclearFields ()
 Resets the list of fields. More...
 
int printf (const char *fmt,...)
 Formatted output with explicit format - a la printf. More...
 
OFilerewind ()
 Rewind a file. More...
 
virtual FileBaseflush ()
 Flush a file. More...
 
OFileenforceRestart ()
 Enforce restart, also if the attached plume object is not restarting. 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...
 
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...
 

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

Detailed Description

Class containing the log stream.

It is similar to a FILE stream. It allows a printf() function, and also to write with a << operator. Moreover, it can prefix lines with the "PLUMED:" prefix, useful to grep out plumed log from output

Member Function Documentation

OFile & PLMD::OFile::addConstantField ( const std::string &  name)
inherited
std::string PLMD::FileBase::appendSuffix ( const std::string &  path,
const std::string &  suffix 
)
staticprotectedinherited

Append suffix.

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

void PLMD::OFile::backupAllFiles ( const std::string &  str)
inherited

This backs up all the files that would have been created with the name str.

It is used in analysis when you are not restarting. Analysis output files at different times, which are names analysis.0.<filename>, analysis.1.<filename> and <filename>, are backed up to bck.0.analysis.0.<filename>, bck.0.analysis.1.<filename> and bck.0.<filename>

void PLMD::OFile::backupFile ( const std::string &  bstring,
const std::string &  fname 
)
inherited

Backup a file by giving it a different name.

OFile & PLMD::OFile::clearFields ( )
inherited

Resets the list of fields.

As it is only possible to add new constant fields (addConstantField()), this method can be used to clean the field list.

void PLMD::FileBase::close ( )
inherited

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

OFile & PLMD::OFile::enforceRestart ( )
inherited

Enforce restart, also if the attached plume object is not restarting.

Useful for tests

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

Check if the file exists.

FileBase & PLMD::OFile::flush ( )
virtualinherited

Flush a file.

Reimplemented from PLMD::FileBase.

OFile & PLMD::OFile::fmtField ( const std::string &  fmt)
inherited

Set the format for writing double precision fields.

OFile & PLMD::OFile::fmtField ( )
inherited

Reset the format for writing double precision fields to its default.

bool PLMD::FileBase::isOpen ( )
inherited

Check if a file is open.

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

Link to an already open filed.

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

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

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

Link to a Communicator object.

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

Link to an Action object.

Automatically links also the corresponding PlumedMain and Communicator.

OFile & PLMD::OFile::link ( OFile l)
inherited

Allows linking this OFile to another one.

In this way, everything written to this OFile will be immediately written on the linked OFile. Notice that a OFile should be either opened explicitly, linked to a FILE or linked to a OFile

OFile & PLMD::OFile::open ( const std::string &  name)
virtualinherited

Opens the file using automatic append/backup.

Implements PLMD::FileBase.

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

Check for error/eof.

int PLMD::OFile::printf ( const char *  fmt,
  ... 
)
inherited

Formatted output with explicit format - a la printf.

OFile & PLMD::OFile::printField ( const std::string &  name,
double  v 
)
inherited

Set the value of a double precision field.

OFile & PLMD::OFile::printField ( const std::string &  name,
int  v 
)
inherited

Set the value of a int field.

OFile & PLMD::OFile::printField ( const std::string &  name,
const std::string &  v 
)
inherited

Set the value of a string field.

OFile & PLMD::OFile::printField ( Value val,
const double &  v 
)
inherited

Print a value.

OFile & PLMD::OFile::printField ( )
inherited

Close a line.

Typically used as

  of.printField("a",a).printField("b",b).printField();
OFile & PLMD::OFile::rewind ( )
inherited

Rewind a file.

void PLMD::OFile::setBackupString ( const std::string &  str)
inherited

Set the string name to be used for automatic backup.

void PLMD::FileBase::setHeavyFlush ( )
inlineinherited

Set heavyFlush flag.

OFile & PLMD::OFile::setLinePrefix ( const std::string &  l)
inherited

Set the prefix for output.

Typically "PLUMED: ". Notice that lines with a prefix cannot be parsed using fields in a IFile.

OFile & PLMD::OFile::setupPrintValue ( Value val)
inherited

Used to setup printing of values.

void PLMD::FileBase::test ( )
staticinherited

Runs a small testcase.

Member Data Documentation

Action* PLMD::FileBase::action
protectedinherited

pointer to corresponding action. NULL if not linked

bool PLMD::FileBase::cloned
protectedinherited

Control closing on destructor.

If true, file will not be closed in destructor

Communicator* PLMD::FileBase::comm
protectedinherited

communicator. NULL if not set

bool PLMD::FileBase::eof
protectedinherited

Set to true when end of file is encountered.

bool PLMD::FileBase::err
protectedinherited

Set to true when error is encountered.

FILE* PLMD::FileBase::fp
protectedinherited

file pointer

void* PLMD::FileBase::gzfp
protectedinherited

zip file pointer.

bool PLMD::FileBase::heavyFlush
protectedinherited

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

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

path of the opened file

PlumedMain* PLMD::FileBase::plumed
protectedinherited

pointer to main plumed object. NULL if not linked


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