jplus-0.4.7
trjfile.h
Go to the documentation of this file.
1/* -*- mode: c++; indent-tabs-mode:nil -*- */
2#include <fstream>
3#include <string>
4
6class trjfile {
7protected:
9 int neq;
11 std::fstream trj;
12public:
13
16
23 bool open(std::string path, bool create=true);
24
26 bool close();
27
30 bool good();
31
40 bool saveFrame(const int neq, const double &T, const double* data);
41
45
49 int getNEQ();
50
55 bool loadFrame(double &T, double* data);
56
59 int size();
60
64 bool toFrame(int frame);
65
66protected:
68 std::streampos header_size();
69
71 std::streampos frame_size();
72
76 void setHeader(int id, int neq);
77
78};
YACTS trajectory file.
Definition trjfile.h:6
int size()
Get number of frames in the file.
int neq
Number of equations in the system solved (frame size).
Definition trjfile.h:9
bool saveFrame(const int neq, const double &T, const double *data)
Saves frame to the file at the current pos, appends if necessary.
bool good()
Checks that trajectory file is opened and properly positioned.
int getNEQ()
Get number of equations.
bool open(std::string path, bool create=true)
Opens/creates trajectory and positions it before the last frame, or right after the header if traject...
bool close()
Closes the trajectory.
std::fstream trj
Opened stream to the underlying file.
Definition trjfile.h:11
trjfile()
Instantiates unopened trajectory file.
void setHeader(int id, int neq)
patch the header with new data
bool toFrame(int frame)
Position the file before the specified frame.
bool loadFrame(double &T, double *data)
Load frame.
std::streampos frame_size()
frame size on disk
bool hasNextFrame()
Checks if the file has next frame stored.
std::streampos header_size()
header size on disk