jplus-0.4.6
trjfile Class Reference

YACTS trajectory file. More...

#include <src/trjfile.h>

Inheritance diagram for trjfile:

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.

Detailed Description

YACTS trajectory file.

Holds the past and current states of integrated system.


Constructor & Destructor Documentation

Instantiates unopened trajectory file.


Member Function Documentation

bool trjfile::close ( )

Closes the trajectory.

std::streampos trjfile::frame_size ( ) [protected]

frame size on disk

int trjfile::getNEQ ( )

Get number of equations.

Returns:
the number of frames or 0 if the file was just created and no frames were stored yet.
bool trjfile::good ( )

Checks that trajectory file is opened and properly positioned.

Returns:
true if everything is ok.

Checks if the file has next frame stored.

Returns:
true if the next frame can be read.
std::streampos trjfile::header_size ( ) [protected]

header size on disk

bool trjfile::loadFrame ( double &  T,
double *  data 
)

Load frame.

Parameters:
Tthe variable to hold the time of the frame.
datathe 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.

Parameters:
pathfilesystem path to the trajectory.
createwhen true an empty trajectory will be created when file is missing, otherwise this is failure.
Returns:
true if everything is ok.
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.

Parameters:
neqnumber of equations in the system.
Ttime of the frame.
dataframe data.
Returns:
true if success.
void trjfile::setHeader ( int  id,
int  neq 
) [protected]

patch the header with new data

Parameters:
idreserved.
neqnumber of equations in the system.
int trjfile::size ( )

Get number of frames in the file.

Returns:
the total number of frames currently in trajectory.

Reimplemented in yacts.

bool trjfile::toFrame ( int  frame)

Position the file before the specified frame.

Parameters:
frameposition will be set before this frame, 0 positions before the first frame, -1 positions before the last frame.

Field Documentation

int trjfile::neq [protected]

Number of equations in the system solved (frame size).

std::fstream trjfile::trj [protected]

Opened stream to the underlying file.


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