Trajectory

class chemfiles::Trajectory

A Trajectory is a chemistry file on the hard drive. It is the main entry point of the chemfiles library.

A Trajectory is made with a File and a Format. The File implements all the physical operations, while the Format provides a way to interpret the file.

Public Functions

Trajectory(const std::string & filename, const std::string & mode = "r", const std::string & format = "")

Open a file, automatically gessing the file format and type from the extension.

Parameters
  • filename -

    The file path. In "w" or "a" modes, the file is created if it does not exist yet. In “r” mode, and exception is throwed is the file does not exist yet.

  • format -

    Specific format to use. Needed when there is no way to guess the format from the extension of the file, or when this guess would be wrong.

  • mode -

    Opening mode for the file. Default mode is “r” for read. Other supported modes depends on the underlying format and are “w” for write, and “a” for append. “w” mode discard any previously existing file.

Trajectory & operator>>(Frame & frame)

Read operator, in stream version.

Frame read()

Read operator, in method version.

Frame read_step(const size_t)

Read operator, in method version with specific step.

void sync()

Synchronize any content in the underlying buffer to the disk.

Trajectory & operator<<(const Frame & frame)

Write operator, in stream version.

void write(const Frame & frame)

Write operator, in method version.

void topology(const Topology &)

Set a topology to use while writing or reading format where no topological information is present.

void topology(const std::string & filename)

Use the topology of the first frame of the following file to read or write all the following files.

void cell(const UnitCell &)

Set an unit cell to use while writing or reading format when no information about unit cell is present.

size_t nsteps() const

Get the number of steps (the number of Frames) in this trajectory.

bool done() const

Have we read all the Frames in this file ?