jplus-0.4.6
|
YACTS trajectory file. More...
#include <src/trjfile.h>
Public Member Functions | |
trjfile () | |
Instantiates unopened trajectory file. | |
bool | open (std::string path, bool create=true) |
Opens/creates trajectory and positions it before the last frame, or right after the header if trajectory was empty. | |
bool | close () |
Closes the trajectory. | |
bool | good () |
Checks that trajectory file is opened and properly positioned. | |
bool | saveFrame (const int neq, const double &T, const double *data) |
Saves frame to the file at the current pos, appends if necessary. | |
bool | hasNextFrame () |
Checks if the file has next frame stored. | |
int | getNEQ () |
Get number of equations. | |
bool | loadFrame (double &T, double *data) |
Load frame. | |
int | size () |
Get number of frames in the file. | |
bool | toFrame (int frame) |
Position the file before the specified frame. | |
Protected Member Functions | |
std::streampos | header_size () |
header size on disk | |
std::streampos | frame_size () |
frame size on disk | |
void | setHeader (int id, int neq) |
patch the header with new data | |
Protected Attributes | |
int | neq |
Number of equations in the system solved (frame size). | |
std::fstream | trj |
Opened stream to the underlying file. |
YACTS trajectory file.
Holds the past and current states of integrated system.
trjfile::trjfile | ( | ) |
Instantiates unopened trajectory file.
bool trjfile::close | ( | ) |
Closes the trajectory.
std::streampos trjfile::frame_size | ( | ) | [protected] |
frame size on disk
int trjfile::getNEQ | ( | ) |
Get number of equations.
bool trjfile::good | ( | ) |
Checks that trajectory file is opened and properly positioned.
bool trjfile::hasNextFrame | ( | ) |
Checks if the file has next frame stored.
std::streampos trjfile::header_size | ( | ) | [protected] |
header size on disk
bool trjfile::loadFrame | ( | double & | T, |
double * | data | ||
) |
Load frame.
T | the variable to hold the time of the frame. |
data | the array to hold the frame data (should have enough space for getNEQ() doubles). |
bool trjfile::open | ( | std::string | path, |
bool | create = true |
||
) |
Opens/creates trajectory and positions it before the last frame, or right after the header if trajectory was empty.
path | filesystem path to the trajectory. |
create | when true an empty trajectory will be created when file is missing, otherwise this is failure. |
bool trjfile::saveFrame | ( | const int | neq, |
const double & | T, | ||
const double * | data | ||
) |
Saves frame to the file at the current pos, appends if necessary.
If this is the first frame saved, the passed neq parameter _defines_ the number of frames in this trajectory file, then it becomes an error to save frames with different neq.
neq | number of equations in the system. |
T | time of the frame. |
data | frame data. |
void trjfile::setHeader | ( | int | id, |
int | neq | ||
) | [protected] |
patch the header with new data
id | reserved. |
neq | number of equations in the system. |
int trjfile::size | ( | ) |
Get number of frames in the file.
Reimplemented in yacts.
bool trjfile::toFrame | ( | int | frame | ) |
Position the file before the specified frame.
frame | position will be set before this frame, 0 positions before the first frame, -1 positions before the last frame. |
int trjfile::neq [protected] |
Number of equations in the system solved (frame size).
std::fstream trjfile::trj [protected] |
Opened stream to the underlying file.