00001
00002
00003
00004
00005
00012 #ifndef _FCD_EXTRA_H_
00013 #define _FCD_EXTRA_H_
00014
00015 #include "FCDocument/FCDObject.h"
00016
00017 class FCDAnimated;
00018 class FCDAnimatedCustom;
00019 class FCDETechnique;
00020 class FCDENode;
00021
00026 struct FCDEAttribute
00027 {
00028 string name;
00029 fstring value;
00030 };
00031
00032 typedef vector<FCDETechnique*> FCDETechniqueList;
00033 typedef vector<FCDENode*> FCDENodeList;
00034 typedef vector<FCDEAttribute*> FCDEAttributeList;
00044 class FCOLLADA_EXPORT FCDExtra : public FCDObject
00045 {
00046 private:
00047 DeclareObjectType;
00048 FCDETechniqueList techniques;
00049
00050 public:
00054 FCDExtra(FCDocument* document);
00055
00058 virtual ~FCDExtra();
00059
00062 FCDETechniqueList& GetTechniques() { return techniques; }
00063 const FCDETechniqueList& GetTechniques() const { return techniques; }
00067 size_t GetTechniqueCount() const { return techniques.size(); }
00068
00073 FCDETechnique* GetTechnique(size_t index) { FUAssert(index < techniques.size(), return NULL); return techniques.at(index); }
00074 const FCDETechnique* GetTechnique(size_t index) const { FUAssert(index < techniques.size(), return NULL); return techniques.at(index); }
00081 FCDETechnique* AddTechnique(const char* profile);
00082 inline FCDETechnique* AddTechnique(const string& profile) { return AddTechnique(profile.c_str()); }
00086 void ReleaseTechnique(FCDETechnique* technique);
00087
00092 FCDETechnique* FindTechnique(const char* profile);
00093 const FCDETechnique* FindTechnique(const char* profile) const;
00094 inline FCDETechnique* FindTechnique(const string& profile) { return FindTechnique(profile.c_str()); }
00095 inline const FCDETechnique* FindTechnique(const string& profile) const { return FindTechnique(profile.c_str()); }
00103 FCDENode* FindRootNode(const char* name);
00104 const FCDENode* FindRootNode(const char* name) const;
00105 inline FCDENode* FindRootNode(const string& name) { return FindRootNode(name.c_str()); }
00106 inline const FCDENode* FindRootNode(const string& name) const { return FindRootNode(name.c_str()); }
00112 FUStatus LoadFromXML(xmlNode* extraNode);
00113
00117 xmlNode* WriteToXML(xmlNode* parentNode) const;
00118 };
00119
00129 class FCOLLADA_EXPORT FCDENode : public FCDObject
00130 {
00131 private:
00132 DeclareObjectType;
00133
00134 string name;
00135 fstring content;
00136
00137 FCDENode* parent;
00138 FCDENodeList children;
00139 FCDEAttributeList attributes;
00140
00141 FCDAnimatedCustom* animated;
00142
00143 public:
00148 FCDENode(FCDocument* document, FCDENode* parent);
00149
00154 virtual ~FCDENode();
00155
00158 void Release();
00159
00163 inline const char* GetName() const { return name.c_str(); }
00164
00168 inline void SetName(const char* _name) { name = _name; }
00169 inline void SetName(const string& _name) { name = _name; }
00175 const fchar* GetContent() const { return content.c_str(); }
00176
00181 void SetContent(const fchar* _content);
00182 inline void SetContent(const fstring& _content) { return SetContent(_content.c_str()); }
00188 FCDAnimatedCustom* GetAnimated() { return animated; }
00189 const FCDAnimatedCustom* GetAnimated() const { return animated; }
00196 FCDENode* GetParent() { return parent; }
00197 const FCDENode* GetParent() const { return parent; }
00201 FCDENodeList& GetChildNodes() { return children; }
00202 const FCDENodeList& GetChildNodes() const { return children; }
00206 size_t GetChildNodeCount() const { return children.size(); }
00207
00212 FCDENode* GetChildNode(size_t index) { FUAssert(index < children.size(), return NULL); return children.at(index); }
00213 const FCDENode* GetChildNode(size_t index) const { FUAssert(index < children.size(), return NULL); return children.at(index); }
00217 FCDENode* AddChildNode();
00218
00221 void ReleaseChildNode(FCDENode* childNode);
00222
00228 FCDENode* FindChildNode(const char* name);
00229 const FCDENode* FindChildNode(const char* name) const;
00230 inline FCDENode* FindChildNode(const string& name) { return FindChildNode(name.c_str()); }
00231 inline const FCDENode* FindChildNode(const string& name) const { return FindChildNode(name.c_str()); }
00242 FCDENode* FindParameter(const char* name);
00243
00251 void FindParameters(FCDENodeList& nodes, StringList& names);
00252
00255 FCDEAttributeList& GetAttributes() { return attributes; }
00256 const FCDEAttributeList& GetAttributes() const { return attributes; }
00260 size_t GetAttributeCount() const { return attributes.size(); }
00261
00266 FCDEAttribute* GetAttribute(size_t index) { FUAssert(index < attributes.size(), return NULL); return attributes.at(index); }
00267 const FCDEAttribute* GetAttribute(size_t index) const { FUAssert(index < attributes.size(), return NULL); return attributes.at(index); }
00275 FCDEAttribute* AddAttribute(const char* _name, const fchar* _value);
00276 inline FCDEAttribute* AddAttribute(const string& _name, const fchar* _value) { return AddAttribute(_name.c_str(), _value); }
00277 inline FCDEAttribute* AddAttribute(const char* _name, const fstring& _value) { return AddAttribute(_name, _value.c_str()); }
00278 inline FCDEAttribute* AddAttribute(const string& _name, const fstring& _value) { return AddAttribute(_name.c_str(), _value.c_str()); }
00279 template <typename T> inline FCDEAttribute* AddAttribute(const char* _name, const T& _value) { return AddAttribute(_name, TO_FSTRING(_value)); }
00280 template <typename T> inline FCDEAttribute* AddAttribute(const string& _name, const T& _value) { return AddAttribute(_name.c_str(), TO_FSTRING(_value)); }
00284 void ReleaseAttribute(FCDEAttribute* attribute);
00285
00291 FCDEAttribute* FindAttribute(const char* name);
00292 const FCDEAttribute* FindAttribute(const char* name) const;
00298 virtual FUStatus LoadFromXML(xmlNode* customNode);
00299
00303 virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
00304
00305 protected:
00311 FUStatus ReadChildrenFromXML(xmlNode* customNode);
00312
00316 void WriteChildrenToXML(xmlNode* customNode) const;
00317 };
00318
00328 class FCOLLADA_EXPORT FCDETechnique : public FCDENode
00329 {
00330 private:
00331 DeclareObjectType;
00332
00333 string profile;
00334
00335 public:
00340 FCDETechnique(FCDocument* document, const char* profile);
00341
00344 virtual ~FCDETechnique();
00345
00348 const char* GetProfile() const { return profile.c_str(); }
00349
00354 virtual FUStatus LoadFromXML(xmlNode* techniqueNode);
00355
00359 virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
00360 };
00361
00362 #endif // _FCD_EXTRA_H_