// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include #include #include #include #include namespace zen { class GcManager; class ScrubContext; /** CAS storage interface This uses the hash of the stored data (after decompression) as the key */ class CasStore { public: virtual ~CasStore() = default; inline const CidStoreConfiguration& Config() { return m_Config; } struct InsertResult { bool New = false; }; enum class InsertMode { kCopyOnly, kMayBeMovedInPlace }; virtual void Initialize(const CidStoreConfiguration& Config) = 0; virtual InsertResult InsertChunk(IoBuffer Data, const IoHash& ChunkHash, InsertMode Mode = InsertMode::kMayBeMovedInPlace) = 0; virtual std::vector InsertChunks(std::span Data, std::span ChunkHashes, InsertMode Mode = InsertMode::kMayBeMovedInPlace) = 0; virtual IoBuffer FindChunk(const IoHash& ChunkHash) = 0; virtual bool ContainsChunk(const IoHash& ChunkHash) = 0; virtual void FilterChunks(HashKeySet& InOutChunks) = 0; virtual bool IterateChunks(std::span DecompressedIds, const std::function& AsyncCallback, WorkerThreadPool* OptionalWorkerPool, uint64_t LargeSizeLimit) = 0; virtual void Flush() = 0; virtual CidStoreSize TotalSize() const = 0; #if ZEN_WITH_TESTS virtual void Scrub(ScrubContext& Ctx) = 0; #endif // ZEN_WITH_TESTS protected: CidStoreConfiguration m_Config; }; std::unique_ptr CreateCasStore(GcManager& Gc); void CAS_forcelink(); } // namespace zen