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