Gromacs  2020.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
gmx::test::TrajectoryFrameReader Class Reference

#include <programs/mdrun/tests/trajectoryreader.h>

Description

Manages returning a t_trxframe whose contents were read from successive frames of an trajectory file.

Public Member Functions

bool readNextFrame ()
 Attempt to read the next frame from the trajectory file. More...
 
TrajectoryFrame frame ()
 Return the next frame from the trajectory file. More...
 
 TrajectoryFrameReader (const std::string &filename)
 Constructor. More...
 

Constructor & Destructor Documentation

gmx::test::TrajectoryFrameReader::TrajectoryFrameReader ( const std::string &  filename)
explicit

Constructor.

Parameters
[in]filenameName of trajectory file to open and read.

Member Function Documentation

TrajectoryFrame gmx::test::TrajectoryFrameReader::frame ( )

Return the next frame from the trajectory file.

If the next frame has not been probed for, then probe for it. If no next frame exists, then throw APIError, because user code should have called readNextFrameStub itself if this is possible. (This permits user code to avoid making calls to readNextFrameStub in a case where it already knows that the frame exists.)

Exceptions
APIErrorif no next frame exists, or if it lacks either time or step number.
bool gmx::test::TrajectoryFrameReader::readNextFrame ( )

Attempt to read the next frame from the trajectory file.

Returns
Whether a frame was available to read.

This call wraps the read_first_frame()/read_next_frame() API, which does the file opening as a side effect of reading the first frame.

If true is returned, then TrajectoryFrame frame() should be called to get access to the data. If false is returned, then no further data exists and no further call to readNextFrameStub or TrajectoryFrame frame() should occur.

Exceptions
FileIOErrorupon reading the first frame, if the trajectory file cannot be opened
APIErrorif an earlier probe has not been properly handled (by calling frame(), or stopping trying to read from the file).

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