/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Engine/Foundation/IO/DeduplicationWriteContext.h
61 строка
2 KB
Jan Krassnigg
Fixes for including public ez headers (#1755)
04 янв 2026, 10:57
Не верифицирован
04 янв 2026, 10:57
5feb7ef
Код
Авторство
О чём код?
#pragma once #include <Foundation/Containers/ArrayBase.h> #include <Foundation/Containers/HashTable.h> #include <Foundation/Containers/Map.h> #include <Foundation/Containers/Set.h> #include <Foundation/IO/SerializationContext.h> #include <Foundation/Types/SharedPtr.h> #include <Foundation/Types/UniquePtr.h> class ezStreamWriter; /// \brief Serialization Context that de-duplicates objects when writing to a stream. Duplicated objects are identified by their address and /// only the first occurrence is written to the stream while all subsequence occurrences are just written as an index. class EZ_FOUNDATION_DLL ezDeduplicationWriteContext : public ezSerializationContext<ezDeduplicationWriteContext> { EZ_DECLARE_SERIALIZATION_CONTEXT(ezDeduplicationWriteContext); public: ezDeduplicationWriteContext(); ~ezDeduplicationWriteContext(); /// \brief Writes a single object to the stream. Can be either a reference or a pointer to the object. template <typename T> ezResult WriteObject(ezStreamWriter& inout_stream, const T& obj); // [tested] /// \brief Writes a single object to the stream. template <typename T> ezResult WriteObject(ezStreamWriter& inout_stream, const ezSharedPtr<T>& pObject); // [tested] /// \brief Writes a single object to the stream. template <typename T> ezResult WriteObject(ezStreamWriter& inout_stream, const ezUniquePtr<T>& pObject); // [tested] /// \brief Writes an array of de-duplicated objects. template <typename ArrayType, typename ValueType> ezResult WriteArray(ezStreamWriter& inout_stream, const ezArrayBase<ValueType, ArrayType>& array); // [tested] /// \brief Writes a set of de-duplicated objects. template <typename KeyType, typename Comparer> ezResult WriteSet(ezStreamWriter& inout_stream, const ezSetBase<KeyType, Comparer>& set); // [tested] enum class WriteMapMode { DedupKey, DedupValue, DedupBoth }; /// \brief Writes a map. Mode controls whether key or value or both should de-duplicated. template <typename KeyType, typename ValueType, typename Comparer> ezResult WriteMap(ezStreamWriter& inout_stream, const ezMapBase<KeyType, ValueType, Comparer>& map, WriteMapMode mode); // [tested] private: template <typename T> ezResult WriteObjectInternal(ezStreamWriter& stream, const T* pObject); ezHashTable<const void*, ezUInt32> m_Objects; }; #include <Foundation/IO/Implementation/DeduplicationWriteContext_inl.h>