fvfile.h

00001
00002 /***************************************************************************
00003  *  fvfile.h - FireVision file
00004  *
00005  *  Created: Fri Mar 28 11:29:55 2008
00006  *  Copyright  2008  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023
00024 #ifndef __FIREVISION_FVUTILS_FILEFORMAT_FVFILE_H_
00025 #define __FIREVISION_FVUTILS_FILEFORMAT_FVFILE_H_
00026 
00027 #include <fvutils/fileformat/fvff.h>
00028 #include <fvutils/fileformat/fvfile_block.h>
00029 #include <cstdlib>
00030 #include <list>
00031
00032 class FireVisionDataFile
00033 {
00034  public:
00035   FireVisionDataFile(unsigned short int magic_token, unsigned short int version);
00036   virtual ~FireVisionDataFile();
00037
00038   unsigned int  magic_token();
00039   unsigned int  version();
00040   bool          is_big_endian();
00041   bool          is_little_endian();
00042   size_t        num_blocks();
00043
00044   const char *  get_comment() const;
00045   void          set_comment(const char *comment);
00046
00047   void          set_owns_blocks(bool owns_blocks);
00048
00049   virtual void add_block(FireVisionDataFileBlock *block);
00050   virtual void clear();
00051
00052   virtual void write(const char *file_name);
00053   virtual void read(const char *file_name);
00054
00055   static unsigned short int read_magic_token(const char *filename);
00056   static bool has_magic_token(const char *filename, unsigned short int magic_token);
00057 
00058   /** List of FireVision data file blocks. */
00059   typedef std::list<FireVisionDataFileBlock *> BlockList;
00060   BlockList &  blocks();
00061
00062  protected:
00063   void         *_spec_header;
00064   size_t        _spec_header_size;
00065
00066  private:
00067   fvff_header_t       *__header;
00068   BlockList            __blocks;
00069   BlockList::iterator  __bi;
00070
00071   unsigned int  __magic_token;
00072   unsigned int  __version;
00073
00074   char *        __comment;
00075
00076   bool          __owns_blocks;
00077 };
00078
00079
00080 #endif