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 
30 #include <cstdlib>
31 #include <list>
32 
33 namespace firevision {
34 
36 {
37 public:
38  FireVisionDataFile(unsigned short int magic_token, unsigned short int version);
39  virtual ~FireVisionDataFile();
40 
41  unsigned int magic_token();
42  unsigned int version();
43  bool is_big_endian();
44  bool is_little_endian();
45  size_t num_blocks();
46 
47  const char *get_comment() const;
48  void set_comment(const char *comment);
49 
50  void set_owns_blocks(bool owns_blocks);
51 
52  virtual void add_block(FireVisionDataFileBlock *block);
53  virtual void clear();
54 
55  virtual void write(const char *file_name);
56  virtual void read(const char *file_name);
57 
58  static unsigned short int read_magic_token(const char *filename);
59  static bool has_magic_token(const char *filename, unsigned short int magic_token);
60 
61  /** List of FireVision data file blocks. */
62  typedef std::list<FireVisionDataFileBlock *> BlockList;
63  BlockList & blocks();
64 
65 protected:
66  void * _spec_header;
68 
69 private:
70  fvff_header_t * header_;
71  BlockList blocks_;
72  BlockList::iterator bi_;
73 
74  unsigned int magic_token_;
75  unsigned int version_;
76 
77  char *comment_;
78 
79  bool owns_blocks_;
80 };
81 
82 } // end namespace firevision
83 
84 #endif
FireVision File Format data block.
Definition: fvfile_block.h:34
FireVision File Format for data files.
Definition: fvfile.h:36
unsigned int version()
Get the version of the file.
Definition: fvfile.cpp:158
virtual void read(const char *file_name)
Read file.
Definition: fvfile.cpp:290
void * _spec_header
Content specific header.
Definition: fvfile.h:66
unsigned int magic_token()
Get the magic token of the file.
Definition: fvfile.cpp:149
FireVisionDataFile(unsigned short int magic_token, unsigned short int version)
Constructor.
Definition: fvfile.cpp:90
virtual void clear()
Clear internal storage.
Definition: fvfile.cpp:122
size_t num_blocks()
Get the number of available info blocks.
Definition: fvfile.cpp:216
bool is_little_endian()
Check if data is encoded as little endian.
Definition: fvfile.cpp:176
size_t _spec_header_size
Size in bytes of _spec_header.
Definition: fvfile.h:67
static unsigned short int read_magic_token(const char *filename)
Get magic token from file.
Definition: fvfile.cpp:403
void set_comment(const char *comment)
Set comment.
Definition: fvfile.cpp:194
virtual void add_block(FireVisionDataFileBlock *block)
Add a block.
Definition: fvfile.cpp:225
std::list< FireVisionDataFileBlock * > BlockList
List of FireVision data file blocks.
Definition: fvfile.h:62
const char * get_comment() const
Get comment.
Definition: fvfile.cpp:185
static bool has_magic_token(const char *filename, unsigned short int magic_token)
Check if file has a certain magic token.
Definition: fvfile.cpp:428
bool is_big_endian()
Check if data is encoded as big endian.
Definition: fvfile.cpp:167
virtual void write(const char *file_name)
Write file.
Definition: fvfile.cpp:243
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:207
BlockList & blocks()
Get blocks.
Definition: fvfile.cpp:234
virtual ~FireVisionDataFile()
Destructor.
Definition: fvfile.cpp:107
Header for a FireVision file format file.
Definition: fvff.h:55