Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CCmpTemplateManager Class Referencefinal
Inheritance diagram for CCmpTemplateManager:
Collaboration diagram for CCmpTemplateManager:

Public Member Functions

int GetComponentTypeId () const override
 
void Init (const CParamNode &paramNode) override
 
void Deinit () override
 
void Serialize (ISerializer &serialize) override
 
void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize) override
 
void HandleMessage (const CMessage &msg, bool global) override
 
void DisableValidation () override
 Permanently disable XML validation (intended solely for test cases). More...
 
const CParamNodeLoadTemplate (entity_id_t ent, const std::string &templateName) override
 Loads the template XML file identified by 'templateName' (including inheritance from parent XML files) for use with a new entity 'ent'. More...
 
const CParamNodeGetTemplate (const std::string &templateName) override
 Loads the template XML file identified by 'templateName' (including inheritance from parent XML files). More...
 
const CParamNodeGetTemplateWithoutValidation (const std::string &templateName) override
 Like GetTemplate, except without doing the XML validation (so it's faster but may return invalid templates). More...
 
bool TemplateExists (const std::string &templateName) const override
 Check if the template XML file exists, without trying to load it. More...
 
const CParamNodeLoadLatestTemplate (entity_id_t ent) override
 Returns the template most recently specified for the entity 'ent'. More...
 
std::string GetCurrentTemplateName (entity_id_t ent) const override
 Returns the name of the template most recently specified for the entity 'ent'. More...
 
std::vector< std::string > FindAllTemplates (bool includeActors) const override
 Returns a list of strings that could be validly passed as templateName to LoadTemplate. More...
 
std::vector< std::vector< std::wstring > > GetCivData () override
 Returns some data of the civs from the templates. More...
 
std::vector< std::string > FindUsedTemplates () const override
 Returns a list of strings that could be validly passed as templateName to LoadTemplate. More...
 
std::vector< entity_id_tGetEntitiesUsingTemplate (const std::string &templateName) const override
 Get the list of entities using the specified template. More...
 
virtual const CParamNodeLoadTemplate (entity_id_t ent, const std::string &templateName)=0
 Loads the template XML file identified by 'templateName' (including inheritance from parent XML files) for use with a new entity 'ent'. More...
 
virtual const CParamNodeGetTemplate (const std::string &templateName)=0
 Loads the template XML file identified by 'templateName' (including inheritance from parent XML files). More...
 
virtual const CParamNodeGetTemplateWithoutValidation (const std::string &templateName)=0
 Like GetTemplate, except without doing the XML validation (so it's faster but may return invalid templates). More...
 
virtual bool TemplateExists (const std::string &templateName) const =0
 Check if the template XML file exists, without trying to load it. More...
 
virtual const CParamNodeLoadLatestTemplate (entity_id_t ent)=0
 Returns the template most recently specified for the entity 'ent'. More...
 
virtual std::string GetCurrentTemplateName (entity_id_t ent) const =0
 Returns the name of the template most recently specified for the entity 'ent'. More...
 
virtual std::vector< entity_id_tGetEntitiesUsingTemplate (const std::string &templateName) const =0
 Returns the list of entities having the specified template. More...
 
virtual std::vector< std::string > FindAllTemplates (bool includeActors) const =0
 Returns a list of strings that could be validly passed as templateName to LoadTemplate. More...
 
virtual std::vector< std::vector< std::wstring > > GetCivData ()=0
 Returns some data of the civs from the templates. More...
 
virtual std::vector< std::string > FindUsedTemplates () const =0
 Returns a list of strings that could be validly passed as templateName to LoadTemplate. More...
 
virtual void DisableValidation ()=0
 Permanently disable XML validation (intended solely for test cases). More...
 
- Public Member Functions inherited from IComponent
virtual ~IComponent ()
 
virtual void Init (const CParamNode &paramNode)=0
 
virtual void Deinit ()=0
 
virtual void HandleMessage (const CMessage &msg, bool global)
 
CEntityHandle GetEntityHandle () const
 
void SetEntityHandle (CEntityHandle ent)
 
entity_id_t GetEntityId () const
 
CEntityHandle GetSystemEntity () const
 
const CSimContextGetSimContext () const
 
void SetSimContext (const CSimContext &context)
 
virtual void Serialize (ISerializer &serialize)=0
 
virtual void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize)=0
 
virtual bool NewJSObject (const ScriptInterface &scriptInterface, JS::MutableHandleObject out) const
 Returns false by default, indicating that a scripted wrapper of this IComponent is not supported. More...
 
virtual JS::Value GetJSInstance () const
 
virtual int GetComponentTypeId () const =0
 

Static Public Member Functions

static void ClassInit (CComponentManager &componentManager)
 
static IComponentAllocate (const ScriptInterface &, JS::HandleValue)
 
static void Deallocate (IComponent *cmp)
 
static std::string GetSchema ()
 
- Static Public Member Functions inherited from IComponent
static std::string GetSchema ()
 
static void RegisterComponentType (CComponentManager &mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char *name, const std::string &schema)
 
static void RegisterComponentTypeScriptWrapper (CComponentManager &mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char *name, const std::string &schema)
 
static u8 GetSerializationVersion ()
 

Private Attributes

CTemplateLoader m_templateLoader
 
RelaxNGValidator m_Validator
 
bool m_DisableValidation
 
std::map< std::string, bool > m_TemplateSchemaValidity
 
std::map< entity_id_t, std::string > m_LatestTemplates
 

Additional Inherited Members

- Public Types inherited from IComponent
using AllocFunc = IComponent *(*)(const ScriptInterface &scriptInterface, JS::HandleValue ctor)
 
using DeallocFunc = void(*)(IComponent *)
 

Member Function Documentation

◆ Allocate()

static IComponent * CCmpTemplateManager::Allocate ( const ScriptInterface ,
JS::HandleValue   
)
inlinestatic

◆ ClassInit()

static void CCmpTemplateManager::ClassInit ( CComponentManager componentManager)
inlinestatic

◆ Deallocate()

static void CCmpTemplateManager::Deallocate ( IComponent cmp)
inlinestatic

◆ Deinit()

void CCmpTemplateManager::Deinit ( )
inlineoverridevirtual

Implements IComponent.

◆ Deserialize()

void CCmpTemplateManager::Deserialize ( const CParamNode paramNode,
IDeserializer deserialize 
)
inlineoverridevirtual

Implements IComponent.

◆ DisableValidation()

void CCmpTemplateManager::DisableValidation ( )
inlineoverridevirtual

Permanently disable XML validation (intended solely for test cases).

Implements ICmpTemplateManager.

◆ FindAllTemplates()

std::vector< std::string > CCmpTemplateManager::FindAllTemplates ( bool  includeActors) const
overridevirtual

Returns a list of strings that could be validly passed as templateName to LoadTemplate.

(This includes "actor|foo" etc names). Intended for use by the map editor. This is likely to be quite slow.

Implements ICmpTemplateManager.

◆ FindUsedTemplates()

std::vector< std::string > CCmpTemplateManager::FindUsedTemplates ( ) const
overridevirtual

Returns a list of strings that could be validly passed as templateName to LoadTemplate.

Intended for use by the AI manager.

Implements ICmpTemplateManager.

◆ GetCivData()

std::vector< std::vector< std::wstring > > CCmpTemplateManager::GetCivData ( )
overridevirtual

Returns some data of the civs from the templates.

Intended for use by the map editor.

Implements ICmpTemplateManager.

◆ GetComponentTypeId()

int CCmpTemplateManager::GetComponentTypeId ( ) const
inlineoverridevirtual

Implements IComponent.

◆ GetCurrentTemplateName()

std::string CCmpTemplateManager::GetCurrentTemplateName ( entity_id_t  ent) const
overridevirtual

Returns the name of the template most recently specified for the entity 'ent'.

Implements ICmpTemplateManager.

◆ GetEntitiesUsingTemplate()

std::vector< entity_id_t > CCmpTemplateManager::GetEntitiesUsingTemplate ( const std::string &  templateName) const
overridevirtual

Get the list of entities using the specified template.

Implements ICmpTemplateManager.

◆ GetSchema()

static std::string CCmpTemplateManager::GetSchema ( )
inlinestatic

◆ GetTemplate()

const CParamNode * CCmpTemplateManager::GetTemplate ( const std::string &  templateName)
overridevirtual

Loads the template XML file identified by 'templateName' (including inheritance from parent XML files).

The templateName syntax is the same as LoadTemplate.

Returns
NULL on error

Implements ICmpTemplateManager.

◆ GetTemplateWithoutValidation()

const CParamNode * CCmpTemplateManager::GetTemplateWithoutValidation ( const std::string &  templateName)
overridevirtual

Like GetTemplate, except without doing the XML validation (so it's faster but may return invalid templates).

Returns
NULL on error

Implements ICmpTemplateManager.

◆ HandleMessage()

void CCmpTemplateManager::HandleMessage ( const CMessage msg,
bool  global 
)
inlineoverridevirtual

Reimplemented from IComponent.

◆ Init()

void CCmpTemplateManager::Init ( const CParamNode paramNode)
inlineoverridevirtual

Implements IComponent.

◆ LoadLatestTemplate()

const CParamNode * CCmpTemplateManager::LoadLatestTemplate ( entity_id_t  ent)
overridevirtual

Returns the template most recently specified for the entity 'ent'.

Used during deserialization.

Returns
NULL on error

Implements ICmpTemplateManager.

◆ LoadTemplate()

const CParamNode * CCmpTemplateManager::LoadTemplate ( entity_id_t  ent,
const std::string &  templateName 
)
overridevirtual

Loads the template XML file identified by 'templateName' (including inheritance from parent XML files) for use with a new entity 'ent'.

The returned CParamNode must not be used for any entities other than 'ent'.

If templateName is of the form "actor|foo" then it will load a default stationary entity template that uses actor "foo". (This is a convenience to avoid the need for hundreds of tiny decorative-object entity templates.)

If templateName is of the form "preview|foo" then it will load a template based on entity template "foo" with the non-graphical components removed. (This is for previewing construction/placement of units.)

If templateName is of the form "corpse|foo" then it will load a template like "preview|foo" but with corpse-related components included.

If templateName is of the form "foundation|foo" then it will load a template based on entity template "foo" with various components removed and a few changed and added. (This is for constructing foundations of buildings.)

Returns
NULL on error

Implements ICmpTemplateManager.

◆ Serialize()

void CCmpTemplateManager::Serialize ( ISerializer serialize)
inlineoverridevirtual

Implements IComponent.

◆ TemplateExists()

bool CCmpTemplateManager::TemplateExists ( const std::string &  templateName) const
overridevirtual

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

Implements ICmpTemplateManager.

Member Data Documentation

◆ m_DisableValidation

bool CCmpTemplateManager::m_DisableValidation
private

◆ m_LatestTemplates

std::map<entity_id_t, std::string> CCmpTemplateManager::m_LatestTemplates
private

◆ m_templateLoader

CTemplateLoader CCmpTemplateManager::m_templateLoader
private

◆ m_TemplateSchemaValidity

std::map<std::string, bool> CCmpTemplateManager::m_TemplateSchemaValidity
private

◆ m_Validator

RelaxNGValidator CCmpTemplateManager::m_Validator
private

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