HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_DAList.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_DAList.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_DAList__
12 #define __GT_DAList__
13 
14 #include "GT_API.h"
15 #include "GT_DataArray.h"
16 #include "GT_CountArray.h"
17 #include <UT/UT_Array.h>
18 #include <UT/UT_IntArray.h>
19 
20 /// @brief A list which "merges" multiple data arrays into a single array
22 {
23 public:
24  /// Default constructor
26  : myFirst(NULL)
27  , myStorage(GT_STORE_INVALID)
28  , GT_DataArray()
29  {
30  }
31  /// Useful constructor
33  : myFirst(NULL)
34  , myStorage(GT_STORE_INVALID)
35  , GT_DataArray()
36  {
37  init(list);
38  }
39  /// Copy constructor
41  : myFirst(NULL)
42  , myStorage(src.getStorage())
43  , GT_DataArray(src)
44  {
45  init(src.myList);
46  }
47  /// Destructor
48  ~GT_DAList() override;
49 
50  const char *className() const override { return "GT_DAList"; }
51 
52  /// Initialize with given data
53  void init(const UT_Array<GT_DataArrayHandle> &list);
54 
55  /// Test whether the array is valid
56  bool isValid() const override { return myFirst != NULL; }
57 
58  /// @{
59  /// Method defined on GT_DataArray
60  GT_Storage getStorage() const override
61  { return myFirst->getStorage(); }
62  GT_Size getTupleSize() const override
63  { return myFirst->getTupleSize(); }
64  GT_Type getTypeInfo() const override
65  { return myFirst->getTypeInfo(); }
66  GT_Size entries() const override
67  { return myTotalEntries; }
68  bool hasArrayEntries() const override
69  {
70  UT_ASSERT(isValid());
71  return myFirst->hasArrayEntries();
72  }
73  GT_Size itemSize(GT_Offset offset) const override;
74  GT_Size getTotalArrayEntries() const override
75  { return myTotalArrayEntries; }
76 
77  int64 getMemoryUsage() const override;
78  bool getPointerAliasing(const void *data) const override;
79  /// @}
80 
81  /// @{
82  /// Not supported since there's no easy way to merge string indices
83  GT_Size getStringIndexCount() const override { return -1; }
84  GT_Offset getStringIndex(GT_Offset, int idx) const override
85  { return -1; }
87  UT_IntArray&) const override {}
88 
89  /// Not supported since there's no easy way to merge dictionary indices
90  GT_Size getDictIndexCount() const override { return -1; }
91  GT_Offset getDictIndex(GT_Offset, int idx) const override
92  { return -1; }
94  UT_IntArray&) const override {}
95  /// @}
96 
97 protected:
98  /// @{
99  /// Data accessor
100  fpreal16 getF16(GT_Offset offset, int idx=0) const override
101  {
102  const GT_DataArray *h = getList(offset);
103  return h->getF16(offset, idx);
104  }
105  fpreal32 getF32(GT_Offset offset, int idx=0) const override
106  {
107  const GT_DataArray *h = getList(offset);
108  return h->getF32(offset, idx);
109  }
110  fpreal64 getF64(GT_Offset offset, int idx=0) const override
111  {
112  const GT_DataArray *h = getList(offset);
113  return h->getF64(offset, idx);
114  }
115  uint8 getU8(GT_Offset offset, int idx=0) const override
116  {
117  const GT_DataArray *h = getList(offset);
118  return h->getU8(offset, idx);
119  }
120  int32 getI32(GT_Offset offset, int idx=0) const override
121  {
122  const GT_DataArray *h = getList(offset);
123  return h->getI32(offset, idx);
124  }
125  int64 getI64(GT_Offset offset, int idx=0) const override
126  {
127  const GT_DataArray *h = getList(offset);
128  return h->getI64(offset, idx);
129  }
130  GT_String getS(GT_Offset offset, int idx=0) const override
131  {
132  const GT_DataArray *h = getList(offset);
133  return h->getS(offset, idx);
134  }
136  GT_Offset offset) const override
137  {
138  const GT_DataArray *h = getList(offset);
139  return h->getSA(a, offset);
140  }
141 
142  void doImport(GT_Offset off, uint8 *d,
143  GT_Size sz) const override
144  {
145  const GT_DataArray *h = getList(off);
146  h->import(off, d, sz);
147  }
148  void doImport(GT_Offset off, int8 *d,
149  GT_Size sz) const override
150  {
151  const GT_DataArray *h = getList(off);
152  h->import(off, d, sz);
153  }
154  void doImport(GT_Offset off, int16 *d,
155  GT_Size sz) const override
156  {
157  const GT_DataArray *h = getList(off);
158  h->import(off, d, sz);
159  }
160  void doImport(GT_Offset off, int32 *d,
161  GT_Size sz) const override
162  {
163  const GT_DataArray *h = getList(off);
164  h->import(off, d, sz);
165  }
166  void doImport(GT_Offset off, int64 *d,
167  GT_Size sz) const override
168  {
169  const GT_DataArray *h = getList(off);
170  h->import(off, d, sz);
171  }
173  GT_Size sz) const override
174  {
175  const GT_DataArray *h = getList(off);
176  h->import(off, d, sz);
177  }
179  GT_Size sz) const override
180  {
181  const GT_DataArray *h = getList(off);
182  h->import(off, d, sz);
183  }
185  GT_Size sz) const override
186  {
187  const GT_DataArray *h = getList(off);
188  h->import(off, d, sz);
189  }
190 
191 #define GT_IMPL_IMPORT_ARRAY(TYPE) \
192  virtual void doImportArray(GT_Offset off, UT_ValArray<TYPE> &data) const override \
193  { \
194  const GT_DataArray *h = getList(off); \
195  h->import(off, data); \
196  }
197 
206 
207 #undef GT_IMPL_IMPORT_ARRAY
208 
210  int tsize, int stride) const override;
212  int tsize, int stride) const override;
214  int tsize, int stride) const override;
216  int tsize, int stride) const override;
218  int tsize, int stride) const override;
219  void doFillArray(fpreal16 *dat, GT_Offset start, GT_Size len,
220  int tsize, int stride) const override;
221  void doFillArray(fpreal32 *dat, GT_Offset start, GT_Size len,
222  int tsize, int stride) const override;
223  void doFillArray(fpreal64 *dat, GT_Offset start, GT_Size len,
224  int tsize, int stride) const override;
225  /// @}
226 
227 
228 private:
229  const GT_DataArray *getList(GT_Offset &offset) const
230  {
231  // Figure out which list is
232  GT_Offset list = myListFromOffset(offset);
233  // Now, adjust the offset to be relative for the
234  // list in question.
235  offset -= myListCounts.getOffset(list);
236  return myList(list).get();
237  }
238 
239  const GT_DataArray *myFirst;
241  UT_IntArray myListFromOffset;
242  GT_CountArray myListCounts;
243  GT_Size myTotalEntries;
244  GT_Size myTotalArrayEntries;
245  GT_Storage myStorage;
246 };
247 
248 #endif
GT_Storage
Definition: GT_Types.h:19
void import(GT_Offset idx, int8 *data, GT_Size size=0) const
Definition: GT_DataArray.h:267
virtual bool isValid() const
Data array is valid; can be sampled from.
Definition: GT_DataArray.h:83
GT_String getS(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:130
int int32
Definition: SYS_Types.h:39
virtual fpreal16 getF16(GT_Offset offset, int idx=0) const
Definition: GT_DataArray.h:111
GT_Size entries() const override
Definition: GT_DAList.h:66
virtual fpreal64 getF64(GT_Offset offset, int idx=0) const
Definition: GT_DataArray.h:114
GT_DAList()
Default constructor.
Definition: GT_DAList.h:25
GLuint start
Definition: glcorearb.h:475
virtual fpreal32 getF32(GT_Offset offset, int idx=0) const =0
void getIndexedStrings(UT_StringArray &, UT_IntArray &) const override
Definition: GT_DAList.h:86
#define GT_API
Definition: GT_API.h:13
void doImport(GT_Offset off, fpreal16 *d, GT_Size sz) const override
Definition: GT_DAList.h:172
GT_Type
Definition: GT_Types.h:36
virtual int64 getI64(GT_Offset offset, int idx=0) const
Definition: GT_DataArray.h:108
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
int32 getI32(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:120
GT_Storage getStorage() const override
Definition: GT_DAList.h:60
fpreal64 getF64(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:110
virtual GT_Size itemSize(GT_Offset) const
Return the number of elements in the array for the given item.
Definition: GT_DataArray.h:60
float fpreal32
Definition: SYS_Types.h:200
double fpreal64
Definition: SYS_Types.h:201
void doImport(GT_Offset off, int16 *d, GT_Size sz) const override
Definition: GT_DAList.h:154
unsigned char uint8
Definition: SYS_Types.h:36
GT_Size getDictIndexCount() const override
Not supported since there's no easy way to merge dictionary indices.
Definition: GT_DAList.h:90
GT_DAList(const UT_Array< GT_DataArrayHandle > &list)
Useful constructor.
Definition: GT_DAList.h:32
GLintptr offset
Definition: glcorearb.h:665
Abstract data class for an array of float, int or string data.
Definition: GT_DataArray.h:40
bool isValid() const override
Test whether the array is valid.
Definition: GT_DAList.h:56
virtual bool getPointerAliasing(const void *data) const
Return "true" if there's pointer aliasing.
Definition: GT_DataArray.h:79
const char * className() const override
Definition: GT_DAList.h:50
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:872
void doImport(GT_Offset off, int32 *d, GT_Size sz) const override
Definition: GT_DAList.h:160
GT_Offset getStringIndex(GT_Offset, int idx) const override
Definition: GT_DAList.h:84
int64 GT_Offset
Definition: GT_Types.h:129
long long int64
Definition: SYS_Types.h:116
virtual void doFillArray(uint8 *data, GT_Offset start, GT_Size length, int tuple_size, int stride) const
Definition: GT_DataArray.h:633
void getIndexedDicts(UT_Array< UT_OptionsHolder > &, UT_IntArray &) const override
Definition: GT_DAList.h:93
virtual bool getSA(UT_StringArray &a, GT_Offset offset) const
Definition: GT_DataArray.h:118
bool hasArrayEntries() const override
Definition: GT_DAList.h:68
GT_Size getTotalArrayEntries() const override
Definition: GT_DAList.h:74
signed char int8
Definition: SYS_Types.h:35
bool getSA(UT_StringArray &a, GT_Offset offset) const override
Definition: GT_DAList.h:135
fpreal16 getF16(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:100
GT_Type getTypeInfo() const override
Definition: GT_DAList.h:64
A list which "merges" multiple data arrays into a single array.
Definition: GT_DAList.h:21
GT_DAList(const GT_DAList &src)
Copy constructor.
Definition: GT_DAList.h:40
int64 GT_Size
Definition: GT_Types.h:128
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
GT_Size getStringIndexCount() const override
Definition: GT_DAList.h:83
#define GT_IMPL_IMPORT_ARRAY(TYPE)
Definition: GT_DAList.h:191
short int16
Definition: SYS_Types.h:37
GT_Size getTupleSize() const override
Definition: GT_DAList.h:62
virtual uint8 getU8(GT_Offset offset, int idx=0) const =0
uint8 getU8(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:115
virtual int64 getMemoryUsage() const =0
void doImport(GT_Offset off, fpreal32 *d, GT_Size sz) const override
Definition: GT_DAList.h:178
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
void doImport(GT_Offset off, uint8 *d, GT_Size sz) const override
Definition: GT_DAList.h:142
void doImport(GT_Offset off, fpreal64 *d, GT_Size sz) const override
Definition: GT_DAList.h:184
void doImport(GT_Offset off, int64 *d, GT_Size sz) const override
Definition: GT_DAList.h:166
virtual int32 getI32(GT_Offset offset, int idx=0) const =0
fpreal32 getF32(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:105
void doImport(GT_Offset off, int8 *d, GT_Size sz) const override
Definition: GT_DAList.h:148
int64 getI64(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:125
Definition: format.h:1821
virtual GT_String getS(GT_Offset offset, int idx=0) const =0
GT_Offset getDictIndex(GT_Offset, int idx) const override
Definition: GT_DAList.h:91
GLenum src
Definition: glcorearb.h:1793