1 /*
2     Copyright (c) 2008-2009 NetAllied Systems GmbH
3 
4     This file is part of COLLADASaxFrameworkLoader.
5 
6     Licensed under the MIT Open Source License,
7     for details please see LICENSE file or the website
8     http://www.opensource.org/licenses/mit-license.php
9 */
10 
11 #ifndef __COLLADASAXFWL_ACCESSOR_H__
12 #define __COLLADASAXFWL_ACCESSOR_H__
13 
14 #include "COLLADASaxFWLPrerequisites.h"
15 
16 #include "COLLADAFWParam.h"
17 
18 #include "COLLADABUURI.h"
19 
20 
21 namespace COLLADASaxFWL
22 {
23 
24     /**
25      * Describes a stream of values from an array data source.
26      * The <accessor> element declares an access pattern into one of the array elements
27      * <float_array>, <int_array>, <Name_array>, <bool_array>, and <IDREF_array> or into an
28      * external array source. The arrays can be organized in either an interleaved or
29      * noninterleaved manner, depending on the offset and stride attributes.
30      * The output of the accessor is described by its child <param> elements.
31      */
32     class Accessor
33     {
34 
35     private:
36 
37         /**
38          *  The number of times the array is accessed. Required.
39          */
40         unsigned int mCount;
41 
42         /**
43          * The index of the first value to be read from the array. The default is 0. Optional.
44          */
45         unsigned int mOffset;
46 
47         /**
48          * The location of the array to access using a URI expression. Required. This element may
49          * refer to a COLLADA array element or to an array data source outside the scope of the
50          * instance document; the source does not need to be a COLLADA document.
51          */
52         COLLADABU::URI mSource;
53 
54         /**
55          * The number of values that are to be considered a unit during each access to the array.
56          * The default is 1, indicating that a single value is accessed. Optional.
57          */
58         unsigned int mStride;
59 
60         /**
61          * The type attribute of the <param> element, when it is a child of the <accessor> element,
62          * is restricted to the set of array types: int, float, Name, bool, and IDREF.
63          */
64         COLLADAFW::ParamArray mParamArray;
65 
66     public:
67 
68         /** Constructor. */
Accessor()69         Accessor () {}
70 
71         /** Destructor. */
~Accessor()72         virtual ~Accessor () {}
73 
74         /**
75         *  The number of times the array is accessed. Required.
76         */
getCount()77         const unsigned int getCount () const { return mCount; }
setCount(const unsigned int count)78         void setCount ( const unsigned int count ) { mCount = count; }
79 
80         /**
81         * The index of the first value to be read from the array. The default is 0. Optional.
82         */
getOffset()83         const unsigned int getOffset () const { return mOffset; }
setOffset(const unsigned int offset)84         void setOffset ( const unsigned int offset ) { mOffset = offset; }
85 
86         /**
87         * The location of the array to access using a URI expression. Required. This element may
88         * refer to a COLLADA array element or to an array data source outside the scope of the
89         * instance document; the source does not need to be a COLLADA document.
90         */
getSource()91         const COLLADABU::URI getSource () const { return mSource; }
setSource(const COLLADABU::URI source)92         void setSource ( const COLLADABU::URI source ) { mSource = source; }
93 
94         /**
95         * The number of values that are to be considered a unit during each access to the array.
96         * The default is 1, indicating that a single value is accessed. Optional.
97         */
getStride()98         const unsigned int getStride () const { return mStride; }
setStride(const unsigned int stride)99         void setStride ( const unsigned int stride ) { mStride = stride; }
100 
101         /**
102         * The type attribute of the <param> element, when it is a child of the <accessor> element,
103         * is restricted to the set of array types: int, float, Name, bool, and IDREF.
104         */
getParamArray()105         const COLLADAFW::ParamArray getParamArray () const { return mParamArray; }
106 
107         /**
108         * The type attribute of the <param> element, when it is a child of the <accessor> element,
109         * is restricted to the set of array types: int, float, Name, bool, and IDREF.
110         */
setParamArray(const COLLADAFW::ParamArray paramArray)111         void setParamArray ( const COLLADAFW::ParamArray paramArray )
112         {
113             mParamArray = paramArray;
114         }
115 
116     };
117 }
118 
119 #endif // __COLLADASAXFWL_ACCESSOR_H__
120