domAccessor.h 5.2 KB

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