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 __domAccessor_h__
     10 #define __domAccessor_h__
     11 
     12 #include <dae/daeDocument.h>
     13 #include <dom/domTypes.h>
     14 #include <dom/domElements.h>
     15 
     16 #include <dom/domParam.h>
     17 class DAE;
     18 
     19 /**
     20  * The accessor element declares an access pattern to one of the array elements:
     21  * float_array,  int_array, Name_array, bool_array, and IDREF_array. The accessor
     22  * element describes access  to arrays that are organized in either an interleaved
     23  * or non-interleaved manner, depending  on the offset and stride attributes.
     24  */
     25 class domAccessor : public daeElement
     26 {
     27 public:
     28 	virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::ACCESSOR; }
     29 	static daeInt ID() { return 609; }
     30 	virtual daeInt typeID() const { return ID(); }
     31 protected:  // Attributes
     32 /**
     33  *  The count attribute indicates the number of times the array is accessed.
     34  * Required attribute.
     35  */
     36 	domUint attrCount;
     37 /**
     38  *  The offset attribute indicates the index of the first value to be read
     39  * from the array.  The default value is 0. Optional attribute.
     40  */
     41 	domUint attrOffset;
     42 /**
     43  *  The source attribute indicates the location of the array to access using
     44  * a URL expression. Required attribute.
     45  */
     46 	xsAnyURI attrSource;
     47 /**
     48  *  The stride attribute indicates number of values to be considered a unit
     49  * during each access to  the array. The default value is 1, indicating that
     50  * a single value is accessed. Optional attribute.
     51  */
     52 	domUint attrStride;
     53 
     54 protected:  // Element
     55 /**
     56  *  The accessor element may have any number of param elements.  @see domParam
     57  */
     58 	domParam_Array elemParam_array;
     59 
     60 public:	//Accessors and Mutators
     61 	/**
     62 	 * Gets the count attribute.
     63 	 * @return Returns a domUint of the count attribute.
     64 	 */
     65 	domUint getCount() const { return attrCount; }
     66 	/**
     67 	 * Sets the count attribute.
     68 	 * @param atCount The new value for the count attribute.
     69 	 */
     70 	void setCount( domUint atCount ) { attrCount = atCount; _validAttributeArray[0] = true; }
     71 
     72 	/**
     73 	 * Gets the offset attribute.
     74 	 * @return Returns a domUint of the offset attribute.
     75 	 */
     76 	domUint getOffset() const { return attrOffset; }
     77 	/**
     78 	 * Sets the offset attribute.
     79 	 * @param atOffset The new value for the offset attribute.
     80 	 */
     81 	void setOffset( domUint atOffset ) { attrOffset = atOffset; _validAttributeArray[1] = true; }
     82 
     83 	/**
     84 	 * Gets the source attribute.
     85 	 * @return Returns a xsAnyURI reference of the source attribute.
     86 	 */
     87 	xsAnyURI &getSource() { return attrSource; }
     88 	/**
     89 	 * Gets the source attribute.
     90 	 * @return Returns a constant xsAnyURI reference of the source attribute.
     91 	 */
     92 	const xsAnyURI &getSource() const { return attrSource; }
     93 	/**
     94 	 * Sets the source attribute.
     95 	 * @param atSource The new value for the source attribute.
     96 	 */
     97 	void setSource( const xsAnyURI &atSource ) { attrSource = atSource; _validAttributeArray[2] = true; }
     98 	/**
     99 	 * Sets the source attribute.
    100 	 * @param atSource The new value for the source attribute.
    101 	 */
    102 	void setSource( xsString atSource ) { attrSource = atSource; _validAttributeArray[2] = true; }
    103 
    104 	/**
    105 	 * Gets the stride attribute.
    106 	 * @return Returns a domUint of the stride attribute.
    107 	 */
    108 	domUint getStride() const { return attrStride; }
    109 	/**
    110 	 * Sets the stride attribute.
    111 	 * @param atStride The new value for the stride attribute.
    112 	 */
    113 	void setStride( domUint atStride ) { attrStride = atStride; _validAttributeArray[3] = true; }
    114 
    115 	/**
    116 	 * Gets the param element array.
    117 	 * @return Returns a reference to the array of param elements.
    118 	 */
    119 	domParam_Array &getParam_array() { return elemParam_array; }
    120 	/**
    121 	 * Gets the param element array.
    122 	 * @return Returns a constant reference to the array of param elements.
    123 	 */
    124 	const domParam_Array &getParam_array() const { return elemParam_array; }
    125 protected:
    126 	/**
    127 	 * Constructor
    128 	 */
    129 	domAccessor(DAE& dae) : daeElement(dae), attrCount(), attrOffset(), attrSource(dae, *this), attrStride(), elemParam_array() {}
    130 	/**
    131 	 * Destructor
    132 	 */
    133 	virtual ~domAccessor() {}
    134 	/**
    135 	 * Overloaded assignment operator
    136 	 */
    137 	virtual domAccessor &operator=( const domAccessor &cpy ) { (void)cpy; return *this; }
    138 
    139 public: // STATIC METHODS
    140 	/**
    141 	 * Creates an instance of this class and returns a daeElementRef referencing it.
    142 	 * @return a daeElementRef referencing an instance of this object.
    143 	 */
    144 	static DLLSPEC daeElementRef create(DAE& dae);
    145 	/**
    146 	 * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
    147 	 * If a daeMetaElement already exists it will return that instead of creating a new one.
    148 	 * @return A daeMetaElement describing this COLLADA element.
    149 	 */
    150 	static DLLSPEC daeMetaElement* registerElement(DAE& dae);
    151 };
    152 
    153 
    154 #endif
    155