15 #include "../OSSupport/IsThread.h"
16 #include "../OSSupport/Queue.h"
30 class cWSSchema
abstract
33 cWSSchema(
cWorld * a_World) : m_World(a_World) {}
34 virtual ~cWSSchema() {}
36 virtual bool LoadChunk(
const cChunkCoords & a_Chunk) = 0;
37 virtual bool SaveChunk(
const cChunkCoords & a_Chunk) = 0;
38 virtual const AString GetName(
void)
const = 0;
97 bool LoadChunk(
int a_ChunkX,
int a_ChunkZ);
101 virtual void Execute(
void)
override;
std::list< cWSSchema * > cWSSchemaList
Wraps the chunk coords into a single structure.
cIsThread(AString &&a_ThreadName)
The actual world storage class.
bool LoadChunk(int a_ChunkX, int a_ChunkZ)
Loads the chunk specified; returns true on success, false on failure.
bool LoadOneChunk(void)
Loads one chunk from the queue (if any queued); returns true if there was a chunk in the queue to loa...
virtual ~cWorldStorage() override
void Initialize(cWorld &a_World, const AString &a_StorageSchemaName, int a_StorageCompressionFactor)
Initializes the storage schemas, ready to be started.
cEvent m_Event
Set when there's any addition to the queues.
AString m_StorageSchemaName
size_t GetSaveQueueLength(void)
size_t GetLoadQueueLength(void)
virtual void Execute(void) override
This function, overloaded by the descendants, is called in the new thread.
void WaitForSaveQueueEmpty(void)
bool SaveOneChunk(void)
Saves one chunk from the queue (if any queued); returns true if there was a chunk in the queue to sav...
void QueueLoadChunk(int a_ChunkX, int a_ChunkZ)
Queues a chunk to be loaded, asynchronously.
cQueue< cChunkCoords > m_LoadQueue
void InitSchemas(int a_StorageCompressionFactor)
void QueueSaveChunk(int a_ChunkX, int a_ChunkZ)
Queues a chunk to be saved, asynchronously.
void WaitForLoadQueueEmpty(void)
cQueue< cChunkCoords > m_SaveQueue
cWSSchema * m_SaveSchema
The one storage schema used for saving.
cWSSchemaList m_Schemas
All the storage schemas (all used for loading)