Pyrogenesis
trunk
|
Template loader: Handles the loading of entity template files for: More...
#include <TemplateLoader.h>
Public Member Functions | |
CTemplateLoader () | |
const CParamNode & | GetTemplateFileData (const std::string &templateName) |
Provides the file data for requested template. More... | |
bool | TemplateExists (const std::string &templateName) const |
Check if the template XML file exits, without trying to load it. More... | |
std::vector< std::string > | FindTemplates (const std::string &path, bool includeSubdirectories, ETemplatesType templatesType) const |
Returns a list of strings that could be validly passed as templateName to LoadTemplateFile. More... | |
std::vector< std::string > | FindPlaceableTemplates (const std::string &path, bool includeSubdirectories, ETemplatesType templatesType, ScriptInterface &scriptInterface) const |
Private Member Functions | |
bool | LoadTemplateFile (const std::string &templateName, int depth) |
(Re)loads the given template, regardless of whether it exists already, and saves into m_TemplateFileData. More... | |
void | ConstructTemplateActor (const std::string &actorName, CParamNode &out) |
Constructs a standard static-decorative-object template for the given actor. More... | |
Private Attributes | |
std::map< std::string, CParamNode > | m_TemplateFileData |
Map from template name (XML filename or special |-separated string) to the most recently loaded non-broken template data. More... | |
Template loader: Handles the loading of entity template files for:
Template names are intentionally restricted to ASCII strings for storage/serialization efficiency (we have a lot of strings so this is significant); they correspond to filenames so they shouldn't contain non-ASCII anyway.
TODO: Find a way to validate templates outside of the simulation.
|
inline |
|
private |
Constructs a standard static-decorative-object template for the given actor.
std::vector< std::string > CTemplateLoader::FindPlaceableTemplates | ( | const std::string & | path, |
bool | includeSubdirectories, | ||
ETemplatesType | templatesType, | ||
ScriptInterface & | scriptInterface | ||
) | const |
std::vector< std::string > CTemplateLoader::FindTemplates | ( | const std::string & | path, |
bool | includeSubdirectories, | ||
ETemplatesType | templatesType | ||
) | const |
Returns a list of strings that could be validly passed as templateName
to LoadTemplateFile.
(This includes "actor|foo" etc names).
const CParamNode & CTemplateLoader::GetTemplateFileData | ( | const std::string & | templateName | ) |
Provides the file data for requested template.
|
private |
(Re)loads the given template, regardless of whether it exists already, and saves into m_TemplateFileData.
Also loads any parents that are not yet loaded. Returns false on error.
templateName | XML filename to load (not a |-separated string) |
bool CTemplateLoader::TemplateExists | ( | const std::string & | templateName | ) | const |
Check if the template XML file exits, without trying to load it.
|
private |
Map from template name (XML filename or special |-separated string) to the most recently loaded non-broken template data.
This includes files that will fail schema validation. (Failed loads won't remove existing entries under the same name, so we behave more nicely when hotloading broken files)