Home | History | Annotate | Download | only in dom
      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 __domImage_h__
     10 #define __domImage_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/domExtra.h>
     18 class DAE;
     19 
     20 /**
     21  * The image element declares the storage for the graphical representation
     22  * of an object.  The image element best describes raster image data, but
     23  * can conceivably handle other  forms of imagery. The image elements allows
     24  * for specifying an external image file with  the init_from element or embed
     25  * image data with the data element.
     26  */
     27 class domImage : public daeElement
     28 {
     29 public:
     30 	virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::IMAGE; }
     31 	static daeInt ID() { return 635; }
     32 	virtual daeInt typeID() const { return ID(); }
     33 public:
     34 	class domData;
     35 
     36 	typedef daeSmartRef<domData> domDataRef;
     37 	typedef daeTArray<domDataRef> domData_Array;
     38 
     39 /**
     40  * The data child element contains a sequence of hexadecimal encoded  binary
     41  * octets representing  the embedded image data.
     42  */
     43 	class domData : public daeElement
     44 	{
     45 	public:
     46 		virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::DATA; }
     47 		static daeInt ID() { return 636; }
     48 		virtual daeInt typeID() const { return ID(); }
     49 
     50 	protected:  // Value
     51 		/**
     52 		 * The domListOfHexBinary value of the text data of this element.
     53 		 */
     54 		domListOfHexBinary _value;
     55 
     56 	public:	//Accessors and Mutators
     57 		/**
     58 		 * Gets the _value array.
     59 		 * @return Returns a domListOfHexBinary reference of the _value array.
     60 		 */
     61 		domListOfHexBinary &getValue() { return _value; }
     62 		/**
     63 		 * Gets the _value array.
     64 		 * @return Returns a constant domListOfHexBinary reference of the _value array.
     65 		 */
     66 		const domListOfHexBinary &getValue() const { return _value; }
     67 		/**
     68 		 * Sets the _value array.
     69 		 * @param val The new value for the _value array.
     70 		 */
     71 		void setValue( const domListOfHexBinary &val ) { _value = val; }
     72 
     73 	protected:
     74 		/**
     75 		 * Constructor
     76 		 */
     77 		domData(DAE& dae) : daeElement(dae), _value() {}
     78 		/**
     79 		 * Destructor
     80 		 */
     81 		virtual ~domData() {}
     82 		/**
     83 		 * Overloaded assignment operator
     84 		 */
     85 		virtual domData &operator=( const domData &cpy ) { (void)cpy; return *this; }
     86 
     87 	public: // STATIC METHODS
     88 		/**
     89 		 * Creates an instance of this class and returns a daeElementRef referencing it.
     90 		 * @return a daeElementRef referencing an instance of this object.
     91 		 */
     92 		static DLLSPEC daeElementRef create(DAE& dae);
     93 		/**
     94 		 * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
     95 		 * If a daeMetaElement already exists it will return that instead of creating a new one.
     96 		 * @return A daeMetaElement describing this COLLADA element.
     97 		 */
     98 		static DLLSPEC daeMetaElement* registerElement(DAE& dae);
     99 	};
    100 
    101 	class domInit_from;
    102 
    103 	typedef daeSmartRef<domInit_from> domInit_fromRef;
    104 	typedef daeTArray<domInit_fromRef> domInit_from_Array;
    105 
    106 /**
    107  * The init_from element allows you to specify an external image file to use
    108  * for the image element.
    109  */
    110 	class domInit_from : public daeElement
    111 	{
    112 	public:
    113 		virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::INIT_FROM; }
    114 		static daeInt ID() { return 637; }
    115 		virtual daeInt typeID() const { return ID(); }
    116 
    117 	protected:  // Value
    118 		/**
    119 		 * The xsAnyURI value of the text data of this element.
    120 		 */
    121 		xsAnyURI _value;
    122 
    123 	public:	//Accessors and Mutators
    124 		/**
    125 		 * Gets the value of this element.
    126 		 * @return Returns a xsAnyURI of the value.
    127 		 */
    128 		xsAnyURI &getValue() { return _value; }
    129 		/**
    130 		 * Gets the value of this element.
    131 		 * @return Returns a constant xsAnyURI of the value.
    132 		 */
    133 		const xsAnyURI &getValue() const { return _value; }
    134 		/**
    135 		 * Sets the _value of this element.
    136 		 * @param val The new value for this element.
    137 		 */
    138 		void setValue( const xsAnyURI &val ) { _value = val; }
    139 		/**
    140 		 * Sets the _value of this element.
    141 		 * @param val The new value for this element.
    142 		 */
    143 		void setValue( xsString val ) { _value = val; }
    144 
    145 	protected:
    146 		/**
    147 		 * Constructor
    148 		 */
    149 		domInit_from(DAE& dae) : daeElement(dae), _value(dae, *this) {}
    150 		/**
    151 		 * Destructor
    152 		 */
    153 		virtual ~domInit_from() {}
    154 		/**
    155 		 * Overloaded assignment operator
    156 		 */
    157 		virtual domInit_from &operator=( const domInit_from &cpy ) { (void)cpy; return *this; }
    158 
    159 	public: // STATIC METHODS
    160 		/**
    161 		 * Creates an instance of this class and returns a daeElementRef referencing it.
    162 		 * @return a daeElementRef referencing an instance of this object.
    163 		 */
    164 		static DLLSPEC daeElementRef create(DAE& dae);
    165 		/**
    166 		 * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
    167 		 * If a daeMetaElement already exists it will return that instead of creating a new one.
    168 		 * @return A daeMetaElement describing this COLLADA element.
    169 		 */
    170 		static DLLSPEC daeMetaElement* registerElement(DAE& dae);
    171 	};
    172 
    173 
    174 protected:  // Attributes
    175 /**
    176  *  The id attribute is a text string containing the unique identifier of
    177  * this element. This value  must be unique within the instance document.
    178  * Optional attribute.
    179  */
    180 	xsID attrId;
    181 /**
    182  *  The name attribute is the text string name of this element. Optional attribute.
    183  */
    184 	xsNCName attrName;
    185 /**
    186  *  The format attribute is a text string value that indicates the image format.
    187  * Optional attribute.
    188  */
    189 	xsToken attrFormat;
    190 /**
    191  *  The height attribute is an integer value that indicates the height of
    192  * the image in pixel  units. Optional attribute.
    193  */
    194 	domUint attrHeight;
    195 /**
    196  *  The width attribute is an integer value that indicates the width of the
    197  * image in pixel units.  Optional attribute.
    198  */
    199 	domUint attrWidth;
    200 /**
    201  *  The depth attribute is an integer value that indicates the depth of the
    202  * image in pixel units.  A 2-D image has a depth of 1, which is also the
    203  * default value. Optional attribute.
    204  */
    205 	domUint attrDepth;
    206 
    207 protected:  // Elements
    208 /**
    209  *  The image element may contain an asset element.  @see domAsset
    210  */
    211 	domAssetRef elemAsset;
    212 /**
    213  * The data child element contains a sequence of hexadecimal encoded  binary
    214  * octets representing  the embedded image data. @see domData
    215  */
    216 	domDataRef elemData;
    217 /**
    218  * The init_from element allows you to specify an external image file to use
    219  * for the image element. @see domInit_from
    220  */
    221 	domInit_fromRef elemInit_from;
    222 /**
    223  *  The extra element may appear any number of times.  @see domExtra
    224  */
    225 	domExtra_Array elemExtra_array;
    226 	/**
    227 	 * Used to preserve order in elements that do not specify strict sequencing of sub-elements.
    228 	 */
    229 	daeElementRefArray _contents;
    230 	/**
    231 	 * Used to preserve order in elements that have a complex content model.
    232 	 */
    233 	daeUIntArray       _contentsOrder;
    234 
    235 	/**
    236 	 * Used to store information needed for some content model objects.
    237 	 */
    238 	daeTArray< daeCharArray * > _CMData;
    239 
    240 
    241 public:	//Accessors and Mutators
    242 	/**
    243 	 * Gets the id attribute.
    244 	 * @return Returns a xsID of the id attribute.
    245 	 */
    246 	xsID getId() const { return attrId; }
    247 	/**
    248 	 * Sets the id attribute.
    249 	 * @param atId The new value for the id attribute.
    250 	 */
    251 	void setId( xsID atId ) { *(daeStringRef*)&attrId = atId; _validAttributeArray[0] = true;
    252 		if( _document != NULL ) _document->changeElementID( this, attrId );
    253 	}
    254 
    255 	/**
    256 	 * Gets the name attribute.
    257 	 * @return Returns a xsNCName of the name attribute.
    258 	 */
    259 	xsNCName getName() const { return attrName; }
    260 	/**
    261 	 * Sets the name attribute.
    262 	 * @param atName The new value for the name attribute.
    263 	 */
    264 	void setName( xsNCName atName ) { *(daeStringRef*)&attrName = atName; _validAttributeArray[1] = true; }
    265 
    266 	/**
    267 	 * Gets the format attribute.
    268 	 * @return Returns a xsToken of the format attribute.
    269 	 */
    270 	xsToken getFormat() const { return attrFormat; }
    271 	/**
    272 	 * Sets the format attribute.
    273 	 * @param atFormat The new value for the format attribute.
    274 	 */
    275 	void setFormat( xsToken atFormat ) { *(daeStringRef*)&attrFormat = atFormat; _validAttributeArray[2] = true; }
    276 
    277 	/**
    278 	 * Gets the height attribute.
    279 	 * @return Returns a domUint of the height attribute.
    280 	 */
    281 	domUint getHeight() const { return attrHeight; }
    282 	/**
    283 	 * Sets the height attribute.
    284 	 * @param atHeight The new value for the height attribute.
    285 	 */
    286 	void setHeight( domUint atHeight ) { attrHeight = atHeight; _validAttributeArray[3] = true; }
    287 
    288 	/**
    289 	 * Gets the width attribute.
    290 	 * @return Returns a domUint of the width attribute.
    291 	 */
    292 	domUint getWidth() const { return attrWidth; }
    293 	/**
    294 	 * Sets the width attribute.
    295 	 * @param atWidth The new value for the width attribute.
    296 	 */
    297 	void setWidth( domUint atWidth ) { attrWidth = atWidth; _validAttributeArray[4] = true; }
    298 
    299 	/**
    300 	 * Gets the depth attribute.
    301 	 * @return Returns a domUint of the depth attribute.
    302 	 */
    303 	domUint getDepth() const { return attrDepth; }
    304 	/**
    305 	 * Sets the depth attribute.
    306 	 * @param atDepth The new value for the depth attribute.
    307 	 */
    308 	void setDepth( domUint atDepth ) { attrDepth = atDepth; _validAttributeArray[5] = true; }
    309 
    310 	/**
    311 	 * Gets the asset element.
    312 	 * @return a daeSmartRef to the asset element.
    313 	 */
    314 	const domAssetRef getAsset() const { return elemAsset; }
    315 	/**
    316 	 * Gets the data element.
    317 	 * @return a daeSmartRef to the data element.
    318 	 */
    319 	const domDataRef getData() const { return elemData; }
    320 	/**
    321 	 * Gets the init_from element.
    322 	 * @return a daeSmartRef to the init_from element.
    323 	 */
    324 	const domInit_fromRef getInit_from() const { return elemInit_from; }
    325 	/**
    326 	 * Gets the extra element array.
    327 	 * @return Returns a reference to the array of extra elements.
    328 	 */
    329 	domExtra_Array &getExtra_array() { return elemExtra_array; }
    330 	/**
    331 	 * Gets the extra element array.
    332 	 * @return Returns a constant reference to the array of extra elements.
    333 	 */
    334 	const domExtra_Array &getExtra_array() const { return elemExtra_array; }
    335 	/**
    336 	 * Gets the _contents array.
    337 	 * @return Returns a reference to the _contents element array.
    338 	 */
    339 	daeElementRefArray &getContents() { return _contents; }
    340 	/**
    341 	 * Gets the _contents array.
    342 	 * @return Returns a constant reference to the _contents element array.
    343 	 */
    344 	const daeElementRefArray &getContents() const { return _contents; }
    345 
    346 protected:
    347 	/**
    348 	 * Constructor
    349 	 */
    350 	domImage(DAE& dae) : daeElement(dae), attrId(), attrName(), attrFormat(), attrHeight(), attrWidth(), attrDepth(), elemAsset(), elemData(), elemInit_from(), elemExtra_array() {}
    351 	/**
    352 	 * Destructor
    353 	 */
    354 	virtual ~domImage() { daeElement::deleteCMDataArray(_CMData); }
    355 	/**
    356 	 * Overloaded assignment operator
    357 	 */
    358 	virtual domImage &operator=( const domImage &cpy ) { (void)cpy; return *this; }
    359 
    360 public: // STATIC METHODS
    361 	/**
    362 	 * Creates an instance of this class and returns a daeElementRef referencing it.
    363 	 * @return a daeElementRef referencing an instance of this object.
    364 	 */
    365 	static DLLSPEC daeElementRef create(DAE& dae);
    366 	/**
    367 	 * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
    368 	 * If a daeMetaElement already exists it will return that instead of creating a new one.
    369 	 * @return A daeMetaElement describing this COLLADA element.
    370 	 */
    371 	static DLLSPEC daeMetaElement* registerElement(DAE& dae);
    372 };
    373 
    374 
    375 #endif
    376