Fawkes API  Fawkes Development Version
fvfile.h
1 
2 /***************************************************************************
3  * fvfile.h - FireVision file
4  *
5  * Created: Fri Mar 28 11:29:55 2008
6  * Copyright 2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __FIREVISION_FVUTILS_FILEFORMAT_FVFILE_H_
25 #define __FIREVISION_FVUTILS_FILEFORMAT_FVFILE_H_
26 
27 #include <fvutils/fileformat/fvff.h>
28 #include <fvutils/fileformat/fvfile_block.h>
29 #include <cstdlib>
30 #include <list>
31 
32 namespace firevision {
33 #if 0 /* just to make Emacs auto-indent happy */
34 }
35 #endif
36 
38 {
39  public:
40  FireVisionDataFile(unsigned short int magic_token, unsigned short int version);
41  virtual ~FireVisionDataFile();
42 
43  unsigned int magic_token();
44  unsigned int version();
45  bool is_big_endian();
46  bool is_little_endian();
47  size_t num_blocks();
48 
49  const char * get_comment() const;
50  void set_comment(const char *comment);
51 
52  void set_owns_blocks(bool owns_blocks);
53 
54  virtual void add_block(FireVisionDataFileBlock *block);
55  virtual void clear();
56 
57  virtual void write(const char *file_name);
58  virtual void read(const char *file_name);
59 
60  static unsigned short int read_magic_token(const char *filename);
61  static bool has_magic_token(const char *filename, unsigned short int magic_token);
62 
63  /** List of FireVision data file blocks. */
64  typedef std::list<FireVisionDataFileBlock *> BlockList;
65  BlockList & blocks();
66 
67  protected:
68  void *_spec_header;
70 
71  private:
72  fvff_header_t *__header;
73  BlockList __blocks;
74  BlockList::iterator __bi;
75 
76  unsigned int __magic_token;
77  unsigned int __version;
78 
79  char * __comment;
80 
81  bool __owns_blocks;
82 };
83 
84 } // end namespace firevision
85 
86 #endif
size_t num_blocks()
Get the number of available info blocks.
Definition: fvfile.cpp:232
size_t _spec_header_size
Size in bytes of _spec_header.
Definition: fvfile.h:69
virtual void add_block(FireVisionDataFileBlock *block)
Add a block.
Definition: fvfile.cpp:242
virtual ~FireVisionDataFile()
Destructor.
Definition: fvfile.cpp:114
FireVision File Format data block.
Definition: fvfile_block.h:35
bool is_big_endian()
Check if data is encoded as big endian.
Definition: fvfile.cpp:178
std::list< FireVisionDataFileBlock * > BlockList
List of FireVision data file blocks.
Definition: fvfile.h:64
bool is_little_endian()
Check if data is encoded as little endian.
Definition: fvfile.cpp:188
static bool has_magic_token(const char *filename, unsigned short int magic_token)
Check if file has a certain magic token.
Definition: fvfile.cpp:446
virtual void write(const char *file_name)
Write file.
Definition: fvfile.cpp:262
virtual void read(const char *file_name)
Read file.
Definition: fvfile.cpp:308
const char * get_comment() const
Get comment.
Definition: fvfile.cpp:198
static unsigned short int read_magic_token(const char *filename)
Get magic token from file.
Definition: fvfile.cpp:419
unsigned int version()
Get the version of the file.
Definition: fvfile.cpp:168
FireVisionDataFile(unsigned short int magic_token, unsigned short int version)
Constructor.
Definition: fvfile.cpp:95
void * _spec_header
Content specific header.
Definition: fvfile.h:68
void set_owns_blocks(bool owns_blocks)
Lets the file take over the ownership and give up the ownership of the blocks, respectively.
Definition: fvfile.cpp:222
FireVision File Format for data files.
Definition: fvfile.h:37
void set_comment(const char *comment)
Set comment.
Definition: fvfile.cpp:208
Header for a FireVision file format file.
Definition: fvff.h:57
unsigned int magic_token()
Get the magic token of the file.
Definition: fvfile.cpp:158
virtual void clear()
Clear internal storage.
Definition: fvfile.cpp:130
BlockList & blocks()
Get blocks.
Definition: fvfile.cpp:252