libHSPlasma
|
Manages the entire library's resources, including keys, creatables, age info and page info. More...
#include <plResManager.h>
Protected Attributes | |
PlasmaVer | fPlasmaVer |
plKeyCollector | keys |
std::vector< plPageInfo * > | pages |
std::vector< plAgeInfo * > | ages |
ProgressCallback | progressFunc |
PageUnloadCallback | pageUnloadFunc |
unsigned int | totalKeys |
unsigned int | readKeys |
bool | mustStub |
Manages the entire library's resources, including keys, creatables, age info and page info.
You will need to create at least one ResManager if you plan to use any creatables or keys in your application. You can also use it to handle PRC data and store Age or PRP information. Most of the top-level file-based operations you'll do will start from here.
plResManager::plResManager | ( | PlasmaVer | pv = PlasmaVer::pvUnknown | ) |
|
virtual |
Destroy the ResManager.
This will delete all keys, Creatables, Ages and Pages that are registered with the ResManager.
void plResManager::AddAge | ( | plAgeInfo * | age | ) |
Manually register a plAgeInfo with the ResManager.
Note: You should only use this for NEW ages created by the application, never for ages read from files or PRC tags.
Manually register a plKey with the ResManager.
Note: You should do this if you are creating a NEW hsKeyedObject (after initializing the key with hsKeyedObject::init() ). You should NOT use this for keys or KeyedObjects that are loaded into the ResManager through other sources, like parsing from a file or PRC tag.
Unlike AddObject(), this function WILL check to see if the key is already registered, and returns a copy of the registered key instead of the new one, if it is found in the ResManager.
void plResManager::AddObject | ( | const plLocation & | loc, |
hsKeyedObject * | obj | ||
) |
Manually register an hsKeyedObject with the ResManager.
Like AddKey, this registers the object and its key into the ResManager, but this function also changes the location of the associated plKey to match the location we're adding it to. However, unlike AddKey(), this function performs no check to see whether the key is already loaded. You should only use this function for NEW hsKeyedObjects and never for ones that are already loaded from a file or PRC tag.
void plResManager::AddPage | ( | plPageInfo * | page | ) |
Manually register a plPageInfo with the ResManager.
Note: You should only use this for NEW pages created by the application, never for pages read from files or PRC tags.
void plResManager::ChangeLocation | ( | plLocation | from, |
plLocation | to | ||
) |
This function can completely change a location identifier for all loaded data. Any plKeys or plPageInfos that are registered whose location matches from will be updated to the location to, and when the files are written back to disk, they will be stored with the new location info.
unsigned int plResManager::countKeys | ( | const plLocation & | loc | ) |
Returns the total number of keys registered for the specified plLocation
void plResManager::DelAge | ( | const plString & | name | ) |
Removes the age specified by filename from the ResManager, and frees any memory associated with it. Unlike UnloadAge(), this function does NOT remove any pages referenced by the age, nor any objects referenced by those pages.
void plResManager::DelObject | ( | plKey | obj | ) |
Removes the plKey and its associated hsKeyedObject from the ResManager, and frees the memory associated with both. This will allow you to delete an object from a page.
void plResManager::DelPage | ( | const plLocation & | loc | ) |
Removes the page specified by loc from the ResManager, and frees any memory associated with it. Unlike UnloadPage(), this function does NOT remove any keys or objects referenced by the page.
Finds a registered age info structure by name.
name | The filename of the age to be found |
plPageInfo* plResManager::FindPage | ( | const plLocation & | loc | ) |
Find a registered page whose location is specified by loc.
std::vector<plKey> plResManager::getKeys | ( | const plLocation & | loc, |
short | type, | ||
bool | checkKeys = false |
||
) |
Return an array of all the plKeys of the specified Creatable Class for the specified location.
checkKeys | if set to true, the ResManager will clean out any invalid keys while building the type list. |
std::vector<plKey> plResManager::getKeys | ( | short | type, |
bool | checkKeys = false |
||
) |
Return an array of all the plKeys of the specified Creatable Class for all locations.
checkKeys | if set to true, the ResManager will clean out any invalid keys while building the type list. |
std::vector<plLocation> plResManager::getLocations | ( | ) |
Return an array of all page locations registered by the ResManager. Note that this might include locations that are not currently loaded, since it's possible to load keys for external pages.
class hsKeyedObject* plResManager::getObject | ( | plKey | key | ) |
Find and return the object referenced by key, or NULL if the key either doesn't exist or isn't loaded. This uses the ResManager's internal list of keys, unlike plKeyData::getObj() which just returns the key's internal object pointer.
class plSceneNode* plResManager::getSceneNode | ( | const plLocation & | loc | ) |
Finds the plSceneNode associated with the page at loc. If there is more than one Scene Node in the page, returns only the first one.
std::vector<short> plResManager::getTypes | ( | const plLocation & | loc, |
bool | checkKeys = false |
||
) |
Return an array of all of the Creatable Class types that have one or more keys loaded into the ResManager for this location.
checkKeys | if set to true, the ResManager will clean out any invalid keys while building the type list. |
PlasmaVer plResManager::getVer | ( | ) |
Return the version of data files this ResManager expects to deal with. Used for reading or writing data to files only.
void plResManager::lock | ( | ) |
Lock access to the ResManager in multithreaded apps
void plResManager::MoveKey | ( | plKey | key, |
const plLocation & | to | ||
) |
Change a plKey's location to the one specified. This is probably a good idea to call after importing a key or KeyedObject from a file or PRC data, to ensure the key and object get put into the correct place. Since plKeys share a single datum, any objects in any pages that hold reference to this key will also use the updated location.
class plCreatable* plResManager::prcParseCreatable | ( | const pfPrcTag * | tag | ) |
Parse a plCreatable contained in the PRC tag.
Parse the PRC tag as a plKey and register it with the ResManager
plKey plResManager::prcParseKeyNotify | ( | const pfPrcTag * | tag, |
const plKeyData::AfterLoadCallback & | callback | ||
) |
Parse the PRC tag as a plKey, register it with the ResManager and add callback
callback | Callback to be called after object referenced by this key is parsed |
plAgeInfo* plResManager::ReadAge | ( | const char * | filename, |
bool | readPages | ||
) |
Read an AGE file and register it with the ResManager.
readPages | Specifies whether to also load and register all of the pages referenced by the AGE file. |
Read age file data from a PRC block and register it with the ResManager.
class plCreatable* plResManager::ReadCreatable | ( | hsStream * | S, |
bool | canStub = false , |
||
int | stubLen = 0 |
||
) |
Read a plCreatable from the stream. This should be converted to a compatible subclass in order to make use of its members.
canStub | Specifies whether an unsupported ClassIndex can be made into a plCreatableStub without disrupting the stream. |
stubLen | Specifies the size of the plCreatable for stubs This only makes sense if canStub is true, and it MUST be specified if canStub is true. |
plKey plResManager::readKeyNotify | ( | hsStream * | S, |
const plKeyData::AfterLoadCallback & | callback | ||
) |
Read a plKey, register it with the ResManager and add callback
callback | Callback to be called after object referenced by this key is loaded |
plPageInfo* plResManager::ReadPage | ( | const char * | filename, |
bool | stub = false |
||
) |
Read a Page (PRP File) and register it with the ResManager.
plPageInfo* plResManager::ReadPagePrc | ( | const pfPrcTag * | root | ) |
Parse a page from a PRC data source, and register it with the ResManager.
Read a raw plKey from a stream (no "exists" bool for Uru streams)
PageUnloadCallback plResManager::SetPageUnloadFunc | ( | PageUnloadCallback | newFunc | ) |
ProgressCallback plResManager::SetProgressFunc | ( | ProgressCallback | newFunc | ) |
This function is currently unsupported.
void plResManager::setVer | ( | PlasmaVer | pv, |
bool | force = false |
||
) |
Set the version of data files this ResManager expects to deal with. This is used when reading or writing data to files, but doesn't have any affect on data already loaded.
force | Change the version even if one is already set |
void plResManager::UnloadAge | ( | const plString & | name | ) |
Unload an age info structure by name. Frees all memory associated with the age, and also unloads all pages that are described by this age info.
void plResManager::UnloadPage | ( | const plLocation & | loc | ) |
Unloads and frees memory for all registered data for the page whose location is specified by loc.
void plResManager::unlock | ( | ) |
Unlock access to the ResManager in multithreaded apps
void plResManager::WriteAge | ( | const char * | filename, |
plAgeInfo * | age | ||
) |
Create/overwrite an age file for the specified age info structure
void plResManager::WriteAgePrc | ( | pfPrcHelper * | prc, |
plAgeInfo * | age | ||
) |
Write a PRC chunk for the specified age info structure
void plResManager::WriteCreatable | ( | hsStream * | S, |
class plCreatable * | pCre | ||
) |
Writes a plCreatable to the stream.
void plResManager::writeKey | ( | hsStream * | S, |
hsKeyedObject * | ko | ||
) |
Write the plKey that describes the specified hsKeyedObject to a stream
void plResManager::WritePage | ( | const char * | filename, |
plPageInfo * | page | ||
) |
Write the specified page to a PRP file
void plResManager::WritePagePrc | ( | pfPrcHelper * | prc, |
plPageInfo * | page | ||
) |
Write the specified page to a PRC document
Write a raw plKey to a stream (no "exists" bool for Uru streams)
void plResManager::writeUoid | ( | hsStream * | S, |
hsKeyedObject * | ko | ||
) |
Write the raw plKey that describes the hsKeyedObject to a stream
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |