HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_DASubArray.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GT_DASubArray.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_DASubArray__
12 #define __GT_DASubArray__
13 
14 #include "GT_API.h"
15 #include "GT_DAInherit.h"
16 
17 #include <UT/UT_ValArray.h>
18 
19 /// @brief A slice of a different data array
21 public:
22  /// Default constructor
24  : mySize(0)
25  , myStart(0)
26  , GT_DAInherit()
27  {
28  }
29  /// Useful constructor
31  : mySize(size)
32  , myStart(start)
33  , GT_DAInherit(data)
34  {
35  }
36  /// Copy constructor
38  : mySize(src.mySize)
39  , myStart(src.myStart)
40  , GT_DAInherit(src)
41  {
42  }
43  /// Destructor
44  ~GT_DASubArray() override;
45 
46  const char *className() const override { return "GT_DASubArray"; }
47 
48  /// Initialize with given data
51  {
52  GT_DAInherit::init(data);
53  myStart = start;
54  mySize = size;
55  }
56 
57  GT_Size itemSize(GT_Offset offset) const override
58  { return myData->itemSize(this->getIndirect(offset)); }
59  GT_Size getTotalArrayEntries() const override
60  {
61  GT_Size sum = 0;
62  for (GT_Size off = myStart; off < myStart; ++off)
63  sum += myData->itemSize(off);
64  return sum;
65  }
66 
67  GT_IMPL_INHERIT_ARRAY(getIndirect, mySize)
68 
69 private:
70  /// Map the requested offset to the offset in my data
71  inline GT_Offset getIndirect(GT_Offset offset) const
72  { return myStart + offset; }
73 
74  GT_Offset myStart;
75  GT_Size mySize;
76 };
77 
78 #endif
GT_DASubArray(const GT_DataArrayHandle &data, GT_Offset start, GT_Size size)
Useful constructor.
Definition: GT_DASubArray.h:30
GLuint start
Definition: glcorearb.h:475
void init(const GT_DataArrayHandle &data, GT_Offset start, GT_Size size)
Initialize with given data.
Definition: GT_DASubArray.h:49
#define GT_API
Definition: GT_API.h:11
GT_Size itemSize(GT_Offset offset) const override
Definition: GT_DASubArray.h:57
GLenum src
Definition: glcorearb.h:1793
GT_DASubArray(const GT_DASubArray &src)
Copy constructor.
Definition: GT_DASubArray.h:37
GLsizeiptr size
Definition: glcorearb.h:664
int64 GT_Offset
Definition: GT_Types.h:124
GT_DASubArray()
Default constructor.
Definition: GT_DASubArray.h:23
GT_Size getTotalArrayEntries() const override
Definition: GT_DASubArray.h:59
int64 GT_Size
Definition: GT_Types.h:123
A slice of a different data array.
Definition: GT_DASubArray.h:20
Base class for a data array which references another data array.
Definition: GT_DAInherit.h:18
#define GT_IMPL_INHERIT_ARRAY(MAP_INDEX, SIZE)
Definition: GT_DAInherit.h:83
void init(const GT_DataArrayHandle &data)
Definition: GT_DAInherit.h:32
GLintptr offset
Definition: glcorearb.h:665
Definition: format.h:895
const char * className() const override
Definition: GT_DASubArray.h:46