framefast::framereader Class Reference
[Fast frame I/O]

#include <framefast.hh>

List of all members.

Public Member Functions

 framereader ()
virtual ~framereader ()
bool loadFile (const char *filename, bool map=true)
bool loadFrame (const void *fdata, int len, bool ownit=false)
bool loadFrame (basic_frame_storage *frame)
bool loadFrame (frame_storage_ptr &frame)
bool releaseFrame (frame_storage_ptr &frame)
void unload ()
bool isFrame ()
bool getDict (dict_t &dict)
bool getFrameHeader (frameheader_t &h, int fnum=0)
bool getDetectorInfo (detector_t &det, int fnum=0, int dnum=0)
int getDetectorInfoNum ()
bool getHistoryInfo (hist_t &hist, int fnum=0)
bool getRawDataInfo (rawdata_t &raw, int fnum=0)
bool getData (data_t &dat, int_8u_t pos, datatype_t dtype, frvect_t::datacopy cpy=frvect_t::fv_copy)
bool getData (data_t &dat, const char *channel, int nframe=0, frvect_t::datacopy cpy=frvect_t::fv_copy)
int copy (const char *chnname, real_4_t *x, int max)
int copy (const char *chnname, real_8_t *x, int max)
int copy (const char *chnname, int_2s_t *x, int max)
int copy (const char *chnname, int_4s_t *x, int max)
std::ostream & writeTOC (std::ostream &os)
std::ostream & writeFileHeader (std::ostream &os)
int length () const
const char * frame () const
const char * frameend () const
const char * fname () const
std::string guessFilename ()
int nframe ()
Time starttime (int framenum=0)
Interval duration (int framenum=0)
Time nexttime ()
const toc_tgetTOC ()
void setScanTOC (bool set=true)

Protected Types

enum  toc_status_t { kTOCUndefined = 0, kTOCNo, kTOCYes }
 TOC status. More...
enum  header_status_t { kFileHeaderUndefined = 0, kFileHeaderInvalid, kFileHeaderValid }
 file header status More...

Protected Member Functions

bool newTOC ()
 new toc structure
bool freeTOC ()
 free TOC structure
bool readTOC ()
 read TOC structure
bool scanTOC ()
 regenerate TOC from raw frame file
bool newFileHeader ()
 new header structure
bool freeFileHeader ()
 free header
bool readFileHeader ()
 read header
int lookup (const char *chnname, int_8u_t *&ofs, datatype_t &dtype)
 look up channel in TOC

Protected Attributes

bool fDebug
 Debug flag.
frame_storage_ptr fFrame
 Frame data.
toc_tfTOC
 Pointer to toc.
toc_status_t fHasTOC
 Frame TOC status.
bool fForceScanToc
 Force to rescan TOC.
fileheader_tfFileHeader
 Pointer to header.
header_status_t fHasFileHeader
 Frame header status.
frameheader_tfFrameHeader
 Pointer to frameheader.
bool fSwap
 Need to swap? (only valid after header was read successful).


Detailed Description

Fast frame reader. This frame reader uses the table of content (TOC) of a frame to extract data directly from the file or memory object. It uses memory mapped files for fast IO throughput.Performance has been optimized for reading small number of channels from large frame files which are stored on disk. Only frames version 4.0 or later which include a TOC are supported. brief Fast frame reader.
Author:
Written September 2000 by Daniel Sigg
Version:
1.0

Member Enumeration Documentation

enum framefast::framereader::toc_status_t [protected]

TOC status.

Enumerator:
kTOCUndefined  TOC not yet checked.
kTOCNo  no TOC
kTOCYes  has TOC

enum framefast::framereader::header_status_t [protected]

file header status

Enumerator:
kFileHeaderUndefined  file header not yet checked
kFileHeaderInvalid  invalid file header (frame)
kFileHeaderValid  valid file header


Constructor & Destructor Documentation

framefast::framereader::framereader (  ) 

Constructs a fast frame reader. brief Default constructor.

virtual framefast::framereader::~framereader (  )  [virtual]

Destructs a fast frame reader. brief Destructor.


Member Function Documentation

bool framefast::framereader::loadFile ( const char *  filename,
bool  map = true 
)

Loads a file into the fast frame reader (the file is not actually read, just mapped). brief Load a file.

Parameters:
filename Name of file
map Map the file into memory rather than read it
Returns:
true if successful

bool framefast::framereader::loadFrame ( const void *  fdata,
int  len,
bool  ownit = false 
)

Loads a memory object into the fast frame reader. brief Load a memory object.

Parameters:
fdata Pointer to frame data
len Length of data array (in bytes)
ownit The framereader will own the data
Returns:
true if successful

bool framefast::framereader::loadFrame ( basic_frame_storage frame  )  [inline]

Loads a frame into the fast frame reader. The frame storage object is adopted. brief Load a frame object.

Parameters:
frame frame object
Returns:
true if successful

bool framefast::framereader::loadFrame ( frame_storage_ptr frame  )  [inline]

Loads a frame into the fast frame reader. The frame storage object is adopted. brief Load a frame object.

Parameters:
frame frame object pointer
Returns:
true if successful

bool framefast::framereader::releaseFrame ( frame_storage_ptr frame  ) 

Releases a previously loaded frame form the fast frame reader. A frame storage pointer object is returned. brief Release a frame object.

Parameters:
frame frame object pointer (return)
Returns:
true if successful

void framefast::framereader::unload (  ) 

Unloads a frame form the fast frame reader. brief Unload a frame.

Returns:
void

bool framefast::framereader::isFrame (  ) 

Reads the frame header and checks for frame format. brief Checks frame.

Returns:
true if frame file, false otherwise

bool framefast::framereader::getDict ( dict_t dict  ) 

Get the dictionary. brief Get dictionary.

Parameters:
dict Dictionary (return)
Returns:
true if successful

bool framefast::framereader::getFrameHeader ( frameheader_t h,
int  fnum = 0 
)

Get a frame header. brief Get a frame header.

Parameters:
h Frame header
fnum Frame number within file
Returns:
true if successful

bool framefast::framereader::getDetectorInfo ( detector_t det,
int  fnum = 0,
int  dnum = 0 
)

Get detector information. brief Get detector information.

Parameters:
det Detector information
fnum Frame number within file
dnum Detector number
Returns:
true if successful

int framefast::framereader::getDetectorInfoNum (  ) 

Get number of detector information. brief Get number of detectors.

Returns:
Number of detectors

bool framefast::framereader::getHistoryInfo ( hist_t hist,
int  fnum = 0 
)

Get history information. brief Get history information.

Parameters:
hist History information
fnum Frame number within file
Returns:
true if successful

bool framefast::framereader::getRawDataInfo ( rawdata_t raw,
int  fnum = 0 
)

Get raw data information. brief Get raw data information.

Parameters:
raw Raw data information
fnum Frame number within file
Returns:
true if successful

bool framefast::framereader::getData ( data_t dat,
int_8u_t  pos,
datatype_t  dtype,
frvect_t::datacopy  cpy = frvect_t::fv_copy 
)

Get data from the specified position. brief Get data.

Parameters:
dat Data record
pos Position within frame
dtype Data type
cpy Copy data?
Returns:
true if successful

bool framefast::framereader::getData ( data_t dat,
const char *  channel,
int  nframe = 0,
frvect_t::datacopy  cpy = frvect_t::fv_copy 
)

Get data for the specified channel and frame number. brief Get data.

Parameters:
dat Data record
channel Channel name
nframe Frame number
cpy Copy data?
Returns:
true if successful

int framefast::framereader::copy ( const char *  chnname,
real_4_t *  x,
int  max 
)

Copies channel data into a float array. A return value of -1 indicates that the frame does not contain a TOC; a return value of 0 indicates that the channel name was not found; a positive return value repesents the number of data points associated with this channel. The returned number of points can be larger than the maximum specified, however, only max points are actually copied into the array. If the array pointer is 0, just the number of points is returned. brief Get float data.

Parameters:
chnname Name of channel
x data array (destination)
max maximum length of data array
Returns:
number of data points, or <=0 on error

int framefast::framereader::copy ( const char *  chnname,
real_8_t *  x,
int  max 
)

Copies channel data into a double array. A return value of -1 indicates that the frame does not contain a TOC; a return value of 0 indicates that the channel name was not found; a positive return value repesents the number of data points associated with this channel. The returned number of points can be larger than the maximum specified, however, only max points are actually copied into the array. If the array pointer is 0, just the number of points is returned. brief Get double data.

Parameters:
chnname Name of channel
x data array (destination)
max maximum length of data array
Returns:
number of data points, or <=0 on error

int framefast::framereader::copy ( const char *  chnname,
int_2s_t *  x,
int  max 
)

Copies channel data into a short array. A return value of -1 indicates that the frame does not contain a TOC; a return value of 0 indicates that the channel name was not found; a positive return value repesents the number of data points associated with this channel. The returned number of points can be larger than the maximum specified, however, only max points are actually copied into the array. If the array pointer is 0, just the number of points is returned. brief Get short data.

Parameters:
chnname Name of channel
x data array (destination)
max maximum length of data array
Returns:
number of data points, or <=0 on error

int framefast::framereader::copy ( const char *  chnname,
int_4s_t *  x,
int  max 
)

Copies channel data into an integer array. A return value of -1 indicates that the frame does not contain a TOC; a return value of 0 indicates that the channel name was not found; a positive return value repesents the number of data points associated with this channel. The returned number of points can be larger than the maximum specified, however, only max points are actually copied into the array. If the array pointer is 0, just the number of points is returned. brief Get int data.

Parameters:
chnname Name of channel
x data array (destination)
max maximum length of data array
Returns:
number of data points, or <=0 on error

std::ostream& framefast::framereader::writeTOC ( std::ostream &  os  ) 

Writes the TOC to an output stream. brief Write TOC.

Parameters:
os Output stream
Returns:
Output stream

std::ostream& framefast::framereader::writeFileHeader ( std::ostream &  os  ) 

Writes the file header to an output stream. brief Write file header.

Parameters:
os Output stream
Returns:
Output stream

int framefast::framereader::length (  )  const [inline]

Gets the length of the frame. brief Length of frame.

Returns:
Length of frame

const char* framefast::framereader::frame (  )  const [inline]

Gets the pointer to the frame. brief Pointer of frame.

Returns:
Frame pointer

const char* framefast::framereader::frameend (  )  const [inline]

Gets the pointer to the end of the frame. brief Pointer of frame end.

Returns:
End of frame pointer

const char* framefast::framereader::fname (  )  const [inline]

Gets the original name of the frame storage object. brief Origianl name of frame.

Returns:
Origianl name of frame

std::string framefast::framereader::guessFilename (  ) 

Guess the basic filename from the detector information and the GPS time (doesn't include directory nor extension). Uses the original name if set. brief Guess filename.

Returns:
Filename

int framefast::framereader::nframe (  ) 

Gets the number of frames in the file. brief Number of frames.

Returns:
Number of frames

Time framefast::framereader::starttime ( int  framenum = 0  ) 

Gets the start time of a frame. brief Start time of a frame.

Parameters:
framenum Frame number
Returns:
Start time

Interval framefast::framereader::duration ( int  framenum = 0  ) 

Gets the duration of a frame. brief Duration of a frame.

Parameters:
framenum Frame number
Returns:
Duration

Time framefast::framereader::nexttime (  ) 

Gets the time of the next frame (in the next file). brief time of next frame.

Returns:
Next time

const toc_t* framefast::framereader::getTOC (  ) 

Gets the TOC. brief Get the TOC.

Returns:
TOC

void framefast::framereader::setScanTOC ( bool  set = true  )  [inline]

Enforce a rescan of the TOC. brief Rescan the TOC.

Returns:
void


The documentation for this class was generated from the following file:
Generated on Sun Mar 8 19:21:14 2009 for dmt by  doxygen 1.5.4