Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/system/ParamNode.h
Show All 26 Lines | |||||
#include <map> | #include <map> | ||||
#include <string> | #include <string> | ||||
class XMBFile; | class XMBFile; | ||||
class XMBElement; | class XMBElement; | ||||
class ScriptRequest; | class ScriptRequest; | ||||
class CTemplateLoader; | |||||
/** | /** | ||||
* An entity initialisation parameter node. | * An entity initialisation parameter node. | ||||
* Each node has a text value, plus a number of named child nodes (in a tree structure). | * Each node has a text value, plus a number of named child nodes (in a tree structure). | ||||
* Child nodes are unordered, and there cannot be more than one with the same name. | * Child nodes are unordered, and there cannot be more than one with the same name. | ||||
* Nodes are immutable. | * Nodes are immutable. | ||||
* | * | ||||
* Nodes can be initialised from XML files. Child elements are mapped onto child nodes. | * Nodes can be initialised from XML files. Child elements are mapped onto child nodes. | ||||
* Attributes are mapped onto child nodes with names prefixed by "@" | * Attributes are mapped onto child nodes with names prefixed by "@" | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | |||||
class CParamNode | class CParamNode | ||||
{ | { | ||||
public: | public: | ||||
typedef std::map<std::string, CParamNode> ChildrenMap; | typedef std::map<std::string, CParamNode> ChildrenMap; | ||||
/** | /** | ||||
* Constructs a new, empty node. | * Constructs a new, empty node. | ||||
*/ | */ | ||||
CParamNode(bool isOk = true); | CParamNode(CTemplateLoader* templateLoader, bool isOk = true); | ||||
/** | /** | ||||
* Loads the XML data specified by @a file into the node @a ret. | * Loads the XML data specified by @a file into the node @a ret. | ||||
* Any existing data in @a ret will be overwritten or else kept, so this | * Any existing data in @a ret will be overwritten or else kept, so this | ||||
* can be called multiple times to build up a node from multiple inputs. | * can be called multiple times to build up a node from multiple inputs. | ||||
* | * | ||||
* @param sourceIdentifier Optional; string you can pass along to indicate the source of | * @param sourceIdentifier Optional; string you can pass along to indicate the source of | ||||
* the data getting loaded. Used for output to log messages if an error occurs. | * the data getting loaded. Used for output to log messages if an error occurs. | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | private: | ||||
* Overlays the specified data onto this node. See class documentation for the concept and examples. | * Overlays the specified data onto this node. See class documentation for the concept and examples. | ||||
* | * | ||||
* @param xmb Representation of the XMB file containing an element with the data to apply. | * @param xmb Representation of the XMB file containing an element with the data to apply. | ||||
* @param element Element inside the specified @p xmb file containing the data to apply. | * @param element Element inside the specified @p xmb file containing the data to apply. | ||||
* @param sourceIdentifier Optional; string you can pass along to indicate the source of | * @param sourceIdentifier Optional; string you can pass along to indicate the source of | ||||
* the data getting applied. Used for output to log messages if an error occurs. | * the data getting applied. Used for output to log messages if an error occurs. | ||||
*/ | */ | ||||
void ApplyLayer(const XMBFile& xmb, const XMBElement& element, const wchar_t* sourceIdentifier = NULL); | void ApplyLayer(const XMBFile& xmb, const XMBElement& element, const wchar_t* sourceIdentifier = NULL); | ||||
void ApplyLayer(const CParamNode& node); | |||||
void ResetScriptVal(); | void ResetScriptVal(); | ||||
void ConstructJSVal(const ScriptRequest& rq, JS::MutableHandleValue ret) const; | void ConstructJSVal(const ScriptRequest& rq, JS::MutableHandleValue ret) const; | ||||
std::wstring m_Value; | std::wstring m_Value; | ||||
ChildrenMap m_Childs; | ChildrenMap m_Childs; | ||||
bool m_IsOk; | bool m_IsOk; | ||||
CTemplateLoader* m_TemplateLoader; | |||||
/** | /** | ||||
* Caches the ToJSVal script representation of this node. | * Caches the ToJSVal script representation of this node. | ||||
*/ | */ | ||||
mutable std::shared_ptr<JS::PersistentRootedValue> m_ScriptVal; | mutable std::shared_ptr<JS::PersistentRootedValue> m_ScriptVal; | ||||
}; | }; | ||||
#endif // INCLUDED_PARAMNODE | #endif // INCLUDED_PARAMNODE |
Wildfire Games · Phabricator