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_StringArray.h> // required by GT_IMPL_INHERIT_ARRAY()
18 #include <UT/UT_ValArray.h>
19 
20 /// @brief A slice of a different data array
22 public:
23  /// Default constructor
25  : mySize(0)
26  , myStart(0)
27  , GT_DAInherit()
28  {
29  }
30  /// Useful constructor
32  : mySize(size)
33  , myStart(start)
34  , GT_DAInherit(data)
35  {
36  }
37  /// Copy constructor
39  : mySize(src.mySize)
40  , myStart(src.myStart)
41  , GT_DAInherit(src)
42  {
43  }
44  /// Destructor
45  ~GT_DASubArray() override;
46 
47  const char *className() const override { return "GT_DASubArray"; }
48 
49  /// Initialize with given data
52  {
53  GT_DAInherit::init(data);
54  myStart = start;
55  mySize = size;
56  }
57 
58  GT_Size itemSize(GT_Offset offset) const override
59  { return myData->itemSize(this->getIndirect(offset)); }
60  GT_Size getTotalArrayEntries() const override
61  {
62  GT_Size sum = 0;
63  for (GT_Size off = myStart; off < myStart; ++off)
64  sum += myData->itemSize(off);
65  return sum;
66  }
67 
68  GT_IMPL_INHERIT_ARRAY(getIndirect, mySize)
69 
70 private:
71  /// Map the requested offset to the offset in my data
72  inline GT_Offset getIndirect(GT_Offset offset) const
73  { return myStart + offset; }
74 
75  GT_Offset myStart;
76  GT_Size mySize;
77 };
78 
79 #endif
GT_DASubArray(const GT_DataArrayHandle &data, GT_Offset start, GT_Size size)
Useful constructor.
Definition: GT_DASubArray.h:31
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:50
#define GT_API
Definition: GT_API.h:13
GT_Size itemSize(GT_Offset offset) const override
Definition: GT_DASubArray.h:58
GT_DASubArray(const GT_DASubArray &src)
Copy constructor.
Definition: GT_DASubArray.h:38
GLintptr offset
Definition: glcorearb.h:665
int64 GT_Offset
Definition: GT_Types.h:129
GT_DASubArray()
Default constructor.
Definition: GT_DASubArray.h:24
GT_Size getTotalArrayEntries() const override
Definition: GT_DASubArray.h:60
int64 GT_Size
Definition: GT_Types.h:128
GLsizeiptr size
Definition: glcorearb.h:664
A slice of a different data array.
Definition: GT_DASubArray.h:21
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
Definition: format.h:895
const char * className() const override
Definition: GT_DASubArray.h:47
GLenum src
Definition: glcorearb.h:1793