diff options
author | peterbell10 <peterbell10@live.co.uk> | 2017-08-21 18:56:53 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2017-08-21 18:56:53 +0200 |
commit | 096cdac80d222ac0be2a0554a759a0b16c1c34f6 (patch) | |
tree | 03190afb388f999bf9740fbae15d688780f036d5 /src/ChunkDataCallback.h | |
parent | Award player an achievement when creating a beacon (#3930) (diff) | |
download | cuberite-096cdac80d222ac0be2a0554a759a0b16c1c34f6.tar cuberite-096cdac80d222ac0be2a0554a759a0b16c1c34f6.tar.gz cuberite-096cdac80d222ac0be2a0554a759a0b16c1c34f6.tar.bz2 cuberite-096cdac80d222ac0be2a0554a759a0b16c1c34f6.tar.lz cuberite-096cdac80d222ac0be2a0554a759a0b16c1c34f6.tar.xz cuberite-096cdac80d222ac0be2a0554a759a0b16c1c34f6.tar.zst cuberite-096cdac80d222ac0be2a0554a759a0b16c1c34f6.zip |
Diffstat (limited to 'src/ChunkDataCallback.h')
-rw-r--r-- | src/ChunkDataCallback.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/ChunkDataCallback.h b/src/ChunkDataCallback.h index 4841dad03..2bf554b74 100644 --- a/src/ChunkDataCallback.h +++ b/src/ChunkDataCallback.h @@ -101,3 +101,37 @@ protected: +/** A simple implementation of the cChunkDataCallback interface that just copies the cChunkData */ +class cChunkDataCopyCollector : + public cChunkDataCallback +{ +public: + struct MemCallbacks: + cAllocationPool<cChunkData::sChunkSection>::cStarvationCallbacks + { + virtual void OnStartUsingReserve() override {} + virtual void OnEndUsingReserve() override {} + virtual void OnOutOfReserve() override {} + }; + + cChunkDataCopyCollector(): + m_Pool(cpp14::make_unique<MemCallbacks>()), + m_Data(m_Pool) + { + } + + + cListAllocationPool<cChunkData::sChunkSection, cChunkData::NumSections> m_Pool; // Keep 1 chunk worth of reserve + cChunkData m_Data; + +protected: + + virtual void ChunkData(const cChunkData & a_ChunkBuffer) override + { + m_Data.Assign(a_ChunkBuffer); + } +}; + + + + |