- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# FCDocument/FCDExtra.h

Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2005-2007 Feeling Software Inc.
    00003     Portions of the code are:
    00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
    00005
    00006     MIT License: http://www.opensource.org/licenses/mit-license.php
    00007 */
    00008
    00015 #ifndef _FCD_EXTRA_H_
    00016 #define _FCD_EXTRA_H_
    00017
    00018 #ifndef __FCD_OBJECT_H_
    00019 #include "FCDocument/FCDObject.h"
    00020 #endif // __FCD_OBJECT_H_
    00021 #ifndef _FU_PARAMETER_H_
    00022 #include "FUtils/FUParameter.h"
    00023 #endif // _FU_PARAMETER_H_
    00024
    00025 class FCDAnimated;
    00026 class FCDAnimatedCustom;
    00027 class FCDEAttribute;
    00028 class FCDETechnique;
    00029 class FCDEType;
    00030 class FCDENode;
    00031
    00032 typedef fm::pvector<FCDENode> FCDENodeList;
    00042 class FCOLLADA_EXPORT FCDExtra : public FCDObject
    00043 {
    00044 private:
    00045     DeclareObjectType(FCDObject);
    00046
    00047     FUObject* parent;
    00048     DeclareParameterContainer(FCDEType, types, FC("Extra Types"));
    00049
    00050 public:
    00056     FCDExtra(FCDocument* document, FUObject* parent);
    00057
    00059     virtual ~FCDExtra();
    00060
    00063     inline FUObject* GetParent() { return parent; }
    00064     inline const FUObject* GetParent() const { return parent; }
    00068     DEPRECATED(3.05A, GetTypeCount and GetType(index)) inline void GetTypes() const {}
    00069
    00072     size_t GetTypeCount() const { return types.size(); }
    00073
    00078     inline FCDEType* GetDefaultType() { return const_cast<FCDEType*>(const_cast<const FCDExtra*>(this)->GetDefaultType()); }
    00079     inline const FCDEType* GetDefaultType() const { return FindType(""); }
    00084     inline FCDEType* GetType(size_t index) { FUAssert(index < types.size(), return NULL); return types.at(index); }
    00085     inline const FCDEType* GetType(size_t index) const { FUAssert(index < types.size(), return NULL); return types.at(index); }
    00092     FCDEType* AddType(const char* name);
    00093     inline FCDEType* AddType(const fm::string& name) { return AddType(name.c_str()); }
    00099     inline FCDEType* FindType(const char* name) { return const_cast<FCDEType*>(const_cast<const FCDExtra*>(this)->FindType(name)); }
    00100     const FCDEType* FindType(const char* name) const;
    00101     inline FCDEType* FindType(const fm::string& name) { return FindType(name.c_str()); }
    00102     inline const FCDEType* FindType(const fm::string& name) const { return FindType(name.c_str()); }
    00108     bool HasContent() const;
    00109
    00115     FCDExtra* Clone(FCDExtra* clone = NULL) const;
    00116 };
    00117
    00126 class FCOLLADA_EXPORT FCDEType : public FCDObject
    00127 {
    00128 private:
    00129     DeclareObjectType(FCDObject);
    00130
    00131     FCDExtra* parent;
    00132     DeclareParameter(fm::string, FUParameterQualifiers::SIMPLE, name, FC("Type name"));
    00133     DeclareParameterContainer(FCDETechnique, techniques, FC("Profile-specific Techniques"));
    00134
    00135 public:
    00141     FCDEType(FCDocument* document, FCDExtra* parent, const char* type);
    00142
    00144     virtual ~FCDEType();
    00145
    00148     inline FCDExtra* GetParent() { return parent; }
    00149     inline const FCDExtra* GetParent() const { return parent; }
    00153     inline const fm::string& GetName() const { return name; }
    00154
    00159     inline void SetName(const fm::string& _name) { name = _name; }
    00160
    00163     DEPRECATED(3.05A, GetTechniqueCount and GetTechnique(index)) inline void GetTechniques() const {}
    00164
    00167     inline size_t GetTechniqueCount() const { return techniques.size(); }
    00168
    00173     inline FCDETechnique* GetTechnique(size_t index) { FUAssert(index < techniques.size(), return NULL); return techniques.at(index); }
    00174     inline const FCDETechnique* GetTechnique(size_t index) const { FUAssert(index < techniques.size(), return NULL); return techniques.at(index); }
    00181     FCDETechnique* AddTechnique(const char* profile);
    00182     inline FCDETechnique* AddTechnique(const fm::string& profile) { return AddTechnique(profile.c_str()); }
    00188     FCDETechnique* FindTechnique(const char* profile) { return const_cast<FCDETechnique*>(const_cast<const FCDEType*>(this)->FindTechnique(profile)); }
    00189     const FCDETechnique* FindTechnique(const char* profile) const;
    00190     inline FCDETechnique* FindTechnique(const fm::string& profile) { return FindTechnique(profile.c_str()); }
    00191     inline const FCDETechnique* FindTechnique(const fm::string& profile) const { return FindTechnique(profile.c_str()); }
    00199     inline FCDENode* FindRootNode(const char* name) { return const_cast<FCDENode*>(const_cast<const FCDEType*>(this)->FindRootNode(name)); }
    00200     const FCDENode* FindRootNode(const char* name) const;
    00201     inline FCDENode* FindRootNode(const fm::string& name) { return FindRootNode(name.c_str()); }
    00202     inline const FCDENode* FindRootNode(const fm::string& name) const { return FindRootNode(name.c_str()); }
    00209     FCDEType* Clone(FCDEType* clone = NULL) const;
    00210 };
    00211
    00221 class FCOLLADA_EXPORT FCDENode : public FCDObject
    00222 {
    00223 private:
    00224     DeclareObjectType(FCDObject);
    00225
    00226     FCDENode* parent;
    00227     DeclareParameter(fm::string, FUParameterQualifiers::SIMPLE, name, FC("Node name"));
    00228     DeclareParameter(fstring, FUParameterQualifiers::SIMPLE, content, FC("Node content"));
    00229
    00230     DeclareParameterContainer(FCDENode, children, FC("Children"));
    00231     DeclareParameterContainer(FCDEAttribute, attributes, FC("Attributes"));
    00232
    00233     DeclareParameterRef(FCDAnimatedCustom, animated, FC("Custom Animatable"));
    00234
    00235 public:
    00240     FCDENode(FCDocument* document, FCDENode* parent);
    00241
    00243     virtual ~FCDENode();
    00244
    00248     inline const char* GetName() const { return name->c_str(); }
    00249
    00253     inline void SetName(const char* _name) { fm::string n = _name; SetName(n); }
    00254     inline void SetName(const fm::string& _name) { fm::string n = _name; SetName(n); }
    00255     void SetName(fm::string& _name);
    00256
    00261     static void CleanName(fm::string& n);
    00262
    00267     const fchar* GetContent() const;
    00268
    00273     void SetContent(const fchar* _content);
    00274     inline void SetContent(const fstring& _content) { return SetContent(_content.c_str()); }
    00279     void SetContentDirect(const fstring& _content) { content = _content; }
    00280
    00285     FCDAnimatedCustom* GetAnimated() { return animated; }
    00286     const FCDAnimatedCustom* GetAnimated() const { return animated; }
    00291     void SetAnimated(FCDAnimatedCustom* animatedCustom);
    00292
    00298     FCDENode* GetParent() { return parent; }
    00299     const FCDENode* GetParent() const { return parent; }
    00303     DEPRECATED(3.05A, GetChildNodeCount and GetChildNode(index)) void GetChildNodes() const {}
    00304
    00307     size_t GetChildNodeCount() const { return children.size(); }
    00308
    00313     FCDENode* GetChildNode(size_t index) { FUAssert(index < children.size(), return NULL); return children.at(index); }
    00314     const FCDENode* GetChildNode(size_t index) const { FUAssert(index < children.size(), return NULL); return children.at(index); }
    00319     FCDENode* AddChildNode();
    00320
    00325     FCDENode* AddChildNode(const char* name);
    00326     inline FCDENode* AddChildNode(const fm::string& name) { return AddChildNode(name.c_str()); }
    00333     inline FCDENode* FindChildNode(const char* name) { return const_cast<FCDENode*>(const_cast<const FCDENode*>(this)->FindChildNode(name)); }
    00334     const FCDENode* FindChildNode(const char* name) const;
    00335     inline FCDENode* FindChildNode(const fm::string& name) { return FindChildNode(name.c_str()); }
    00336     inline const FCDENode* FindChildNode(const fm::string& name) const { return FindChildNode(name.c_str()); }
    00342     void FindChildrenNodes(const char* name, FCDENodeList& nodes) const;
    00343     inline void FindChildrenNodes(const fm::string& name, FCDENodeList& nodes) const { FindChildrenNodes(name.c_str(), nodes); }
    00351     const FCDENode* FindParameter(const char* name) const;
    00352     inline FCDENode* FindParameter(const char* name) { return const_cast<FCDENode*>(const_cast<const FCDENode*>(this)->FindParameter(name)); }
    00359     void FindParameters(FCDENodeList& nodes, StringList& names);
    00360
    00363     DEPRECATED(3.05A, GetAttributeCount and GetAttribute(index)) void GetAttributes() const {}
    00364
    00367     size_t GetAttributeCount() const { return attributes.size(); }
    00368
    00373     FCDEAttribute* GetAttribute(size_t index) { FUAssert(index < attributes.size(), return NULL); return attributes.at(index); }
    00374     const FCDEAttribute* GetAttribute(size_t index) const { FUAssert(index < attributes.size(), return NULL); return attributes.at(index); }
    00383     FCDEAttribute* AddAttribute(fm::string& _name, const fchar* _value);
    00384     inline FCDEAttribute* AddAttribute(const char* _name, const fchar* _value) { fm::string n = _name; return AddAttribute(n, _value); }
    00385     inline FCDEAttribute* AddAttribute(const fm::string& _name, const fchar* _value) { fm::string n = _name; return AddAttribute(n, _value); }
    00386     inline FCDEAttribute* AddAttribute(const char* _name, const fstring& _value) { fm::string n = _name; return AddAttribute(n, _value.c_str()); }
    00387     inline FCDEAttribute* AddAttribute(fm::string& _name, const fstring& _value) { return AddAttribute(_name, _value.c_str()); }
    00388     inline FCDEAttribute* AddAttribute(const fm::string& _name, const fstring& _value) { fm::string n = _name; return AddAttribute(n, _value.c_str()); }
    00389     template <typename T> inline FCDEAttribute* AddAttribute(const char* _name, const T& _value) { fm::string n = _name; return AddAttribute(n, TO_FSTRING(_value)); }
    00390     template <typename T> inline FCDEAttribute* AddAttribute(fm::string& _name, const T& _value) { return AddAttribute(_name, TO_FSTRING(_value)); }
    00391     template <typename T> inline FCDEAttribute* AddAttribute(const fm::string& _name, const T& _value) { fm::string n = _name; return AddAttribute(n, TO_FSTRING(_value)); }
    00398     inline FCDEAttribute* FindAttribute(const char* name) { return const_cast<FCDEAttribute*>(const_cast<const FCDENode*>(this)->FindAttribute(name)); }
    00399     const FCDEAttribute* FindAttribute(const char* name) const;
    00406     const fstring& ReadAttribute(const char* name) const;
    00407
    00414     FCDENode* AddParameter(const char* name, const fchar* value);
    00415     inline FCDENode* AddParameter(const fm::string& name, const fchar* value) { return AddParameter(name.c_str(), value); }
    00416     inline FCDENode* AddParameter(const char* name, const fstring& value) { return AddParameter(name, value.c_str()); }
    00417     inline FCDENode* AddParameter(const fm::string& name, const fstring& value) { return AddParameter(name.c_str(), value.c_str()); }
    00418     template <class T>
    00419     inline FCDENode* AddParameter(const char* name, const T& value) { return AddParameter(name, TO_FSTRING(value)); }
    00420     template <class T>
    00421     inline FCDENode* AddParameter(const fm::string& name, const T& value) { return AddParameter(name.c_str(), TO_FSTRING(value)); }
    00427     virtual FCDENode* Clone(FCDENode* clone) const;
    00428 };
    00429
    00439 class FCOLLADA_EXPORT FCDETechnique : public FCDENode
    00440 {
    00441 private:
    00442     DeclareObjectType(FCDENode);
    00443
    00444     FCDEType* parent;
    00445     DeclareParameterPtr(FUTrackable, pluginOverride, FC("Plug-in Override Object"));
    00446     DeclareParameter(fm::string, FUParameterQualifiers::SIMPLE, profile, FC("Profile Name"));
    00447
    00448 public:
    00454     FCDETechnique(FCDocument* document, FCDEType* parent, const char* profile);
    00455
    00457     virtual ~FCDETechnique();
    00458
    00461     const char* GetProfile() const { return profile->c_str(); }
    00462
    00468     void SetProfile(const fm::string& _profile) { profile = _profile; }
    00469
    00474     FUTrackable* GetPluginObject() { return pluginOverride; }
    00475     const FUTrackable* GetPluginObject() const { return pluginOverride; }
    00478     void SetPluginObject(FUTrackable* plugin) { pluginOverride = plugin; }
    00479
    00485     virtual FCDENode* Clone(FCDENode* clone) const;
    00486 };
    00487
    00492 class FCDEAttribute : public FUParameterizable
    00493 {
    00494 private:
    00495     DeclareParameter(fm::string, FUParameterQualifiers::SIMPLE, name, FC("Attribute Name"));
    00496     DeclareParameter(fstring, FUParameterQualifiers::SIMPLE, value, FC("Attribute Value"));
    00498 public:
    00501     FCDEAttribute();
    00502
    00507     FCDEAttribute(const char* name, const fchar* value);
    00508
    00511     inline const fm::string& GetName() const { return name; }
    00512
    00515     inline void SetName(const fm::string& _name) { name = _name; }
    00516
    00519     inline const fstring& GetValue() const { return value; }
    00520
    00523     inline void SetValue(const fstring& _value) { value = _value; }
    00524 };
    00525
    00526 #endif // _FCD_EXTRA_H_