Pyrogenesis  trunk
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CTemplateLoader Class Reference

Template loader: Handles the loading of entity template files for: More...

#include <TemplateLoader.h>

Public Member Functions

 CTemplateLoader ()
 
const CParamNodeGetTemplateFileData (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, CParamNodem_TemplateFileData
 Map from template name (XML filename or special |-separated string) to the most recently loaded non-broken template data. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CTemplateLoader()

CTemplateLoader::CTemplateLoader ( )
inline

Member Function Documentation

◆ ConstructTemplateActor()

void CTemplateLoader::ConstructTemplateActor ( std::string_view  actorName,
CParamNode out 
)
private

Constructs a standard static-decorative-object template for the given actor.

◆ FindTemplates()

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).

◆ FindTemplatesUnrestricted()

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.

◆ GetTemplateFileData()

const CParamNode & CTemplateLoader::GetTemplateFileData ( const std::string &  templateName)

Provides the file data for requested template.

◆ LoadTemplateFile()

bool CTemplateLoader::LoadTemplateFile ( CParamNode node,
std::string_view  templateName,
bool  compositing,
int  depth 
)
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.

Parameters
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.

◆ TemplateExists()

bool CTemplateLoader::TemplateExists ( const std::string &  templateName) const

Check if the template XML file exits, without trying to load it.

Member Data Documentation

◆ m_TemplateFileData

std::unordered_map<std::string, CParamNode> CTemplateLoader::m_TemplateFileData
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)


The documentation for this class was generated from the following files: