resonance 1.0.1
Loading...
Searching...
No Matches
asyncloader.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4#include <vector>
5
6#include "os/hxstr.h"
7#include "os/mem.h"
8
9namespace Rnd {
10class Drawable;
11class Object;
12} // namespace Rnd
13
30public:
42
52 RndAsyncLoader(const HxStr &directory, const HxStr &file, int nZone);
53
61
73 void Enqueue();
74
84 void Cancel();
85
98 void Restart(const HxStr &directory, const HxStr &file);
99
111 void Unload();
112
121 static void *operator new(size_t nSize) {
122 return AllocateTaggedMemory(nSize, "RndAsyncLoader");
123 }
124
132 static void operator delete(void *pBlock) {
133 OperatorDeleteOverride(pBlock, "RndAsyncLoader");
134 }
135
149 int Poll(float *pfProgress);
150
168 static void PollAsyncLoads();
169
177 std::list<Rnd::Object *> mObjects;
178
188 std::list<Rnd::Drawable *> mDrawables;
189
190private:
200 void HarvestLoadedObjects();
201
202 // Every object the request loaded, copied from Rnd::TheManager.mLoaded.
203 std::list<Rnd::Object *> mLoadedObjects; // +0x08
204 HxStr mDirectory; // +0x0c
205 HxStr mFile; // +0x14
206
207public:
215
216private:
217 // Set once PollAsyncLoads() has read the file and loaded its objects.
218 int mFileRead; // +0x20
219 // Set once Poll() finds every texture in mObjects loaded.
220 int mFinished; // +0x24
221 // Zone PollAsyncLoads() selects while it loads the objects.
222 int mZone; // +0x28
223};
224
236
243extern int g_nRndLoaderZone;
int g_nRndLoaderZone
Zone the file reads are allocated from, kNoZone until the first Enqueue().
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Request to load one renderer file in the background.
Definition asyncloader.h:29
static void PollAsyncLoads()
Advance every queued load request.
int Poll(float *pfProgress)
Test whether this request has finished and report how far it has advanced.
std::list< Rnd::Object * > mObjects
The objects the request has produced so far.
Definition asyncloader.h:177
void Cancel()
Abandon this request.
RndAsyncLoader()
Prepare an empty request with no directory or file.
int mPending
Starts set and reports no progress while it stays set.
Definition asyncloader.h:214
RndAsyncLoader(const HxStr &directory, const HxStr &file, int nZone)
Prepare a load request.
~RndAsyncLoader()
Release the request and any partially loaded data.
std::list< Rnd::Drawable * > mDrawables
Drawables the container load produced.
Definition asyncloader.h:188
void Enqueue()
Add this request to the load queue.
void Unload()
Abandon this request and release everything it has loaded, leaving it ready to start again.
void Restart(const HxStr &directory, const HxStr &file)
Abandon this request and point it at another file.
Mix-in for an object that draws itself and then a list of other drawables.
Definition drawable.h:32
Base of every object the renderer can load, resolve by name, and serialise.
Definition object.h:43
void OperatorDeleteOverride(void *pBlock, const char *pszClass)
Release a block that AllocateTaggedMemory() handed out.
void * AllocateTaggedMemory(size_t nSize, const char *pszClass)
Allocate a block for one object of a named class.
The rendering engine.
Definition animhelper.h:3
One file read in flight, 0x10 bytes.
Definition asyncloader.h:230
void * mBuffer
Definition asyncloader.h:233
int mLength
Definition asyncloader.h:234
int mHandle
Definition asyncloader.h:232
RndAsyncLoader * mRequest
Definition asyncloader.h:231