Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
CCmpTemplateManager Class Reference
Inheritance diagram for CCmpTemplateManager:
ICmpTemplateManager IComponent

Public Member Functions

virtual void Init (const CParamNode &paramNode)
 
virtual void Deinit ()
 
virtual void Serialize (ISerializer &serialize)
 
virtual void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize)
 
virtual void HandleMessage (const CMessage &msg, bool global)
 
virtual void DisableValidation ()
 Permanently disable XML validation (intended solely for test cases). More...
 
virtual const CParamNodeLoadTemplate (entity_id_t ent, const std::string &templateName, int playerID)
 Loads the template XML file identified by 'templateName' (including inheritance from parent XML files), and applies the techs that are currently active for player 'playerID', for use with a new entity 'ent'. More...
 
virtual const CParamNodeGetTemplate (std::string templateName)
 Loads the template XML file identified by 'templateName' (including inheritance from parent XML files). More...
 
virtual const CParamNodeGetTemplateWithoutValidation (std::string templateName)
 Like GetTemplate, except without doing the XML validation (so it's faster but may return invalid templates). More...
 
virtual const CParamNodeLoadLatestTemplate (entity_id_t ent)
 Returns the template most recently specified for the entity 'ent'. More...
 
virtual std::string GetCurrentTemplateName (entity_id_t ent)
 Returns the name of the template most recently specified for the entity 'ent'. More...
 
virtual std::vector< std::string > FindAllTemplates (bool includeActors)
 Returns a list of strings that could be validly passed as templateName to LoadTemplate. More...
 
virtual std::vector< entity_id_tGetEntitiesUsingTemplate (std::string templateName)
 Get the list of entities using the specified template. More...
 
- Public Member Functions inherited from IComponent
virtual ~IComponent ()
 
CEntityHandle GetEntityHandle () const
 
void SetEntityHandle (CEntityHandle ent)
 
entity_id_t GetEntityId () const
 
CEntityHandle GetSystemEntity () const
 
const CSimContextGetSimContext () const
 
void SetSimContext (const CSimContext &context)
 
virtual JSClass * GetJSClass () const
 
virtual jsval GetJSInstance () const
 

Static Public Member Functions

static void ClassInit (CComponentManager &componentManager)
 
static IComponentAllocate (ScriptInterface &, jsval)
 
static void Deallocate (IComponent *cmp)
 
static std::string GetSchema ()
 
- Static Public Member Functions inherited from IComponent
static std::string GetSchema ()
 
static u8 GetSerializationVersion ()
 

Private Member Functions

bool LoadTemplateFile (const std::string &templateName, int depth)
 
void ConstructTemplateActor (const std::string &actorName, CParamNode &out)
 
void CopyPreviewSubset (CParamNode &out, const CParamNode &in, bool corpse)
 
void CopyFoundationSubset (CParamNode &out, const CParamNode &in)
 
void CopyConstructionSubset (CParamNode &out, const CParamNode &in)
 
void CopyResourceSubset (CParamNode &out, const CParamNode &in)
 

Private Attributes

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

Detailed Description

Definition at line 34 of file CCmpTemplateManager.cpp.

Member Function Documentation

static IComponent* CCmpTemplateManager::Allocate ( ScriptInterface ,
jsval   
)
inlinestatic

Definition at line 42 of file CCmpTemplateManager.cpp.

static void CCmpTemplateManager::ClassInit ( CComponentManager componentManager)
inlinestatic

Definition at line 37 of file CCmpTemplateManager.cpp.

void CCmpTemplateManager::ConstructTemplateActor ( const std::string &  actorName,
CParamNode out 
)
private

Definition at line 403 of file CCmpTemplateManager.cpp.

void CCmpTemplateManager::CopyConstructionSubset ( CParamNode out,
const CParamNode in 
)
private

Definition at line 602 of file CCmpTemplateManager.cpp.

void CCmpTemplateManager::CopyFoundationSubset ( CParamNode out,
const CParamNode in 
)
private

Definition at line 550 of file CCmpTemplateManager.cpp.

void CCmpTemplateManager::CopyPreviewSubset ( CParamNode out,
const CParamNode in,
bool  corpse 
)
private

Definition at line 498 of file CCmpTemplateManager.cpp.

void CCmpTemplateManager::CopyResourceSubset ( CParamNode out,
const CParamNode in 
)
private

Definition at line 617 of file CCmpTemplateManager.cpp.

static void CCmpTemplateManager::Deallocate ( IComponent cmp)
inlinestatic

Definition at line 42 of file CCmpTemplateManager.cpp.

virtual void CCmpTemplateManager::Deinit ( )
inlinevirtual

Implements IComponent.

Definition at line 58 of file CCmpTemplateManager.cpp.

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

Implements IComponent.

Definition at line 87 of file CCmpTemplateManager.cpp.

virtual void CCmpTemplateManager::DisableValidation ( )
inlinevirtual

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

Implements ICmpTemplateManager.

Definition at line 119 of file CCmpTemplateManager.cpp.

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

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.

Definition at line 460 of file CCmpTemplateManager.cpp.

std::string CCmpTemplateManager::GetCurrentTemplateName ( entity_id_t  ent)
virtual

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

Implements ICmpTemplateManager.

Definition at line 262 of file CCmpTemplateManager.cpp.

std::vector< entity_id_t > CCmpTemplateManager::GetEntitiesUsingTemplate ( std::string  templateName)
virtual

Get the list of entities using the specified template.

Implements ICmpTemplateManager.

Definition at line 487 of file CCmpTemplateManager.cpp.

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

Definition at line 44 of file CCmpTemplateManager.cpp.

const CParamNode * CCmpTemplateManager::GetTemplate ( std::string  templateName)
virtual

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.

Definition at line 202 of file CCmpTemplateManager.cpp.

const CParamNode * CCmpTemplateManager::GetTemplateWithoutValidation ( std::string  templateName)
virtual

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

Returns
NULL on error

Implements ICmpTemplateManager.

Definition at line 238 of file CCmpTemplateManager.cpp.

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

Reimplemented from IComponent.

Definition at line 103 of file CCmpTemplateManager.cpp.

virtual void CCmpTemplateManager::Init ( const CParamNode paramNode)
inlinevirtual

Implements IComponent.

Definition at line 49 of file CCmpTemplateManager.cpp.

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

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

Used during deserialization.

Returns
NULL on error

Implements ICmpTemplateManager.

Definition at line 254 of file CCmpTemplateManager.cpp.

const CParamNode * CCmpTemplateManager::LoadTemplate ( entity_id_t  ent,
const std::string &  templateName,
int  playerID 
)
virtual

Loads the template XML file identified by 'templateName' (including inheritance from parent XML files), and applies the techs that are currently active for player 'playerID', 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.

Definition at line 189 of file CCmpTemplateManager.cpp.

bool CCmpTemplateManager::LoadTemplateFile ( const std::string &  templateName,
int  depth 
)
private

Definition at line 270 of file CCmpTemplateManager.cpp.

virtual void CCmpTemplateManager::Serialize ( ISerializer serialize)
inlinevirtual

Implements IComponent.

Definition at line 62 of file CCmpTemplateManager.cpp.

Member Data Documentation

bool CCmpTemplateManager::m_DisableValidation
private

Definition at line 143 of file CCmpTemplateManager.cpp.

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

Definition at line 159 of file CCmpTemplateManager.cpp.

std::map<std::string, CParamNode> CCmpTemplateManager::m_TemplateFileData
private

Definition at line 149 of file CCmpTemplateManager.cpp.

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

Definition at line 154 of file CCmpTemplateManager.cpp.

RelaxNGValidator CCmpTemplateManager::m_Validator
private

Definition at line 140 of file CCmpTemplateManager.cpp.


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