Plasma Engine  2.0
Loading...
Searching...
No Matches
AssetFileHeader.h
1#pragma once
2
3#include <Foundation/IO/Stream.h>
4#include <Foundation/Strings/HashedString.h>
5
7class PL_FOUNDATION_DLL plAssetFileHeader
8{
9public:
11
13 plResult Read(plStreamReader& inout_stream);
14
16 plResult Write(plStreamWriter& inout_stream) const;
17
19 bool IsFileUpToDate(plUInt64 uiExpectedHash, plUInt16 uiVersion) const { return (m_uiHash == uiExpectedHash && m_uiVersion == uiVersion); }
20
22 plUInt64 GetFileHash() const { return m_uiHash; }
23
25 void SetFileHashAndVersion(plUInt64 uiHash, plUInt16 v)
26 {
27 m_uiHash = uiHash;
28 m_uiVersion = v;
29 }
30
32 plUInt16 GetFileVersion() const { return m_uiVersion; }
33
35 const plHashedString& GetGenerator() { return m_sGenerator; }
36
38 void SetGenerator(plStringView sGenerator) { m_sGenerator.Assign(sGenerator); }
39
40private:
41 // initialize to a 'valid' hash
42 // this may get stored, unless someone sets the hash
43 plUInt64 m_uiHash = 0;
44 plUInt16 m_uiVersion = 0;
45 plHashedString m_sGenerator;
46};
Simple class to handle asset file headers (the very first bytes in all transformed asset files)
Definition AssetFileHeader.h:8
plUInt64 GetFileHash() const
Returns the asset file hash.
Definition AssetFileHeader.h:22
const plHashedString & GetGenerator()
Returns the generator which was used to produce the asset file.
Definition AssetFileHeader.h:35
void SetFileHashAndVersion(plUInt64 uiHash, plUInt16 v)
Sets the asset file hash.
Definition AssetFileHeader.h:25
plUInt16 GetFileVersion() const
Returns the asset type version.
Definition AssetFileHeader.h:32
void SetGenerator(plStringView sGenerator)
Allows to set the generator string.
Definition AssetFileHeader.h:38
bool IsFileUpToDate(plUInt64 uiExpectedHash, plUInt16 uiVersion) const
Checks whether the stored file contains the same hash.
Definition AssetFileHeader.h:19
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
Interface for binary in (read) streams.
Definition Stream.h:22
Interface for binary out (write) streams.
Definition Stream.h:107
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54