ADTF
|
Class for writing indexed files. More...
Classes | |
class | IChunkDroppedCallback |
Callback interface that informs about dropped chunks in history mode. More... | |
Public Member Functions | |
cFilename | GetTempSaveFileName () |
Get the Temp Save File Name (Filename during the Save Mode) More... | |
tVoid | SetPrefixTempFileExtension (tBool useMode) |
Set the mode, if a prefix is set by a temp Save File Name or not. More... | |
tBool | GetPrefixTempFileExtensionMode () |
Get the mode, if a prefix is set by a temp Save File Name or not. More... | |
cString | GetPrefix () |
Returns the prefix. More... | |
cString | GetNewFileNameWithPrefix (cString strFilename) |
Set a Prefix to the incoming Filename and return the new name. More... | |
A_UTILS_DEPRECATED_MESSAGE ("The class 'cIndexedFileWriter' is deprecated. Please use the aquivalent from the " "adtf_file library instead.") cIndexedFileWriter() | |
Default constructor. | |
~cIndexedFileWriter () | |
Destructor. | |
tResult | Create (const tChar *strFilename, tInt nCacheSize=-1, tUInt32 ui32Flags=0, tUInt64 ui64FileTimeOffset=0, tTimeStamp tmHistory=0, tFileSize nHistorySize=0, IChunkDroppedCallback *pDropCallback=nullptr) |
Create a new indexed file. More... | |
tResult | Close () |
Finishes writing to and closes the file. More... | |
tResult | WriteChunk (tUInt16 ui16StreamId, const tVoid *pData, tUInt32 nDataSize, tTimeStamp nTimeStamp, tUInt32 nFlags) |
Writes a new chunk to the file. More... | |
tResult | WriteChunk (tUInt16 ui16StreamId, const tVoid *pData, tUInt32 nDataSize, tTimeStamp nTimeStamp, tUInt32 nFlags, tBool &bIndexEntryAppended) |
Writes a new chunk to the file. More... | |
tResult | SetAdditionalStreamInfo (tUInt16 ui16StreamId, const tVoid *pInfoData, tUInt32 ui32InfoDataSize, tBool bUseAsReference=tFalse) |
Sets additional info for a stream. More... | |
tResult | SetStreamName (tUInt16 ui16StreamId, const tChar *strStreamName) |
Set the name of a stream. More... | |
tInt | GetCacheUsage () |
Get the amount of cache space used. More... | |
tResult | QuitHistory () |
In case there is a history set up, this switches over to permanent storage. More... | |
Public Member Functions inherited from cIndexedFile | |
cIndexedFile () | |
Default constructor. | |
virtual | ~cIndexedFile () |
Destructor. | |
tResult | SetDescription (const tChar *strDescription) |
Sets the description of the file. More... | |
const tChar * | GetDescription () const |
Returns the description of the file. More... | |
tResult | GetGUID (cString &strGUID) |
Get the GUID of the file. More... | |
tResult | SetDateTime (const tDateTime *psDateTime) |
Set the timestamp of the file. More... | |
tResult | GetDateTime (tDateTime *psDateTime) |
Get the timestamp of the file. More... | |
tUInt8 | GetByteOrder () |
Returns the byteorder of the file. More... | |
tInt | GetExtensionCount () |
Get the amount of extensions in the file. More... | |
tResult | FindExtension (const tChar *strIdentifier, tFileExtension **ppsExtensionInfo, tVoid **ppData) |
Finds an extension with a specific identifier. More... | |
tResult | GetExtension (tInt nIndex, tFileExtension **ppsExtensionInfo, tVoid **ppData) |
Get an extension with a specific index. More... | |
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. More... | |
tResult | AppendExtension (const tVoid *pData, const tFileExtension *psExtensionInfo) |
Adds a new extension to the file. More... | |
tResult | FreeExtension (const tChar *strIdentifier) |
Frees specific extensions. More... | |
tResult | FreeExtensions () |
Frees all extensions. More... | |
tResult | GetHeader (tFileHeader **ppsFileHeader) |
Returns the file header. More... | |
Protected Member Functions | |
tResult | Initialize () |
Initializes the writer. More... | |
tResult | WriteFileHeader () |
Write the file header. More... | |
tResult | WriteFileHeaderExt () |
write the extension file header More... | |
tResult | WriteIndexTable () |
write index table More... | |
tResult | WriteToCache (const tVoid *pData, tInt nDataSize, const tBool bIsChunkHeader=tFalse) |
write the given data to local cache More... | |
tResult | StoreToDisk (bool bFlush) |
stores the data to disk More... | |
tVoid | UpdateCache () |
tResult | AllocCache (tInt nSize) |
allocates a given amount of memory for chaching More... | |
tInt64 | InternalWrite (const tVoid *pvBuffer, tInt nBufferSize, tBool bUseSegmentSize) |
internal writing function More... | |
Protected Member Functions inherited from cIndexedFile | |
tResult | AllocBuffer (tInt64 nSize) |
Allocates an internal buffer. More... | |
tResult | FreeBuffer () |
Releases the internal buffer. | |
tResult | AllocHeader () |
Allocates the header structure/data. | |
tResult | FreeHeader () |
Releases the header data. | |
tResult | AllocExtensionPage (tFileSize nSize, tVoid **ppData) |
Allocate memory for an extension. More... | |
tResult | SetGUID () |
Sets the GUID of the file. More... | |
tResult | GenerateNewGUID (cString &strGeneratedGUID) |
Generates a new GUID (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) More... | |
tResult | AllocCache (tInt64 nSize) |
Initialzes an internal cache. More... | |
tResult | FreeCache () |
Releases the cache. | |
tVoid * | GetCacheAddr () |
Returns the cache pointer. | |
tInt | GetSectorSize (const tChar *strFilename) const |
Get the sector size of the filesystem that a specified file resides on. More... | |
tFileSize | GetSizeOnDisk (tFileSize nSize, tBool bUseSegmentSize) |
Calculates the size a data block requires on disk. More... | |
tVoid * | InternalMalloc (tInt64 nSize, tBool bUseSegmentSize) |
Allocates memory. More... | |
tVoid | InternalFree (tVoid *pMemory) |
Release memory. More... | |
Protected Attributes | |
tBool | m_bUsePrefixTempFileExtension |
Protected Attributes inherited from cIndexedFile | |
tInt64 | m_nSectorSize |
current sector size used for disk device depend on drive given by filename within Create method of cIndexedFileReader or cIndexFileWriter | |
tBool | m_bSystemCacheDisabled |
whether system cache used or not depend on flags given within Create method of cIndexedFileReader or cIndexFileWriter | |
cFile | m_oFile |
the open file | |
tFilePos | m_nFilePos |
current filepos | |
tUInt8 * | m_pBuffer |
internal Buffer | |
tInt64 | m_nBufferSize |
internal Buffer size | |
tFileHeader * | m_psFileHeader |
current file header | |
tBool | m_bWriteGUID |
protection for writing GUID | |
tFileExtensionList | m_lstExtensions |
list with all extensions | |
tVoid * | m_pCache |
cache data area | |
tInt64 | m_nCacheSize |
size of cache | |
tBool | m_bWriteMode |
For internal use only (will be moved to a private implementation). | |
Private Member Functions | |
tResult | CreateAFileWithPrefixdAndAFileWithoutPrefix (cFilename strFilename, cFilename &strSaveFilename) |
Return the Name of the file during creation mode. More... | |
tResult | RenameTempSaveToFileName () |
Rename the TempFile Name '~$FileName.dat' back to 'FileName.dat' Filename. More... | |
Additional Inherited Members | |
Public Types inherited from IIndexedFile | |
enum | tTimeFormat { TF_ChunkIndex = 1 , TF_ChunkTime = 2 , TF_StreamIndex = 3 } |
Time format (for seek etc.) More... | |
enum | tReadFlags { RF_None = 0x0 , RF_UseExternalBuffer = 0x1 , RF_Backwards = 0x2 } |
Read options. | |
enum | tSeekFlags { SF_DEFAULT = 0x0 , SF_KEYDATA = 0x1 , SF_BEFORE = 0x02 } |
Seek flags. More... | |
enum | tChunkType { CT_DATA = 0x00 , CT_KEYDATA = 0x01 , CT_INFO = 0x02 , CT_MARKER = 0x04 , CT_TYPE = 0x08 , CT_TRIGGER = 0x10 } |
The chunk types. More... | |
enum | tOpenMode { OM_None = 0x00 , OM_DisableFileSystemCache = 0x01 , OM_SyncWrite = 0x02 , OM_QueryInfo = 0x04 , OM_ValidateChunkHeader = 0x08 , OM_FileChangeMode = 0x10 } |
File open modes. More... | |
Protected Types inherited from cIndexedFile | |
typedef std::list< tFileExtensionStruct * > | tFileExtensionList |
own type definition for a better work with file extension lists | |
Static Protected Attributes inherited from cIndexedFile | |
static const tUInt32 | m_nFileId |
For internal use only (will be moved to a private implementation). | |
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 writing file (currently 0x00000201) | |
static const tUInt32 | m_nVersionIdWithHistory |
supported Version of Indexed File within >= ADTF 2.13 if a file buffered history is used while writing file (currently 0x00000300) | |
static const tUInt32 | m_nVersionIdWithHistoryEndOffset |
supported Version of Indexed File within >= ADTF 2.13.1 if a file buffered history is used while writing file (currently 0x00000301) | |
static const tUInt32 | m_nVersionADTF3 |
supported Version of Indexed File within >= ADTF 3.0.0 (currently 0x00000301) | |
static const tUInt8 | m_ui8ByteOrder |
current value of platform ByteOrder ( More... | |
static tInt64 | m_nDefaultBlockSize |
Default block size in bytes. | |
static tInt64 | m_nDefaultCacheSize |
Default cache size in bytes. | |
Class for writing indexed files.
Definition at line 48 of file indexedfilewriter.h.
allocates a given amount of memory for chaching
nSize | size of memory to be allocated (in bytes) |
|
virtual |
tResult Create | ( | const tChar * | strFilename, |
tInt | nCacheSize = -1 , |
||
tUInt32 | ui32Flags = 0 , |
||
tUInt64 | ui64FileTimeOffset = 0 , |
||
tTimeStamp | tmHistory = 0 , |
||
tFileSize | nHistorySize = 0 , |
||
IChunkDroppedCallback * | pDropCallback = nullptr |
||
) |
Create a new indexed file.
strFilename | [in] The filename. |
nCacheSize | [in] The cache size. |
ui32Flags | [in] Creation flags, see tOpenMode |
ui64FileTimeOffset | [in] unused. |
tmHistory | [in] Timestamp of history. |
nHistorySize | [in] Size of the history. |
pDropCallback | [in] CallBack implementation if chunk was dropped |
|
private |
Return the Name of the file during creation mode.
It can be with or without prefix.
strFilename | [in] The filename. |
strSaveFilename | [out] cFilename the save filename |
tInt GetCacheUsage | ( | ) |
Get the amount of cache space used.
Set a Prefix to the incoming Filename and return the new name.
strFilename | [in] The filename. |
cString GetPrefix | ( | ) |
Returns the prefix.
tBool GetPrefixTempFileExtensionMode | ( | ) |
Get the mode, if a prefix is set by a temp Save File Name or not.
cFilename GetTempSaveFileName | ( | ) |
Get the Temp Save File Name (Filename during the Save Mode)
|
protectedvirtual |
internal writing function
[in] | pvBuffer | pointer to data to be written |
[in] | nBufferSize | size of data |
[in] | bUseSegmentSize |
tResult QuitHistory | ( | ) |
In case there is a history set up, this switches over to permanent storage.
|
private |
Rename the TempFile Name '~$FileName.dat' back to 'FileName.dat' Filename.
tResult SetAdditionalStreamInfo | ( | tUInt16 | ui16StreamId, |
const tVoid * | pInfoData, | ||
tUInt32 | ui32InfoDataSize, | ||
tBool | bUseAsReference = tFalse |
||
) |
Sets additional info for a stream.
ui16StreamId | [in] The stream id. |
pInfoData | [in] The info data. |
ui32InfoDataSize | [in] The info data size. |
bUseAsReference | [in] Whether to store the data in an internal buffer or not (The data is accessed when the file is closed). |
Set the mode, if a prefix is set by a temp Save File Name or not.
useMode | [in] The filename. |
Set the name of a stream.
ui16StreamId | [in] The stream id. |
strStreamName | [in] The new name. |
|
protected |
stores the data to disk
[in] | bFlush | flushes the data |
|
protected |
tResult WriteChunk | ( | tUInt16 | ui16StreamId, |
const tVoid * | pData, | ||
tUInt32 | nDataSize, | ||
tTimeStamp | nTimeStamp, | ||
tUInt32 | nFlags | ||
) |
Writes a new chunk to the file.
This function is not thread safe! (sync must be done outside in caller)!
ui16StreamId | [in] The stream id. |
pData | [in] The chunk data. |
nDataSize | [in] The data size. |
nTimeStamp | [in] The timestamp of the chunk. |
nFlags | [in] Chunk flags, see tChunkType |
tResult WriteChunk | ( | tUInt16 | ui16StreamId, |
const tVoid * | pData, | ||
tUInt32 | nDataSize, | ||
tTimeStamp | nTimeStamp, | ||
tUInt32 | nFlags, | ||
tBool & | bIndexEntryAppended | ||
) |
Writes a new chunk to the file.
This function is not thread safe! (sync must be done outside in caller)!
ui16StreamId | [in] The stream id. |
pData | [in] The chunk data. |
nDataSize | [in] The data size. |
nTimeStamp | [in] The timestamp of the chunk. |
nFlags | [in] Chunk flags, see tChunkType |
bIndexEntryAppended | [out] return value Index Entry Added |
|
protected |
Write the file header.
ERR_NOERROR | everything is OK |
ERR_DEVICE_IO | couldn't write to file |
|
protected |
write the extension file header
ERR_NOERROR | everything is OK |
ERR_DEVICE_IO | couldn't write to file |
ERR_MEMORY | no memory available to create file extension header |
|
protected |
write index table