ivutils
Loading...
Searching...
No Matches
SeqRecord Class Reference

class for storing slices of data_t values d: i <– sequence length (size_t) i <– number of slices (size_t) d d d d d d <– slice0 d d d d d d <– slice1, etc. More...

#include <loggerio.h>

Inheritance diagram for SeqRecord:
Collaboration diagram for SeqRecord:

Public Member Functions

 SeqRecord (size_t ds=sizeof(double), size_t dlen=1, bool if_header_=true)
 constructor parameter dlen is the length of each slice
 
int SetDataSize (size_t ds)
 returns -2 if file is open: can't change existing file
 
virtual int SetSliceLookup (const std::vector< int > &slookup_, ptrdiff_t numslice_limit=-1)
 Lookup for slice number shift with respect to current position.
 
const size_t GetCurrentSlice () const
 Gets the current slice (frame) being recorded.
 
virtual void CopyHeader (const SeqRecord &orig)
 Copies data_size and seqlen from left argumnet to the right one.
 
virtual int ReadHeaderFromFile (const std::string &name)
 Reads seqlen form file name and calculates data_size by means of numslices and seqlen written there.
 
virtual int OpenRecord (const std::string &name, const char *mode="w", const int shift=-1)
 opens a file if the mode is "w" then replaces the old file if it exists and starts new record if the mode is "a" then appends the old file if it exists (after checking format ) or starts new record if not if the mode is "r" analyses the given file (checks it format) and can perform GetData() if the mode is "ar" can do both reading and appending other combinations of r and w are not supported record will start from shift slice, or from the last slice if shift<0
 
virtual int AppendData (const void *rec, size_t arrlen=1, bool recorded=true)
 appends next arrlen records to a file from rec array if arrlen exceeds the maximum number left for current slice, appends the correct number of elements only DATA IS APPENDED BY COPYING FROM MEMORY (using fwrite) <- this behaviour may be changed in the future... returns the number of elements appended
 
virtual int SetTextHeader (const std::string &head)
 Set slice (frame) teaxt header .
 
virtual int NextSlice (bool recorded=true)
 Switches to the next slice.
 
virtual int CloseRecord ()
 Closes the file.
 
virtual int GetData (void *rec, size_t slicenum, size_t beg=0, size_t end=0)
 gets data from slice slicenum starting from beg till end all counters start from zero returns the number of elements read
 

Protected Attributes

size_t data_size
 length of unit data in bytes
 
size_t seqlen
 length of the data sequence
 
FILE * file
 current file
 
size_t rest
 the maximum number left for the last slice
 
size_t numslices
 the current number of slices
 
bool if_header
 presence of header at the begining of the file
 
long long pos
 position in file
 
size_t full_hsz
 full header size
 
ptrdiff_t numlim = -1
 num slices limit for the file, -1 if not used
 
std::vector< int > slookup
 slice shift lookup table
 
int max_slice_shift = 0
 span of slice shifts (positive only)
 

Detailed Description

class for storing slices of data_t values d: i <– sequence length (size_t) i <– number of slices (size_t) d d d d d d <– slice0 d d d d d d <– slice1, etc.

in a file the slices are of equal length header (i i) cab be skipped if flag if_header = false

error codes for all functions: -1 out of range -2 invalid file state (not open/ already open) -3 invalid file (can't open) -4 wrong file format

Member Function Documentation

◆ CloseRecord()

virtual int SeqRecord::CloseRecord ( )
inlinevirtual

Closes the file.

Returns
the current slice number

Reimplemented in QPLTRecord.

◆ GetCurrentSlice()

const size_t SeqRecord::GetCurrentSlice ( ) const
inline

Gets the current slice (frame) being recorded.

To start a new frame an explicit rewind is needed by calling NextSlice()

◆ NextSlice()

virtual int SeqRecord::NextSlice ( bool  recorded = true)
inlinevirtual

Switches to the next slice.

All appended data will be forwarded to this slice until next call to this function.

Returns
the current slice number or <0 in case of error

Reimplemented in QPLTRecord.

◆ OpenRecord()

virtual int SeqRecord::OpenRecord ( const std::string &  name,
const char *  mode = "w",
const int  shift = -1 
)
inlinevirtual

opens a file if the mode is "w" then replaces the old file if it exists and starts new record if the mode is "a" then appends the old file if it exists (after checking format ) or starts new record if not if the mode is "r" analyses the given file (checks it format) and can perform GetData() if the mode is "ar" can do both reading and appending other combinations of r and w are not supported record will start from shift slice, or from the last slice if shift<0

Returns
the current slice number, -2 if file is already open

Reimplemented in QPLTRecord.

◆ ReadHeaderFromFile()

virtual int SeqRecord::ReadHeaderFromFile ( const std::string &  name)
inlinevirtual

Reads seqlen form file name and calculates data_size by means of numslices and seqlen written there.

This function was produced to automaticaly detect SeqRecord parameters for a file. The function does neiver set file parameter nor the numslices feild of SeqRecord rec.

Reimplemented in QPLTRecord.

◆ SetTextHeader()

virtual int SeqRecord::SetTextHeader ( const std::string &  head)
inlinevirtual

Set slice (frame) teaxt header .

Supported by QPLT format. The information will be used while writing the next slice header.

Reimplemented in QPLTRecord.


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