adtf_file_library  0.13.2
indexedfile_v100.h
Go to the documentation of this file.
1 
17 #ifndef INDEXEDFILE_V100_CLASS_HEADER
18 #define INDEXEDFILE_V100_CLASS_HEADER
19 
20 #include <ifhd/indexedfile_types.h>
21 
22 namespace ifhd
23 {
27 namespace v100
28 {
29 
31 const uint32_t version_id = 0x00000100;
32 
33 //*************************************************************************************************
34 /*
35 
36  FILE LAYOUT:
37 
38  +---------------------------------------------------------------+
39  |HDR| DATA |HDR-EXT| IDX |
40  +---------------------------------------------------------------+
41 
42 */
43 
44 //*************************************************************************************************
49 {
50  public:
51  enum
52  {
53  tf_chunk_index = 1,
58  tf_chunk_time = 2
59  };
60 
61 #ifdef WIN32
62 #pragma pack(push)
63 #pragma pack(1)
64 #else
65 #pragma pack(push)
66 #pragma pack(1)
67 #endif
71  typedef struct TagDateTime
72  {
74  uint16_t year;
76  uint16_t month;
78  uint16_t day;
80  uint16_t hour;
82  uint16_t minute;
84  uint16_t second;
86  uint32_t microseconds;
88 
92  typedef struct TagFileHeader
93  {
94  uint32_t file_id;
95  uint32_t version_id;
100  uint64_t index_count;
102  uint64_t duration;
104  uint64_t reserved[7];
105  int8_t description[1912];
107 
111  typedef struct TagChunkHeader
112  {
113  uint64_t chunk_offset;
114  uint64_t time_stamp;
115  uint32_t size;
116  uint32_t flags;
118 
119 #ifdef WIN32
120 #pragma pack(pop)
121 #else
122 #pragma pack(pop)
123 #endif
124 
125  protected:
129  typedef struct TagIndexBlockItem
130  {
132  int data_size;
136 
137  bool _attached;
138 
139  static int _default_block_size;
140  static int _default_cache_size;
142 
144 
146 
147  int64_t _index;
148  int64_t _file_pos;
149 
150  uint8_t* _buffer;
152 
155 
157 
159 
160  void* _cache;
162 
163  bool _write_mode;
164 
165  public:
174 
178  void close();
179 
184  void setDescription(const std::string& description);
185 
190  std::string getDescription() const;
191 
196  void setDateTime(const DateTime& date_time);
197 
202 
207  void allocHeaderExtension(int size);
217  void getHeaderExtension(void** data, int* data_size);
223  void setHeaderExtension(void* data, int data_size);
224 
225  protected:
229  void initialize();
230 
235  void allocBuffer(int size);
239  void freeBuffer();
240 
245  void allocIndexTable(int size);
255  void appendIndex(uint64_t pos, timestamp_t time_stamp);
260  void allocIndexBlock(int count=-1);
261 
265  void allocHeader();
269  void freeHeader();
270 
271  protected:
276  void allocCache(int size);
280  void freeCache();
285  void* getCacheAddr();
286 
292  int getSectorSize(const std::string &filename) const;
293 
299  void* internalMalloc(int size);
304  void internalFree(void* memory);
305 };
306 
307 } //namespace v100
308 } // namespace ifhd
309 
310 //*************************************************************************************************
311 #endif // _INDEXEDFILE_V100_CLASS_HEADER_
Definition: indexedfile_v100.h:49
IndexBlockItem * _index_blocks
Pointer to index blocks.
Definition: indexedfile_v100.h:153
void setHeaderExtension(void *data, int data_size)
std::string getDescription() const
@ tf_chunk_time
time format used for lookup time
Definition: indexedfile_v100.h:58
FileHeader * _file_header
File header.
Definition: indexedfile_v100.h:156
void * _header_extension
Header extension.
Definition: indexedfile_v100.h:158
void setDescription(const std::string &description)
struct ifhd::v100::IndexedFileV100::TagIndexBlockItem IndexBlockItem
struct ifhd::v100::IndexedFileV100::TagChunkHeader ChunkHeader
utils5ext::File * _file
File pointer.
Definition: indexedfile_v100.h:145
static int _index_table_cluster_size
Size of index table clusters.
Definition: indexedfile_v100.h:141
int64_t _file_pos
Current file position.
Definition: indexedfile_v100.h:148
void getHeaderExtension(void **data, int *data_size)
IndexBlockItem * _active_index_block
Pointer to current index block.
Definition: indexedfile_v100.h:154
void * _cache
Pointer to cache.
Definition: indexedfile_v100.h:160
int _sector_size
Sector size.
Definition: indexedfile_v100.h:143
int _cache_size
Cache size.
Definition: indexedfile_v100.h:161
void internalFree(void *memory)
static int _default_cache_size
Default cache size.
Definition: indexedfile_v100.h:140
int64_t _index
Current index.
Definition: indexedfile_v100.h:147
void allocIndexTable(int size)
bool _attached
File attached?
Definition: indexedfile_v100.h:137
int getSectorSize(const std::string &filename) const
void appendIndex(uint64_t pos, timestamp_t time_stamp)
void allocIndexBlock(int count=-1)
void allocHeaderExtension(int size)
void setDateTime(const DateTime &date_time)
static int _default_block_size
Default block size.
Definition: indexedfile_v100.h:139
struct ifhd::v100::IndexedFileV100::TagFileHeader FileHeader
struct ifhd::v100::IndexedFileV100::TagDateTime DateTime
uint8_t * _buffer
Internal buffer.
Definition: indexedfile_v100.h:150
void * internalMalloc(int size)
bool _write_mode
Write mode enabled?
Definition: indexedfile_v100.h:163
int _buffer_size
Buffer size.
Definition: indexedfile_v100.h:151
Definition: file.h:121
const uint32_t version_id
IFHD Version ID V1.0.
Definition: indexedfile_v100.h:31
namespace for IFHD File library
Definition: indexedfile_types.h:30
utils5ext::FilePos FilePos
file pos type
Definition: indexedfile_types.h:54
FilePos FileSize
Type for the file size.
Definition: file.h:41
Definition: indexedfile_v100.h:112
uint64_t time_stamp
Timestamp of chunk.
Definition: indexedfile_v100.h:114
uint64_t chunk_offset
Offset of chunk.
Definition: indexedfile_v100.h:113
uint32_t flags
Flags for chunk.
Definition: indexedfile_v100.h:116
uint32_t size
Size of chunk.
Definition: indexedfile_v100.h:115
Definition: indexedfile_v100.h:72
uint32_t microseconds
The Microseconds after the second - [0,999999].
Definition: indexedfile_v100.h:86
uint16_t day
The Day of the month - [1,31].
Definition: indexedfile_v100.h:78
uint16_t minute
The Minutes after the hour - [0,59].
Definition: indexedfile_v100.h:82
uint16_t month
The Month - [1,12].
Definition: indexedfile_v100.h:76
uint16_t second
The Seconds after the minute - [0,59].
Definition: indexedfile_v100.h:84
uint16_t hour
The Hours past midnight - [0,23].
Definition: indexedfile_v100.h:80
uint16_t year
The Year - [1900,)
Definition: indexedfile_v100.h:74
Definition: indexedfile_v100.h:93
FilePos index_offset
Offset of indices.
Definition: indexedfile_v100.h:101
DateTime date_time
Date and time.
Definition: indexedfile_v100.h:103
uint64_t reserved[7]
Reserved.
Definition: indexedfile_v100.h:104
uint64_t duration
Duration.
Definition: indexedfile_v100.h:102
utils5ext::FileSize data_size
Size of data.
Definition: indexedfile_v100.h:99
uint64_t index_count
Number of indices.
Definition: indexedfile_v100.h:100
int8_t description[1912]
File description.
Definition: indexedfile_v100.h:105
FilePos extension_offset
Offset of extensions.
Definition: indexedfile_v100.h:96
utils5ext::FileSize extension_size
Size of extensions.
Definition: indexedfile_v100.h:97
uint32_t version_id
Version identifier.
Definition: indexedfile_v100.h:95
FilePos data_offset
Offset of data.
Definition: indexedfile_v100.h:98
uint32_t file_id
File identifier.
Definition: indexedfile_v100.h:94
Definition: indexedfile_v100.h:130
int data_size
Size of data.
Definition: indexedfile_v100.h:132
int item_count
Number of items.
Definition: indexedfile_v100.h:133
struct TagIndexBlockItem * next
Pointer to next IndexBlockItem.
Definition: indexedfile_v100.h:134
ChunkHeader * data
Data.
Definition: indexedfile_v100.h:131

Copyright © CARIAD SE.
Generated on Mon Jun 10 2024 by doxygen 1.9.1
GIT Commit Hash: eb3af397a6b49ad6fcad9a60d8277d909b458b48