TileSetDataCache class
Tile sets read whole, for the pixels and the masks of their tiles.
A tile set file is read once, also when it can't be read, so it isn't tried again and again, until it's invalidated after the file was written. A tile set the level stores in itself, whose name starts with :, is read from its bytes in the document, and read again when they changed. A change of the same size is copied into the same bytes, so after MarkLevelTilesChanged() a hash of the bytes tells whether they really changed.
Public static variables
-
static std::
uint64_t HashSeed constexpr - Seed of HashBytes().
-
static std::
size_t MaxUnusedTileSets constexpr - Most tile sets read from their files that the level doesn't use kept at once, the least recently used are forgotten.
Public static functions
-
static auto HashBytes(const void* data,
std::
size_t size, std:: uint64_t hash = HashSeed) -> std:: uint64_t - Hashes bytes by FNV-1a, enough to tell whether they changed.
Constructors, destructors, conversion operators
- TileSetDataCache()
- ~TileSetDataCache()
- TileSetDataCache(const TileSetDataCache&) deleted
Public functions
- auto operator=(const TileSetDataCache&) -> TileSetDataCache& deleted
-
auto Get(const LevelDocument& document,
StringView name) -> const Formats::
TileSetData* - Returns a whole tile set, or
nullptrif it can't be read. - void Invalidate(StringView name)
- Forgets what was read of a tile set, after its file was written.
- void InvalidateLevelTileSets()
- Forgets the tile sets a level stores in itself, before another level is edited.
- void MarkLevelTilesChanged()
- Tells that the bytes of the tile sets the level stores in itself may have changed.
-
auto GetLevelTilesGeneration() const -> std::
uint32_t - Returns a number that changes with each MarkLevelTilesChanged().
Function documentation
const Formats:: TileSetData* Jazz2:: Editor:: TileSetDataCache:: Get(const LevelDocument& document,
StringView name)
Returns a whole tile set, or nullptr if it can't be read.
A name starting with : is a tile set document stores in itself. The pointer is valid until the tile set is invalidated, or for a tile set of the level, until its bytes changed. Only a few tile sets that document doesn't use are kept, so the pointer to such one is valid only until MaxUnusedTileSets others are read.