Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

colvarproxy_io Class Reference

Methods for data input/output. More...

#include <colvarproxy_io.h>

Inheritance diagram for colvarproxy_io:

colvarproxy colvarproxy_vmd List of all members.

Public Methods

 colvarproxy_io ()
 Constructor. More...

virtual ~colvarproxy_io ()
 Destructor. More...

virtual bool io_available ()
 Ensure that we're on the main thread (derived class will do actual check). More...

virtual int get_frame (long int &)
 \brief Save the current frame number in the argument given. More...

virtual int set_frame (long int)
 \brief Set the current frame number (as well as colvarmodule::it). More...

virtual int backup_file (char const *filename)
 \brief Rename the given file, before overwriting it. More...

int backup_file (std::string const &filename)
 \brief Rename the given file, before overwriting it. More...

virtual int remove_file (char const *filename)
 Remove the given file (on Windows only, rename to filename.old). More...

int remove_file (std::string const &filename)
 Remove the given file (on Windows only, rename to filename.old). More...

virtual int rename_file (char const *filename, char const *newfilename)
 Rename the given file. More...

int rename_file (std::string const &filename, std::string const &newfilename)
 Rename the given file. More...

std::stringinput_prefix ()
 Prefix of the input state file to be read next. More...

std::stringoutput_prefix ()
 Default prefix to be used for all output files (final configuration). More...

std::stringrestart_output_prefix ()
 Prefix of the restart (checkpoint) file to be written next. More...

int default_restart_frequency () const
 Default restart frequency (as set by the simulation engine). More...

char const *& input_buffer ()
 Buffer from which the input state information may be read. More...

virtual std::istream & input_stream (std::string const &input_name, std::string const description="file/channel", bool error_on_fail=true)
 Returns a reference to given input stream, creating it if needed
Parameters:
input_name  File name (later only a handle)
description  Purpose of the file
error_on_fail  Raise error when failing to open (allow testing).
More...


virtual bool input_stream_exists (std::string const &input_name)
 Check if the file/channel is open (without opening it if not). More...

virtual int close_input_stream (std::string const &input_name)
 Closes the given input stream. More...

virtual int close_input_streams ()
 Closes all input streams. More...

virtual std::ostream & output_stream (std::string const &output_name, std::string const description="file/channel")
 Returns a reference to the named output file/channel (open it if needed)
Parameters:
output_name  File name or identifier
description  Purpose of the file.
More...


virtual bool output_stream_exists (std::string const &output_name)
 Check if the file/channel is open (without opening it if not). More...

virtual int flush_output_stream (std::string const &output_name)
 Flushes the given output file/channel. More...

virtual int flush_output_streams ()
 Flushes all output files/channels. More...

virtual int close_output_stream (std::string const &output_name)
 Closes the given output file/channel. More...

virtual int close_output_streams ()
 Close all open files/channels to prevent data loss. More...


Protected Attributes

std::string input_prefix_str
 Prefix of the input state file to be read next. More...

std::string output_prefix_str
 Default prefix to be used for all output files (final configuration). More...

std::string restart_output_prefix_str
 Prefix of the restart (checkpoint) file to be written next. More...

int restart_frequency_engine
 How often the simulation engine will write its own restart. More...

std::map< std::string, std::istream * > input_streams_
 Container of input files/channels indexed by path name. More...

std::istream * input_stream_error_
 Object whose reference is returned when read errors occur. More...

std::map< std::string, std::ostream * > output_streams_
 Currently open output files/channels. More...

std::ostream * output_stream_error_
 Object whose reference is returned when write errors occur. More...

char const * input_buffer_
 Buffer from which the input state information may be read. More...


Detailed Description

Methods for data input/output.

Definition at line 19 of file colvarproxy_io.h.


Constructor & Destructor Documentation

colvarproxy_io::colvarproxy_io  
 

Constructor.

Definition at line 30 of file colvarproxy_io.C.

References input_buffer_, input_stream_error_, NULL, output_stream_error_, and restart_frequency_engine.

colvarproxy_io::~colvarproxy_io   [virtual]
 

Destructor.

Definition at line 41 of file colvarproxy_io.C.

References close_input_streams, close_output_streams, input_stream_error_, and output_stream_error_.


Member Function Documentation

int colvarproxy_io::backup_file std::string const &    filename [inline]
 

\brief Rename the given file, before overwriting it.

Definition at line 44 of file colvarproxy_io.h.

References backup_file.

int colvarproxy_io::backup_file char const *    filename [virtual]
 

\brief Rename the given file, before overwriting it.

Definition at line 68 of file colvarproxy_io.C.

References COLVARS_ERROR, colvarmodule::error, rename_file, and string.

Referenced by backup_file, colvarmodule::backup_file, and output_stream.

int colvarproxy_io::close_input_stream std::string const &    input_name [virtual]
 

Closes the given input stream.

Definition at line 188 of file colvarproxy_io.C.

References COLVARS_FILE_ERROR, colvarmodule::error, input_stream_exists, and input_streams_.

Referenced by colvar_grid_gradient::colvar_grid_gradient, colvarbias_restraint_histogram::init, colvarmodule::read_config_file, UIestimator::UIestimator::read_inputfiles, colvar_grid::read_multicol, colvarbias::read_state_prefix, colvarmodule::setup_input, and simple_scalar_dist_functions.

int colvarproxy_io::close_input_streams   [virtual]
 

Closes all input streams.

Definition at line 200 of file colvarproxy_io.C.

References input_streams_.

Referenced by ~colvarproxy_io.

int colvarproxy_io::close_output_stream std::string const &    output_name [virtual]
 

Closes the given output file/channel.

Definition at line 279 of file colvarproxy_io.C.

References COLVARS_BUG_ERROR, colvarmodule::error, io_available, output_stream_exists, and output_streams_.

Referenced by colvarbias_meta::reopen_replica_buffer_file, colvar_grid::write_multicol, colvar_grid::write_opendx, colvarbias_restraint_histogram::write_output_files, colvarbias_meta::write_replica_state_file, colvarmodule::write_restart_file, and colvarbias_meta::~colvarbias_meta.

int colvarproxy_io::close_output_streams   [virtual]
 

Close all open files/channels to prevent data loss.

Definition at line 296 of file colvarproxy_io.C.

References io_available, and output_streams_.

Referenced by colvarproxy::~colvarproxy, and ~colvarproxy_io.

int colvarproxy_io::default_restart_frequency   const [inline]
 

Default restart frequency (as set by the simulation engine).

Definition at line 87 of file colvarproxy_io.h.

References restart_frequency_engine.

Referenced by colvarmodule::colvarmodule.

int colvarproxy_io::flush_output_stream std::string const &    output_name [virtual]
 

Flushes the given output file/channel.

Definition at line 247 of file colvarproxy_io.C.

References io_available, output_stream_exists, and output_streams_.

Referenced by colvarbias_meta::replica_share, colvar::write_state, and colvarmodule::write_traj_files.

int colvarproxy_io::flush_output_streams   [virtual]
 

Flushes all output files/channels.

Definition at line 263 of file colvarproxy_io.C.

References io_available, and output_streams_.

Referenced by colvarproxy::post_run, and colvarmodule::reset.

int colvarproxy_io::get_frame long int &    [virtual]
 

\brief Save the current frame number in the argument given.

Reimplemented in colvarproxy_vmd.

Definition at line 56 of file colvarproxy_io.C.

References COLVARS_NOT_IMPLEMENTED.

char const* & colvarproxy_io::input_buffer   [inline]
 

Buffer from which the input state information may be read.

Definition at line 93 of file colvarproxy_io.h.

References input_buffer_.

Referenced by colvarmodule::setup_input.

std::string& colvarproxy_io::input_prefix   [inline]
 

Prefix of the input state file to be read next.

Definition at line 69 of file colvarproxy_io.h.

References input_prefix_str.

Referenced by colvarmodule::print_total_forces_errning, and colvarmodule::setup_input.

std::istream & colvarproxy_io::input_stream std::string const &    input_name,
std::string const    description = "file/channel",
bool    error_on_fail = true
[virtual]
 

Returns a reference to given input stream, creating it if needed

Parameters:
input_name  File name (later only a handle)
description  Purpose of the file
error_on_fail  Raise error when failing to open (allow testing).

Definition at line 154 of file colvarproxy_io.C.

References COLVARS_BUG_ERROR, COLVARS_FILE_ERROR, colvarmodule::error, input_stream_error_, input_stream_exists, input_streams_, and io_available.

Referenced by colvar_grid_gradient::colvar_grid_gradient, colvarbias_restraint_histogram::init, colvarmodule::read_config_file, UIestimator::UIestimator::read_inputfiles, colvar_grid::read_multicol, colvarbias::read_state_prefix, colvarmodule::setup_input, and simple_scalar_dist_functions.

bool colvarproxy_io::input_stream_exists std::string const &    input_name [virtual]
 

Check if the file/channel is open (without opening it if not).

Definition at line 182 of file colvarproxy_io.C.

References input_streams_.

Referenced by close_input_stream, and input_stream.

bool colvarproxy_io::io_available   [virtual]
 

Ensure that we're on the main thread (derived class will do actual check).

Reimplemented in colvarproxy.

Definition at line 50 of file colvarproxy_io.C.

Referenced by close_output_stream, close_output_streams, flush_output_stream, flush_output_streams, input_stream, and output_stream.

std::string& colvarproxy_io::output_prefix   [inline]
 

Default prefix to be used for all output files (final configuration).

Definition at line 75 of file colvarproxy_io.h.

References output_prefix_str.

Referenced by colvarmodule::setup_output.

std::ostream & colvarproxy_io::output_stream std::string const &    output_name,
std::string const    description = "file/channel"
[virtual]
 

Returns a reference to the named output file/channel (open it if needed)

Parameters:
output_name  File name or identifier
description  Purpose of the file.

Definition at line 212 of file colvarproxy_io.C.

References backup_file, COLVARS_BUG_ERROR, COLVARS_FILE_ERROR, colvarmodule::debug, colvarmodule::error, io_available, colvarmodule::log, output_stream_error_, output_stream_exists, and output_streams_.

Referenced by colvar::calc_runave, colvarbias_meta::reopen_replica_buffer_file, colvar_grid::write_multicol, colvar_grid::write_opendx, colvarbias_restraint_histogram::write_output_files, colvarbias_meta::write_replica_state_file, colvarmodule::write_restart_file, and colvarmodule::write_traj_files.

bool colvarproxy_io::output_stream_exists std::string const &    output_name [virtual]
 

Check if the file/channel is open (without opening it if not).

Definition at line 241 of file colvarproxy_io.C.

References output_streams_.

Referenced by colvar::calc_runave, close_output_stream, flush_output_stream, and output_stream.

int colvarproxy_io::remove_file std::string const &    filename [inline]
 

Remove the given file (on Windows only, rename to filename.old).

Definition at line 53 of file colvarproxy_io.h.

References remove_file.

int colvarproxy_io::remove_file char const *    filename [virtual]
 

Remove the given file (on Windows only, rename to filename.old).

Definition at line 100 of file colvarproxy_io.C.

References COLVARS_FILE_ERROR, and colvarmodule::error.

Referenced by remove_file, rename_file, colvarbias_meta::reopen_replica_buffer_file, and colvarbias_meta::write_replica_state_file.

int colvarproxy_io::rename_file std::string const &    filename,
std::string const &    newfilename
[inline]
 

Rename the given file.

Definition at line 62 of file colvarproxy_io.h.

References rename_file.

int colvarproxy_io::rename_file char const *    filename,
char const *    newfilename
[virtual]
 

Rename the given file.

Definition at line 133 of file colvarproxy_io.C.

References COLVARS_FILE_ERROR, colvarmodule::log, and remove_file.

Referenced by backup_file, rename_file, and colvarbias_meta::write_replica_state_file.

std::string& colvarproxy_io::restart_output_prefix   [inline]
 

Prefix of the restart (checkpoint) file to be written next.

Definition at line 81 of file colvarproxy_io.h.

References restart_output_prefix_str.

Referenced by colvarmodule::setup_output.

int colvarproxy_io::set_frame long    int [virtual]
 

\brief Set the current frame number (as well as colvarmodule::it).

Reimplemented in colvarproxy_vmd.

Definition at line 62 of file colvarproxy_io.C.

References COLVARS_NOT_IMPLEMENTED.


Member Data Documentation

char const* colvarproxy_io::input_buffer_ [protected]
 

Buffer from which the input state information may be read.

Definition at line 163 of file colvarproxy_io.h.

Referenced by colvarproxy_io, and input_buffer.

std::string colvarproxy_io::input_prefix_str [protected]
 

Prefix of the input state file to be read next.

Definition at line 139 of file colvarproxy_io.h.

Referenced by input_prefix.

std::istream* colvarproxy_io::input_stream_error_ [protected]
 

Object whose reference is returned when read errors occur.

Definition at line 154 of file colvarproxy_io.h.

Referenced by colvarproxy_io, input_stream, and ~colvarproxy_io.

std::map<std::string, std::istream *> colvarproxy_io::input_streams_ [protected]
 

Container of input files/channels indexed by path name.

Definition at line 151 of file colvarproxy_io.h.

Referenced by close_input_stream, close_input_streams, input_stream, and input_stream_exists.

std::string colvarproxy_io::output_prefix_str [protected]
 

Default prefix to be used for all output files (final configuration).

Definition at line 142 of file colvarproxy_io.h.

Referenced by output_prefix.

std::ostream* colvarproxy_io::output_stream_error_ [protected]
 

Object whose reference is returned when write errors occur.

Definition at line 160 of file colvarproxy_io.h.

Referenced by colvarproxy_io, output_stream, and ~colvarproxy_io.

std::map<std::string, std::ostream *> colvarproxy_io::output_streams_ [protected]
 

Currently open output files/channels.

Definition at line 157 of file colvarproxy_io.h.

Referenced by close_output_stream, close_output_streams, flush_output_stream, flush_output_streams, output_stream, and output_stream_exists.

int colvarproxy_io::restart_frequency_engine [protected]
 

How often the simulation engine will write its own restart.

Definition at line 148 of file colvarproxy_io.h.

Referenced by colvarproxy_io, and default_restart_frequency.

std::string colvarproxy_io::restart_output_prefix_str [protected]
 

Prefix of the restart (checkpoint) file to be written next.

Definition at line 145 of file colvarproxy_io.h.

Referenced by restart_output_prefix.


The documentation for this class was generated from the following files:
Generated on Sat Apr 20 02:45:04 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002