|
wavelength 1.0.0
|
Registry of every live renderer object, of every class a .rnd file may instantiate, and of the texture files being read. More...
#include <rndmanager.h>
Classes | |
| class | ResourceLoader |
| Read of one resource file into memory, shared by every reference to the file. More... | |
Public Types | |
| enum | TextureState { kTextureLoading = 0 , kTextureLoaded = 1 , kTextureUnknown = 2 } |
| Results of IsTextureLoaded(). More... | |
| typedef RndObject *(* | ClassFactory) (const char *pszName) |
| Builds one instance of a registered class. | |
Public Member Functions | |
| RndManager () | |
| Construct an empty registry. | |
| ~RndManager () | |
| Destroy the registry. | |
| void | Init () |
| Register the factory of every class a .rnd file may instantiate. | |
| void | PollLoaders (float fBudgetMs) |
| Advance the queued loaders until a time budget is spent. | |
| void | RemoveLoader (RndLoader *pLoader) |
| Remove a loader from the queue. | |
| RndObject * | Find (const char *pszName) |
| Resolve a live object by name. | |
| std::unique_ptr< RndLoader > | AddLoader (const char *pszFile, int nFlags, RndLoader::Callback *pCallback, BinStream *pStream) |
| Create a loader for a .rnd file and queue it. | |
| void | LoadFile (const char *pszFile) |
| Load a .rnd file before the call returns. | |
| void | SaveFile (const char *pszFile) |
| Write the objects to a .rnd file. | |
| RndObject * | Create (const char *pszClass, const char *pszName) |
| Create an instance of a registered class. | |
| void | Clone (RndObject *pSource, const char *pszPrefix, std::list< RndObject * > *pClones, int nFlags, int bRecurse, int bLink) |
| Clone an object under a prefixed name, optionally with its descendants and its parents. | |
| void | SortObjects (std::list< RndObject * > &objects) |
| Order a list of objects for writing, the textures first and sorted by file, followed by the animations, the materials, the fonts, the texts, the meshes, the blurs, and the rest. | |
| void | Write (BinStream &stream) |
| Write every object that is not internal as a .rnd file. | |
| const char * | ResourcePath (const char *pszFile) |
| Report the file to read for a resource. | |
| bool | AcquireTexture (const FilePath &path) |
| Take a reference on a texture file, starting to read it on the first reference. | |
| void | GetResource (const FilePath &path, void **ppData, int *pnSize) |
| Wait for a resource file and hand out its data, dropping one reference. | |
| int | IsTextureLoaded (const FilePath &path) |
| Report whether a texture file finished reading. | |
| void | DeleteLoadedObjects () |
| Delete every object a file created, leaving the internal objects. | |
| void | ReleaseTexture (const FilePath &path) |
| Release the read of a texture file whatever its references. | |
| void | ClearResources () |
| Release every resource read. | |
| const std::map< const char *, RndObject *, StrLess > & | GetObjects () const |
| void | SetObject (const char *pszName, RndObject *pObject) |
| Register an object under a name, replacing any object registered under it. | |
| void | RemoveObject (const char *pszName) |
| Remove the registration of a name. | |
| void | SetClassFactory (const char *pszClass, ClassFactory factory) |
| Register the factory that Create() calls for a class. | |
Static Public Member Functions | |
| static RndObject * | NewTunnel (const char *pszName) |
| Create a view in place of a tunnel, the factory registered for the class Tunnel. | |
| static const char * | ResourceTag (const char *pszFile) |
| Report the tag a resource file's buffer is billed to, from the file's extension. | |
Static Public Attributes | |
| static int | sRev |
| The format version Write() writes and the newest a loader accepts. | |
Registry of every live renderer object, of every class a .rnd file may instantiate, and of the texture files being read.
The class has no virtual and no RTTI. Its name is the tag it bills its loaders' storage to, and the RTTI of its nested ResourceLoader records it as the enclosing class.
| typedef RndObject *(* RndManager::ClassFactory) (const char *pszName) |
Builds one instance of a registered class.
| pszName | The object name for the new instance. |
Results of IsTextureLoaded().
| Enumerator | |
|---|---|
| kTextureLoading | The file is still being read. |
| kTextureLoaded | The file is in memory. |
| kTextureUnknown | No reference on the file exists. |
| RndManager::RndManager | ( | ) |
Construct an empty registry.
| RndManager::~RndManager | ( | ) |
Destroy the registry.
| void RndManager::Init | ( | ) |
Register the factory of every class a .rnd file may instantiate.
The class Tunnel is registered with NewTunnel(). The current camera is cleared.
| void RndManager::PollLoaders | ( | float | fBudgetMs | ) |
Advance the queued loaders until a time budget is spent.
The front loader is advanced, and it leaves the queue once it has loaded. The budget is measured on the system clock.
| fBudgetMs | The time the loads may take, in milliseconds. |
| void RndManager::RemoveLoader | ( | RndLoader * | pLoader | ) |
Remove a loader from the queue.
The name is inferred.
| pLoader | The loader. |
| RndObject * RndManager::Find | ( | const char * | pszName | ) |
Resolve a live object by name.
| pszName | The object name. |
| std::unique_ptr< RndLoader > RndManager::AddLoader | ( | const char * | pszFile, |
| int | nFlags, | ||
| RndLoader::Callback * | pCallback, | ||
| BinStream * | pStream ) |
Create a loader for a .rnd file and queue it.
A synchronous load first finishes the loads already queued.
| pszFile | The file. |
| nFlags | The RndLoader::Flags of the load. |
| pCallback | The callback the loader consults for each object, or null. |
| pStream | The stream to read instead of the file, or null. |
| void RndManager::LoadFile | ( | const char * | pszFile | ) |
Load a .rnd file before the call returns.
The loader is deleted once it finishes, and the objects remain.
| pszFile | The file. |
| void RndManager::SaveFile | ( | const char * | pszFile | ) |
Write the objects to a .rnd file.
A file that does not open reports "Could not open file: %s" and nothing is written. Otherwise the directory of the file becomes the root that relative paths resolve against.
| pszFile | The file. |
| RndObject * RndManager::Create | ( | const char * | pszClass, |
| const char * | pszName ) |
Create an instance of a registered class.
An unregistered class, or a name already in use, yields null.
| pszClass | The class name a .rnd file writes. |
| pszName | The object name for the new instance. |
| void RndManager::Clone | ( | RndObject * | pSource, |
| const char * | pszPrefix, | ||
| std::list< RndObject * > * | pClones, | ||
| int | nFlags, | ||
| int | bRecurse, | ||
| int | bLink ) |
Clone an object under a prefixed name, optionally with its descendants and its parents.
The descendants are cloned without their descendants, and every clone then has each reference to an original replaced with the clone of that original. The pairing assumes that pClones started empty. A linked clone is attached to each parent of the source.
| pSource | The object to clone. |
| pszPrefix | The prefix for the name of every clone. |
| pClones | Receives the clone first, followed by the clones of the descendants. |
| nFlags | The copy flags. |
| bRecurse | Non-zero to clone the descendants. |
| bLink | Non-zero to attach the clone to the parents of the source. |
| void RndManager::SortObjects | ( | std::list< RndObject * > & | objects | ) |
Order a list of objects for writing, the textures first and sorted by file, followed by the animations, the materials, the fonts, the texts, the meshes, the blurs, and the rest.
The name is inferred.
| objects | The list to order. |
| void RndManager::Write | ( | BinStream & | stream | ) |
Write every object that is not internal as a .rnd file.
The file is the version, the class and the name of each object, the files of the textures and the movies, and the record of each object, each record followed by an end marker.
| stream | The stream to write to. |
|
static |
Create a view in place of a tunnel, the factory registered for the class Tunnel.
A notice reports the substitution. The name is inferred.
| pszName | The object name. |
|
static |
Report the tag a resource file's buffer is billed to, from the file's extension.
The name is inferred.
| pszFile | The file. |
| const char * RndManager::ResourcePath | ( | const char * | pszFile | ) |
Report the file to read for a resource.
A bitmap is converted to the renderer's texture format and cached. The name is inferred.
| pszFile | The resource file. |
| bool RndManager::AcquireTexture | ( | const FilePath & | path | ) |
Take a reference on a texture file, starting to read it on the first reference.
An empty path, or a renderer without textures, is ignored. The name is inferred.
| path | The file. |
| void RndManager::GetResource | ( | const FilePath & | path, |
| void ** | ppData, | ||
| int * | pnSize ) |
Wait for a resource file and hand out its data, dropping one reference.
A file without a reference is read first. The read is released with its last reference. The name is inferred.
| path | The file. |
| ppData | Receives the data, or null when the file cannot be read. |
| pnSize | Receives the size of the data in bytes. |
| int RndManager::IsTextureLoaded | ( | const FilePath & | path | ) |
Report whether a texture file finished reading.
The name is inferred.
| path | The file. |
| void RndManager::DeleteLoadedObjects | ( | ) |
Delete every object a file created, leaving the internal objects.
The resource reads are released as well.
| void RndManager::ReleaseTexture | ( | const FilePath & | path | ) |
Release the read of a texture file whatever its references.
The name is inferred.
| path | The file. |
| void RndManager::ClearResources | ( | ) |
Release every resource read.
The name is inferred.
|
inline |
Register an object under a name, replacing any object registered under it.
| pszName | The name, which must outlive the registration. |
| pObject | The object. |
|
inline |
Remove the registration of a name.
| pszName | The name. |
|
inline |
Register the factory that Create() calls for a class.
| pszClass | The class name a .rnd file writes. |
| factory | The factory. |
|
static |
The format version Write() writes and the newest a loader accepts.