firevision::FireVisionDataFile Class Reference

FireVision File Format for data files. More...

#include <fvutils/fileformat/fvff.h>

Inheritance diagram for firevision::FireVisionDataFile:

[legend]
List of all members.

Public Types

typedef std::list< FireVisionDataFileBlock * > BlockList
 List of FireVision data file blocks.

Public Member Functions

 FireVisionDataFile (unsigned short int magic_token, unsigned short int version)
 Constructor.
virtual ~FireVisionDataFile ()
 Destructor.
unsigned int magic_token ()
 Get the magic token of the file.
unsigned int version ()
 Get the version of the file.
bool is_big_endian ()
 Check if data is encoded as big endian.
bool is_little_endian ()
 Check if data is encoded as little endian.
size_t num_blocks ()
 Get the number of available info blocks.
const char * get_comment () const
 Get comment.
void set_comment (const char *comment)
 Set comment.
void set_owns_blocks (bool owns_blocks)
 Lets the file take over the ownership and give up the ownership of the blocks, respectively.
virtual void add_block (FireVisionDataFileBlock *block)
 Add a block.
virtual void clear ()
 Clear internal storage.
virtual void write (const char *file_name)
 Write file.
virtual void read (const char *file_name)
 Read file.
BlockListblocks ()
 Get blocks.

Static Public Member Functions

static unsigned short int read_magic_token (const char *filename)
 Get magic token from file.
static bool has_magic_token (const char *filename, unsigned short int magic_token)
 Check if file has a certain magic token.

Protected Attributes

void * _spec_header
 Content specific header.
size_t _spec_header_size
 Size in bytes of _spec_header.

Detailed Description

FireVision File Format for data files.

The FireVision File Format (FVFF) defines a generic file layout that is used to store large chunks of data on the the disk drive in a byte efficient way.

It is meant to serve as a skeleton which is used by subclasses to implement support for a concrete file format like colormaps or rectification information. It allows for arbitrary meta data to be added that is relevant to the format and it provides all the generic meta data that is needed to make the file format work and that is common to all formats.

Each format has a two byte magic token. In general it is of the form FFNN, where FF stays literally (FireVision File) and NN is replaced with a number of the format. Currently assigned format numbers include:

We assume large chunks of data that is saved most efficiently in a proprietary binary format that can be read and written quickly and mimics the layout of the file in the memory.

The general layout is:

  1. General header (file type, version, endianess, number of blocks, etc.)
  2. Content type specific header (optional)
  3. Data blocks
Each of the data blocks itself is of the following form:
  1. General block header (type, size)
  2. Content type specific block header (optional)
  3. Data chunk (raw byte stream, content-specific)

Author:
Tim Niemueller

Definition at line 37 of file fvfile.h.


Member Typedef Documentation

typedef std::list<FireVisionDataFileBlock *> firevision::FireVisionDataFile::BlockList

List of FireVision data file blocks.

Definition at line 64 of file fvfile.h.


Constructor & Destructor Documentation

firevision::FireVisionDataFile::FireVisionDataFile ( unsigned short int  magic_token,
unsigned short int  version 
)

Constructor.

Parameters:
magic_token magic token for the concrete file type
version file format version

Definition at line 94 of file fvfile.cpp.

References _spec_header, _spec_header_size, and clear().

firevision::FireVisionDataFile::~FireVisionDataFile (  )  [virtual]

Destructor.

Definition at line 113 of file fvfile.cpp.

References _spec_header, and clear().


Member Function Documentation

void firevision::FireVisionDataFile::add_block ( FireVisionDataFileBlock block  )  [virtual]

Add a block.

Parameters:
block block to add

Definition at line 241 of file fvfile.cpp.

Referenced by firevision::ColormapFile::add_colormap(), firevision::HistogramFile::add_histogram_block(), and firevision::RectificationInfoFile::add_rectinfo_block().

FireVisionDataFile::BlockList & firevision::FireVisionDataFile::blocks (  ) 

Get blocks.

Returns:
block list

Definition at line 251 of file fvfile.cpp.

Referenced by firevision::ColormapFile::add_colormap(), firevision::ColormapFile::colormap_blocks(), firevision::ColormapFile::get_colormap(), firevision::HistogramFile::histogram_blocks(), firevision::Histogram::load(), and firevision::RectificationInfoFile::rectinfo_blocks().

void firevision::FireVisionDataFile::clear (  )  [virtual]

Clear internal storage.

All internal data is deleted.

Reimplemented in firevision::ColormapFile.

Definition at line 129 of file fvfile.cpp.

References firevision::_fvff_header_t::endianess, firevision::_fvff_header_t::magic_token, firevision::_fvff_header_t::num_blocks, and firevision::_fvff_header_t::version.

Referenced by firevision::ColormapFile::clear(), FireVisionDataFile(), read(), and ~FireVisionDataFile().

const char * firevision::FireVisionDataFile::get_comment (  )  const

Get comment.

Returns:
comment of the file

Definition at line 197 of file fvfile.cpp.

bool firevision::FireVisionDataFile::has_magic_token ( const char *  filename,
unsigned short int  magic_token 
) [static]

Check if file has a certain magic token.

Parameters:
filename name of file to read the magic token from
magic_token magic token to look for
Returns:
true if magic token was found, false otherwise

Definition at line 442 of file fvfile.cpp.

References read_magic_token().

Referenced by firevision::ColormapFile::is_colormap_file().

bool firevision::FireVisionDataFile::is_big_endian (  ) 

Check if data is encoded as big endian.

Returns:
true if data is encoded as big endian, false otherwise

Definition at line 177 of file fvfile.cpp.

References firevision::_fvff_header_t::endianess.

bool firevision::FireVisionDataFile::is_little_endian (  ) 

Check if data is encoded as little endian.

Returns:
true if data is encoded as little endian, false otherwise

Definition at line 187 of file fvfile.cpp.

References firevision::_fvff_header_t::endianess.

unsigned int firevision::FireVisionDataFile::magic_token (  ) 

Get the magic token of the file.

Returns:
Magic token

Definition at line 157 of file fvfile.cpp.

References firevision::_fvff_header_t::magic_token.

Referenced by read_magic_token().

size_t firevision::FireVisionDataFile::num_blocks (  ) 

Get the number of available info blocks.

Returns:
number of available info blocks

Definition at line 231 of file fvfile.cpp.

Referenced by firevision::Histogram::load(), and firevision::TriclopsStereoProcessor::verify_rectification_lut().

void firevision::FireVisionDataFile::read ( const char *  file_name  )  [virtual]

Read file.

Parameters:
file_name file to read from

Reimplemented in firevision::RectificationInfoFile.

Definition at line 307 of file fvfile.cpp.

References _spec_header, clear(), firevision::_fvff_header_t::comment, firevision::FireVisionDataFileBlock::data_ptr(), firevision::_fvff_header_t::endianess, firevision::_fvff_header_t::magic_token, firevision::_fvff_header_t::num_blocks, firevision::_fvff_header_t::spec_head_size, and firevision::_fvff_header_t::version.

Referenced by firevision::ColorModelLookupTable::ColorModelLookupTable(), firevision::ColorModelLookupTable::load(), firevision::Histogram::load(), ColorTrainWidget::load_colormap(), firevision::BayesColormapGenerator::load_histograms(), firevision::YuvColormap::operator+=(), firevision::RectificationInfoFile::read(), and FireVisionNetworkTool::set_colormap().

unsigned short int firevision::FireVisionDataFile::read_magic_token ( const char *  filename  )  [static]

Get magic token from file.

Parameters:
filename name of file to read the magic token from
Returns:
magic token

Definition at line 418 of file fvfile.cpp.

References magic_token().

Referenced by has_magic_token().

void firevision::FireVisionDataFile::set_comment ( const char *  comment  ) 

Set comment.

Parameters:
comment new comment to set

Definition at line 207 of file fvfile.cpp.

References firevision::_fvff_header_t::comment.

void firevision::FireVisionDataFile::set_owns_blocks ( bool  owns_blocks  ) 

Lets the file take over the ownership and give up the ownership of the blocks, respectively.

By default, the file is the owner of the blocks. If a file owns the blocks they will be deleted in the files destructor.

Parameters:
owns_blocks if true file owns the blocks

Definition at line 221 of file fvfile.cpp.

Referenced by firevision::BayesColormapGenerator::load_histograms(), firevision::Histogram::save(), and firevision::BayesColormapGenerator::save_histograms().

unsigned int firevision::FireVisionDataFile::version (  ) 

Get the version of the file.

Returns:
version of the file (or the current supported version if no file was loaded)

Definition at line 167 of file fvfile.cpp.

References firevision::_fvff_header_t::version.

void firevision::FireVisionDataFile::write ( const char *  file_name  )  [virtual]

Write file.

Parameters:
file_name file to write to

Definition at line 261 of file fvfile.cpp.

References _spec_header, _spec_header_size, firevision::_fvff_header_t::created_sec, firevision::_fvff_header_t::created_usec, firevision::_fvff_header_t::num_blocks, and firevision::_fvff_header_t::spec_head_size.

Referenced by FireVisionNetworkTool::fuse_inbound_received(), firevision::Histogram::save(), firevision::BayesHistosToLut::save(), firevision::BayesColormapGenerator::save_histograms(), and firevision::BayesHistosToLut::saveLut().


Member Data Documentation

void * firevision::FireVisionDataFile::_spec_header [protected]

Content specific header.

Create this buffer and set the size in _spec_header_size to get it written to the file.

Definition at line 68 of file fvfile.h.

Referenced by firevision::ColormapFile::add_colormap(), firevision::ColormapFile::ColormapFile(), FireVisionDataFile(), firevision::RectificationInfoFile::read(), read(), firevision::RectificationInfoFile::RectificationInfoFile(), write(), and ~FireVisionDataFile().

size_t firevision::FireVisionDataFile::_spec_header_size [protected]

Size in bytes of _spec_header.

Definition at line 69 of file fvfile.h.

Referenced by firevision::ColormapFile::add_colormap(), firevision::ColormapFile::ColormapFile(), FireVisionDataFile(), firevision::RectificationInfoFile::RectificationInfoFile(), and write().


The documentation for this class was generated from the following files:
Generated on Tue Feb 22 13:33:00 2011 for Fawkes API by  doxygen 1.4.7