![]() |
Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
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 > | FindTemplatesUnrestricted (const std::string &path, bool includeSubdirectories) const |
Returns a list of strings that could validly be passed as templateName to LoadTemplateFile. More... | |
Private Member Functions | |
| bool | LoadTemplateFile (CParamNode &node, std::string_view templateName, bool compositing, int depth) |
| (Re)loads the given template, regardless of whether it exists already, and saves into m_TemplateFileData. More... | |
| void | ConstructTemplateActor (std::string_view actorName, CParamNode &out) |
| Constructs a standard static-decorative-object template for the given actor. More... | |
Private Attributes | |
| std::unordered_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::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).
| std::vector< std::string > CTemplateLoader::FindTemplatesUnrestricted | ( | const std::string & | path, |
| bool | includeSubdirectories | ||
| ) | const |
Returns a list of strings that could validly be passed as templateName to LoadTemplateFile.
Not ignoring any special directories.
| 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 (may be a |-separated string) |
| compositing | - whether this template is an intermediary layer in a |-separated string. |
| depth | - the current recursion depth. |
| 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)