Collective Variables Module - Developer Documentation
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
colvarproxy_io Class Reference

Methods for data input/output. More...

#include <colvarproxy_io.h>

Inheritance diagram for colvarproxy_io:
Inheritance graph
[legend]

Public Member Functions

 colvarproxy_io ()
 Constructor.
 
virtual ~colvarproxy_io ()
 Destructor.
 
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 &)
 Save the current frame number in the argument given. More...
 
virtual int set_frame (long int)
 Set the current frame number (as well as colvarmodule::it) More...
 
std::string get_current_work_dir () const
 Get the current working directory of this process.
 
std::string join_paths (std::string const &path1, std::string const &path2) const
 Join two paths using the operating system's path separation.
 
virtual int backup_file (char const *filename)
 Rename the given file, before overwriting it. More...
 
int backup_file (std::string const &filename)
 Rename the given file, before overwriting it.
 
virtual int remove_file (char const *filename)
 Remove the given file (on Windows only, rename to filename.old)
 
int remove_file (std::string const &filename)
 Remove the given file (on Windows only, rename to filename.old)
 
virtual int rename_file (char const *filename, char const *newfilename)
 Rename the given file.
 
int rename_file (std::string const &filename, std::string const &newfilename)
 Rename the given file.
 
std::string const & input_prefix () const
 Prefix of the input state file to be read next.
 
virtual int set_input_prefix (std::string const &prefix)
 Initialize input_prefix (NOTE: it will be erased after state file is read)
 
std::string const & output_prefix () const
 Default prefix to be used for all output files (final configuration)
 
virtual int set_output_prefix (std::string const &prefix)
 Set default output prefix.
 
std::string const & restart_output_prefix () const
 Prefix of the restart (checkpoint) file to be written next.
 
virtual int set_restart_output_prefix (std::string const &prefix)
 Set default restart state file prefix.
 
int default_restart_frequency () const
 Default restart frequency (as set by the simulation engine)
 
virtual int set_default_restart_frequency (int freq)
 Communicate/set the restart frequency of the simulation engine.
 
std::istream & input_stream (std::string const &input_name, std::string const description="file/channel", bool error_on_fail=true)
 
std::istream & input_stream_from_string (std::string const &input_name, std::string const &content, std::string const description="string")
 
bool input_stream_exists (std::string const &input_name)
 Check if the file/channel is open (without opening it if not)
 
int close_input_stream (std::string const &input_name)
 Closes the given input stream.
 
int close_input_streams ()
 Closes all input streams.
 
int delete_input_stream (std::string const &input_name)
 Same as close_input_stream(), but also removes the corresponding entry from memory.
 
std::list< std::string > list_input_stream_names () const
 List all input streams that were opened at some point.
 
virtual std::ostream & output_stream (std::string const &output_name, std::string const description)
 
virtual bool output_stream_exists (std::string const &output_name)
 Check if the file/channel is open (without opening it if not)
 
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.
 
std::string output_prefix_str
 Default prefix to be used for all output files (final configuration)
 
std::string restart_output_prefix_str
 Prefix of the restart (checkpoint) file to be written next.
 
int restart_frequency_engine
 How often the simulation engine will write its own restart.
 
std::map< std::string, std::istream * > input_streams_
 Container of input files/channels indexed by path name.
 
std::istream * input_stream_error_
 Object whose reference is returned when read errors occur.
 
std::map< std::string, std::ostream * > output_streams_
 Currently open output files/channels.
 
std::ostream * output_stream_error_
 Object whose reference is returned when write errors occur.
 

Detailed Description

Methods for data input/output.

Member Function Documentation

◆ backup_file()

int colvarproxy_io::backup_file ( char const *  filename)
virtual

Rename the given file, before overwriting it.

Reimplemented in colvarproxy_namd.

◆ close_output_stream()

int colvarproxy_io::close_output_stream ( std::string const &  output_name)
virtual

Closes the given output file/channel.

Reimplemented in colvarproxy_namd.

◆ close_output_streams()

int colvarproxy_io::close_output_streams ( )
virtual

Close all open files/channels to prevent data loss.

Reimplemented in colvarproxy_namd.

◆ flush_output_stream()

int colvarproxy_io::flush_output_stream ( std::string const &  output_name)
virtual

Flushes the given output file/channel.

Reimplemented in colvarproxy_namd.

◆ flush_output_streams()

int colvarproxy_io::flush_output_streams ( )
virtual

Flushes all output files/channels.

Reimplemented in colvarproxy_namd.

◆ get_frame()

int colvarproxy_io::get_frame ( long int &  )
virtual

Save the current frame number in the argument given.

Reimplemented in colvarproxy_vmd.

◆ input_stream()

std::istream & colvarproxy_io::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_nameFile name (later only a handle)
descriptionPurpose of the file
error_on_failRaise error when failing to open (allow testing)

◆ input_stream_from_string()

std::istream & colvarproxy_io::input_stream_from_string ( std::string const &  input_name,
std::string const &  content,
std::string const  description = "string" 
)

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

Parameters
input_nameIdentifier of the input stream
contentSet this string as the stream's buffer
descriptionPurpose of the stream

◆ io_available()

bool colvarproxy_io::io_available ( )
virtual

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

Reimplemented in colvarproxy.

◆ output_stream()

std::ostream & colvarproxy_io::output_stream ( std::string const &  output_name,
std::string const  description 
)
virtual

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

Parameters
output_nameFile name or identifier
descriptionPurpose of the file

Reimplemented in colvarproxy_namd.

◆ set_frame()

int colvarproxy_io::set_frame ( long int  )
virtual

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

Reimplemented in colvarproxy_vmd.


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