ADTF  3.18.2
indexedfile.h
Go to the documentation of this file.
1 
7 #ifndef _INDEXEDFILE_CLASS_HEADER_
8 #define _INDEXEDFILE_CLASS_HEADER_
9 
10 namespace A_UTILS_NS
11 {
12 
13 //*************************************************************************************************
14 /*
15 
16  FILE LAYOUT:
17 
18  +------------------------------------------------------------------------------------+
19  |HDR| DATA | EXTENSIONS | EXTENSION-HEADER TABLE |
20  +------------------------------------------------------------------------------------+
21 
22 */
23 
35 //*************************************************************************************************
36 class cIndexedFile;
37 
39 #define IDX_EXT_INDEX "index"
41 #define IDX_EXT_INDEX_0 IDX_EXT_INDEX "0"
43 #define IDX_EXT_INDEX_ADDITONAL "index_add"
45 #define IDX_EXT_INDEX_ADDITONAL_0 IDX_EXT_INDEX_ADDITONAL "0"
46 
47 //*************************************************************************************************
73 class DOEXPORT cIndexedFile : public IIndexedFile
74 {
76 
77  protected:
79  static const tUInt32 m_nFileId;
82  static const tUInt32 m_nVersionId;
90  static const tUInt32 m_nVersionADTF3;
92  static const tUInt8 m_ui8ByteOrder;
103 
108 
115 
118 
122  typedef struct
123  {
127 
129  typedef std::list<tFileExtensionStruct*> tFileExtensionList;
130 
133 
138 
141 
142  public:
150  virtual ~cIndexedFile();
151 
156  virtual tResult Close();
157 
164  tResult SetDescription(const tChar* strDescription);
170  const tChar* GetDescription() const;
171 
179 
188  tResult SetDateTime(const tDateTime* psDateTime);
189 
197 
204 
211 
220  tResult FindExtension(const tChar* strIdentifier, tFileExtension** ppsExtensionInfo, tVoid** ppData);
221 
230  tResult GetExtension(tInt nIndex, tFileExtension** ppsExtensionInfo, tVoid** ppData);
231 
244  tResult AppendExtension(const tChar* strIdentifier,
245  const tVoid* pData,
246  tInt nDataSize,
247  tUInt32 ui32TypeId=0,
248  tUInt32 ui32VersionId=0,
249  tUInt16 ui16StreamId=0,
250  tUInt32 ui32UserId=0);
251 
259  tResult AppendExtension(const tVoid* pData, const tFileExtension* psExtensionInfo);
260 
266  tResult FreeExtension(const tChar* strIdentifier);
267 
273 
280  tResult GetHeader(tFileHeader** ppsFileHeader);
281 
282  protected:
286  virtual tResult Initialize();
287 
294 
299 
304 
309 
317 
324 
331  tResult GenerateNewGUID(cString& strGeneratedGUID);
332 
333  protected:
334 
341 
346 
351 
361  tInt GetSectorSize(const tChar* strFilename) const;
362 
369  tFileSize GetSizeOnDisk(tFileSize nSize, tBool bUseSegmentSize);
370 
377  tVoid* InternalMalloc(tInt64 nSize, tBool bUseSegmentSize);
378 
385 };
386 
387 } // namespace
388 
389 //*************************************************************************************************
390 #endif // _INDEXEDFILE_CLASS_HEADER_
uint8_t tUInt8
type definition for unsigned integer values (8bit) (platform and compiler independent type).
char tChar
The tChar defines the type for platform character set (platform and compiler dependent type).
tInt64 tFileSize
type definition for a file or stream size value (platform and compiler independent type).
int64_t tInt64
type definition for signed integer values (64bit) (platform and compiler independent type).
tInt64 tFilePos
type definition for a file or stream position value (platform and compiler independent type).
void tVoid
The tVoid is always the definition for the void (non-type).
uint16_t tUInt16
type definition for unsigned integer values (16bit) (platform and compiler independent type).
int tInt
type definition for signed integer value (platform and compiler dependent type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
uint32_t tUInt32
type definition for unsigned integer values (32bit) (platform and compiler independent type).
Indexed file interface.
File class.
Definition: file.h:26
Base class for all indexed file classes.
Definition: indexedfile.h:74
tUInt8 * m_pBuffer
internal Buffer
Definition: indexedfile.h:110
tVoid InternalFree(tVoid *pMemory)
Release memory.
static const tUInt32 m_nVersionIdWithHistoryEndOffset
supported Version of Indexed File within >= ADTF 2.13.1 if a file buffered history is used while writ...
Definition: indexedfile.h:88
static const tUInt32 m_nVersionADTF3
supported Version of Indexed File within >= ADTF 3.0.0 (currently 0x00000301)
Definition: indexedfile.h:90
const tChar * GetDescription() const
Returns the description of the file.
tBool m_bWriteMode
For internal use only (will be moved to a private implementation).
Definition: indexedfile.h:140
tBool m_bSystemCacheDisabled
whether system cache used or not depend on flags given within Create method of cIndexedFileReader or ...
Definition: indexedfile.h:102
static tInt64 m_nDefaultCacheSize
Default cache size in bytes.
Definition: indexedfile.h:96
static const tUInt8 m_ui8ByteOrder
current value of platform ByteOrder (
Definition: indexedfile.h:92
static const tUInt32 m_nVersionIdWithHistory
supported Version of Indexed File within >= ADTF 2.13 if a file buffered history is used while writin...
Definition: indexedfile.h:85
tResult GetDateTime(tDateTime *psDateTime)
Get the timestamp of the file.
tResult SetGUID()
Sets the GUID of the file.
tFileSize GetSizeOnDisk(tFileSize nSize, tBool bUseSegmentSize)
Calculates the size a data block requires on disk.
tResult FreeCache()
Releases the cache.
tResult AppendExtension(const tVoid *pData, const tFileExtension *psExtensionInfo)
Adds a new extension to the file.
tResult FreeBuffer()
Releases the internal buffer.
tVoid * InternalMalloc(tInt64 nSize, tBool bUseSegmentSize)
Allocates memory.
tInt GetSectorSize(const tChar *strFilename) const
Get the sector size of the filesystem that a specified file resides on.
tFilePos m_nFilePos
current filepos
Definition: indexedfile.h:107
virtual tResult Initialize()
Initializes internal data.
tResult FindExtension(const tChar *strIdentifier, tFileExtension **ppsExtensionInfo, tVoid **ppData)
Finds an extension with a specific identifier.
tResult FreeExtensions()
Frees all extensions.
tInt64 m_nBufferSize
internal Buffer size
Definition: indexedfile.h:112
cFile m_oFile
the open file
Definition: indexedfile.h:105
cIndexedFile()
Default constructor.
tResult AllocBuffer(tInt64 nSize)
Allocates an internal buffer.
static tInt64 m_nDefaultBlockSize
Default block size in bytes.
Definition: indexedfile.h:94
static const tUInt32 m_nVersionId
supported Version of Indexed File within ADTF 2.0 until 2.12 and >= 2.13 if NO History is used while ...
Definition: indexedfile.h:82
tResult AllocCache(tInt64 nSize)
Initialzes an internal cache.
tUInt8 GetByteOrder()
Returns the byteorder of the file.
static const tUInt32 m_nFileId
For internal use only (will be moved to a private implementation).
Definition: indexedfile.h:79
tResult GetExtension(tInt nIndex, tFileExtension **ppsExtensionInfo, tVoid **ppData)
Get an extension with a specific index.
tResult FreeHeader()
Releases the header data.
tResult SetDescription(const tChar *strDescription)
Sets the description of the file.
tResult GetHeader(tFileHeader **ppsFileHeader)
Returns the file header.
virtual tResult Close()
Closes the file.
tResult AppendExtension(const tChar *strIdentifier, const tVoid *pData, tInt nDataSize, tUInt32 ui32TypeId=0, tUInt32 ui32VersionId=0, tUInt16 ui16StreamId=0, tUInt32 ui32UserId=0)
Adds a new extension to the file.
virtual ~cIndexedFile()
Destructor.
tBool m_bWriteGUID
protection for writing GUID
Definition: indexedfile.h:117
tResult FreeExtension(const tChar *strIdentifier)
Frees specific extensions.
tVoid * m_pCache
cache data area
Definition: indexedfile.h:135
tFileHeader * m_psFileHeader
current file header
Definition: indexedfile.h:114
tResult GetGUID(cString &strGUID)
Get the GUID of the file.
tVoid * GetCacheAddr()
Returns the cache pointer.
std::list< tFileExtensionStruct * > tFileExtensionList
own type definition for a better work with file extension lists
Definition: indexedfile.h:129
tResult GenerateNewGUID(cString &strGeneratedGUID)
Generates a new GUID (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)
tResult AllocExtensionPage(tFileSize nSize, tVoid **ppData)
Allocate memory for an extension.
tResult SetDateTime(const tDateTime *psDateTime)
Set the timestamp of the file.
tFileExtensionList m_lstExtensions
list with all extensions
Definition: indexedfile.h:132
tResult AllocHeader()
Allocates the header structure/data.
tInt64 m_nCacheSize
size of cache
Definition: indexedfile.h:137
tInt GetExtensionCount()
Get the amount of extensions in the file.
tInt64 m_nSectorSize
current sector size used for disk device depend on drive given by filename within Create method of cI...
Definition: indexedfile.h:99
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
Definition: d_ptr.h:270
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
Definition: d_ptr.h:11
combines a file extension information with a concrete extension page
Definition: indexedfile.h:123
tFileExtension sFileExtension
file extension intormation
Definition: indexedfile.h:124
tVoid * pExtensionPage
pointer to extension page
Definition: indexedfile.h:125
Struct to handle date and time together.
Definition: structs.h:57
Header for a file extensions.
The File header for dat-files.