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 > 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, 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 ( )
inline

Member Function Documentation

void CTemplateLoader::ConstructTemplateActor ( const std::string &  actorName,
CParamNode out 
)
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.

bool CTemplateLoader::LoadTemplateFile ( const std::string &  templateName,
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
templateNameXML 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.

Member Data Documentation

std::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: