domSource.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*
  2. * Copyright 2006 Sony Computer Entertainment Inc.
  3. *
  4. * Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
  5. * file except in compliance with the License. You may obtain a copy of the License at:
  6. * http://research.scea.com/scea_shared_source_license.html
  7. *
  8. * Unless required by applicable law or agreed to in writing, software distributed under the License
  9. * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10. * implied. See the License for the specific language governing permissions and limitations under the
  11. * License.
  12. */
  13. #ifndef __domSource_h__
  14. #define __domSource_h__
  15. #include <dae/daeDocument.h>
  16. #include <dom/domTypes.h>
  17. #include <dom/domElements.h>
  18. #include <dom/domAsset.h>
  19. #include <dom/domIDREF_array.h>
  20. #include <dom/domName_array.h>
  21. #include <dom/domBool_array.h>
  22. #include <dom/domFloat_array.h>
  23. #include <dom/domInt_array.h>
  24. #include <dom/domTechnique.h>
  25. #include <dom/domAccessor.h>
  26. class DAE;
  27. /**
  28. * The source element declares a data repository that provides values according
  29. * to the semantics of an input element that refers to it.
  30. */
  31. class domSource : public daeElement
  32. {
  33. public:
  34. virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::SOURCE; }
  35. static daeInt ID() { return 611; }
  36. virtual daeInt typeID() const { return ID(); }
  37. public:
  38. class domTechnique_common;
  39. typedef daeSmartRef<domTechnique_common> domTechnique_commonRef;
  40. typedef daeTArray<domTechnique_commonRef> domTechnique_common_Array;
  41. /**
  42. * The technique common specifies the common method for accessing this source
  43. * element's data.
  44. */
  45. class domTechnique_common : public daeElement
  46. {
  47. public:
  48. virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::TECHNIQUE_COMMON; }
  49. static daeInt ID() { return 612; }
  50. virtual daeInt typeID() const { return ID(); }
  51. protected: // Element
  52. /**
  53. * The source's technique_common must have one and only one accessor. @see
  54. * domAccessor
  55. */
  56. domAccessorRef elemAccessor;
  57. public: //Accessors and Mutators
  58. /**
  59. * Gets the accessor element.
  60. * @return a daeSmartRef to the accessor element.
  61. */
  62. const domAccessorRef getAccessor() const { return elemAccessor; }
  63. protected:
  64. /**
  65. * Constructor
  66. */
  67. domTechnique_common(DAE& dae) : daeElement(dae), elemAccessor() {}
  68. /**
  69. * Destructor
  70. */
  71. virtual ~domTechnique_common() {}
  72. /**
  73. * Overloaded assignment operator
  74. */
  75. virtual domTechnique_common &operator=( const domTechnique_common &cpy ) { (void)cpy; return *this; }
  76. public: // STATIC METHODS
  77. /**
  78. * Creates an instance of this class and returns a daeElementRef referencing it.
  79. * @return a daeElementRef referencing an instance of this object.
  80. */
  81. static DLLSPEC daeElementRef create(DAE& dae);
  82. /**
  83. * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
  84. * If a daeMetaElement already exists it will return that instead of creating a new one.
  85. * @return A daeMetaElement describing this COLLADA element.
  86. */
  87. static DLLSPEC daeMetaElement* registerElement(DAE& dae);
  88. };
  89. protected: // Attributes
  90. /**
  91. * The id attribute is a text string containing the unique identifier of
  92. * this element. This value must be unique within the instance document.
  93. * Required attribute.
  94. */
  95. xsID attrId;
  96. /**
  97. * The name attribute is the text string name of this element. Optional attribute.
  98. */
  99. xsNCName attrName;
  100. protected: // Elements
  101. /**
  102. * The source element may contain an asset element. @see domAsset
  103. */
  104. domAssetRef elemAsset;
  105. /**
  106. * The source element may contain an IDREF_array. @see domIDREF_array
  107. */
  108. domIDREF_arrayRef elemIDREF_array;
  109. /**
  110. * The source element may contain a Name_array. @see domName_array
  111. */
  112. domName_arrayRef elemName_array;
  113. /**
  114. * The source element may contain a bool_array. @see domBool_array
  115. */
  116. domBool_arrayRef elemBool_array;
  117. /**
  118. * The source element may contain a float_array. @see domFloat_array
  119. */
  120. domFloat_arrayRef elemFloat_array;
  121. /**
  122. * The source element may contain an int_array. @see domInt_array
  123. */
  124. domInt_arrayRef elemInt_array;
  125. /**
  126. * The technique common specifies the common method for accessing this source
  127. * element's data. @see domTechnique_common
  128. */
  129. domTechnique_commonRef elemTechnique_common;
  130. /**
  131. * This element may contain any number of non-common profile techniques.
  132. * @see domTechnique
  133. */
  134. domTechnique_Array elemTechnique_array;
  135. /**
  136. * Used to preserve order in elements that do not specify strict sequencing of sub-elements.
  137. */
  138. daeElementRefArray _contents;
  139. /**
  140. * Used to preserve order in elements that have a complex content model.
  141. */
  142. daeUIntArray _contentsOrder;
  143. /**
  144. * Used to store information needed for some content model objects.
  145. */
  146. daeTArray< daeCharArray * > _CMData;
  147. public: //Accessors and Mutators
  148. /**
  149. * Gets the id attribute.
  150. * @return Returns a xsID of the id attribute.
  151. */
  152. xsID getId() const { return attrId; }
  153. /**
  154. * Sets the id attribute.
  155. * @param atId The new value for the id attribute.
  156. */
  157. void setId( xsID atId ) { *(daeStringRef*)&attrId = atId; _validAttributeArray[0] = true;
  158. if( _document != NULL ) _document->changeElementID( this, attrId );
  159. }
  160. /**
  161. * Gets the name attribute.
  162. * @return Returns a xsNCName of the name attribute.
  163. */
  164. xsNCName getName() const { return attrName; }
  165. /**
  166. * Sets the name attribute.
  167. * @param atName The new value for the name attribute.
  168. */
  169. void setName( xsNCName atName ) { *(daeStringRef*)&attrName = atName; _validAttributeArray[1] = true; }
  170. /**
  171. * Gets the asset element.
  172. * @return a daeSmartRef to the asset element.
  173. */
  174. const domAssetRef getAsset() const { return elemAsset; }
  175. /**
  176. * Gets the IDREF_array element.
  177. * @return a daeSmartRef to the IDREF_array element.
  178. */
  179. const domIDREF_arrayRef getIDREF_array() const { return elemIDREF_array; }
  180. /**
  181. * Gets the Name_array element.
  182. * @return a daeSmartRef to the Name_array element.
  183. */
  184. const domName_arrayRef getName_array() const { return elemName_array; }
  185. /**
  186. * Gets the bool_array element.
  187. * @return a daeSmartRef to the bool_array element.
  188. */
  189. const domBool_arrayRef getBool_array() const { return elemBool_array; }
  190. /**
  191. * Gets the float_array element.
  192. * @return a daeSmartRef to the float_array element.
  193. */
  194. const domFloat_arrayRef getFloat_array() const { return elemFloat_array; }
  195. /**
  196. * Gets the int_array element.
  197. * @return a daeSmartRef to the int_array element.
  198. */
  199. const domInt_arrayRef getInt_array() const { return elemInt_array; }
  200. /**
  201. * Gets the technique_common element.
  202. * @return a daeSmartRef to the technique_common element.
  203. */
  204. const domTechnique_commonRef getTechnique_common() const { return elemTechnique_common; }
  205. /**
  206. * Gets the technique element array.
  207. * @return Returns a reference to the array of technique elements.
  208. */
  209. domTechnique_Array &getTechnique_array() { return elemTechnique_array; }
  210. /**
  211. * Gets the technique element array.
  212. * @return Returns a constant reference to the array of technique elements.
  213. */
  214. const domTechnique_Array &getTechnique_array() const { return elemTechnique_array; }
  215. /**
  216. * Gets the _contents array.
  217. * @return Returns a reference to the _contents element array.
  218. */
  219. daeElementRefArray &getContents() { return _contents; }
  220. /**
  221. * Gets the _contents array.
  222. * @return Returns a constant reference to the _contents element array.
  223. */
  224. const daeElementRefArray &getContents() const { return _contents; }
  225. protected:
  226. /**
  227. * Constructor
  228. */
  229. domSource(DAE& dae) : daeElement(dae), attrId(), attrName(), elemAsset(), elemIDREF_array(), elemName_array(), elemBool_array(), elemFloat_array(), elemInt_array(), elemTechnique_common(), elemTechnique_array() {}
  230. /**
  231. * Destructor
  232. */
  233. virtual ~domSource() { daeElement::deleteCMDataArray(_CMData); }
  234. /**
  235. * Overloaded assignment operator
  236. */
  237. virtual domSource &operator=( const domSource &cpy ) { (void)cpy; return *this; }
  238. public: // STATIC METHODS
  239. /**
  240. * Creates an instance of this class and returns a daeElementRef referencing it.
  241. * @return a daeElementRef referencing an instance of this object.
  242. */
  243. static DLLSPEC daeElementRef create(DAE& dae);
  244. /**
  245. * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
  246. * If a daeMetaElement already exists it will return that instead of creating a new one.
  247. * @return A daeMetaElement describing this COLLADA element.
  248. */
  249. static DLLSPEC daeMetaElement* registerElement(DAE& dae);
  250. };
  251. #endif