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 
35 class FireVisionDataFile
36 {
37 public:
38  FireVisionDataFile(unsigned short int magic_token, unsigned short int version);
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;
67  size_t _spec_header_size;
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::FireVisionDataFile::set_comment
void set_comment(const char *comment)
Set comment.
Definition: fvfile.cpp:193
firevision::FireVisionDataFile::_spec_header
void * _spec_header
Definition: fvfile.h:75
firevision::FireVisionDataFile::~FireVisionDataFile
virtual ~FireVisionDataFile()
Destructor.
Definition: fvfile.cpp:106
firevision::FireVisionDataFile::_spec_header_size
size_t _spec_header_size
Definition: fvfile.h:76
firevision::FireVisionDataFile::read
virtual void read(const char *file_name)
Read file.
Definition: fvfile.cpp:289
firevision::FireVisionDataFile::BlockList
std::list< FireVisionDataFileBlock * > BlockList
List of FireVision data file blocks.
Definition: fvfile.h:71
firevision::FireVisionDataFile::get_comment
const char * get_comment() const
Get comment.
Definition: fvfile.cpp:184
firevision::FireVisionDataFile::num_blocks
size_t num_blocks()
Get the number of available info blocks.
Definition: fvfile.cpp:215
firevision::FireVisionDataFile::add_block
virtual void add_block(FireVisionDataFileBlock *block)
Add a block.
Definition: fvfile.cpp:224
firevision::FireVisionDataFile::is_little_endian
bool is_little_endian()
Check if data is encoded as little endian.
Definition: fvfile.cpp:175
firevision::FireVisionDataFile::FireVisionDataFile
FireVisionDataFile(unsigned short int magic_token, unsigned short int version)
Constructor.
Definition: fvfile.cpp:89
firevision::FireVisionDataFile::has_magic_token
static bool has_magic_token(const char *filename, unsigned short int magic_token)
Check if file has a certain magic token.
Definition: fvfile.cpp:427
firevision::FireVisionDataFile::write
virtual void write(const char *file_name)
Write file.
Definition: fvfile.cpp:242
firevision::FireVisionDataFile::version
unsigned int version()
Get the version of the file.
Definition: fvfile.cpp:157
firevision::FireVisionDataFile::magic_token
unsigned int magic_token()
Get the magic token of the file.
Definition: fvfile.cpp:148
firevision::FireVisionDataFile::set_owns_blocks
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:206
firevision::FireVisionDataFileBlock
Definition: fvfile_block.h:37
firevision::FireVisionDataFile::clear
virtual void clear()
Clear internal storage.
Definition: fvfile.cpp:121
firevision::FireVisionDataFile::read_magic_token
static unsigned short int read_magic_token(const char *filename)
Get magic token from file.
Definition: fvfile.cpp:402
firevision::_fvff_header_t
Header for a FireVision file format file.
Definition: fvff.h:53
firevision::FireVisionDataFile::blocks
BlockList & blocks()
Get blocks.
Definition: fvfile.cpp:233
firevision::FireVisionDataFile::is_big_endian
bool is_big_endian()
Check if data is encoded as big endian.
Definition: fvfile.cpp:166