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
21 class GT_API GT_DAList : public GT_DataArray {
22 public:
23  /// Default constructor
25  : myFirst(NULL)
26  , myStorage(GT_STORE_INVALID)
27  , GT_DataArray()
28  {
29  }
30  /// Useful constructor
32  : myFirst(NULL)
33  , myStorage(GT_STORE_INVALID)
34  , GT_DataArray()
35  {
36  init(list);
37  }
38  /// Copy constructor
40  : myFirst(NULL)
41  , myStorage(src.getStorage())
42  , GT_DataArray(src)
43  {
44  init(src.myList);
45  }
46  /// Destructor
47  ~GT_DAList() override;
48 
49  const char *className() const override { return "GT_DAList"; }
50 
51  /// Initialize with given data
52  void init(const UT_Array<GT_DataArrayHandle> &list);
53 
54  /// Test whether the array is valid
55  bool isValid() const override { return myFirst != NULL; }
56 
57  /// @{
58  /// Method defined on GT_DataArray
59  GT_Storage getStorage() const override
60  { return myFirst->getStorage(); }
61  GT_Size getTupleSize() const override
62  { return myFirst->getTupleSize(); }
63  GT_Type getTypeInfo() const override
64  { return myFirst->getTypeInfo(); }
65  GT_Size entries() const override
66  { return myTotalEntries; }
67  bool hasArrayEntries() const override
68  {
69  UT_ASSERT(isValid());
70  return myFirst->hasArrayEntries();
71  }
72  GT_Size itemSize(GT_Offset offset) const override;
73  GT_Size getTotalArrayEntries() const override
74  { return myTotalArrayEntries; }
75 
76  int64 getMemoryUsage() const override;
77  bool getPointerAliasing(const void *data) const override;
78  /// @}
79 
80  /// @{
81  /// Not supported since there's no easy way to merge string indices
82  GT_Size getStringIndexCount() const override { return -1; }
83  GT_Offset getStringIndex(GT_Offset, int idx) const override
84  { return -1; }
86  UT_IntArray&) const override {}
87 
88  /// Not supported since there's no easy way to merge dictionary indices
89  GT_Size getDictIndexCount() const override { return -1; }
90  GT_Offset getDictIndex(GT_Offset, int idx) const override
91  { return -1; }
93  UT_IntArray&) const override {}
94  /// @}
95 
96 protected:
97  /// @{
98  /// Data accessor
99  fpreal16 getF16(GT_Offset offset, int idx=0) const override
100  {
101  const GT_DataArray *h = getList(offset);
102  return h->getF16(offset, idx);
103  }
104  fpreal32 getF32(GT_Offset offset, int idx=0) const override
105  {
106  const GT_DataArray *h = getList(offset);
107  return h->getF32(offset, idx);
108  }
109  fpreal64 getF64(GT_Offset offset, int idx=0) const override
110  {
111  const GT_DataArray *h = getList(offset);
112  return h->getF64(offset, idx);
113  }
114  uint8 getU8(GT_Offset offset, int idx=0) const override
115  {
116  const GT_DataArray *h = getList(offset);
117  return h->getU8(offset, idx);
118  }
119  int32 getI32(GT_Offset offset, int idx=0) const override
120  {
121  const GT_DataArray *h = getList(offset);
122  return h->getI32(offset, idx);
123  }
124  int64 getI64(GT_Offset offset, int idx=0) const override
125  {
126  const GT_DataArray *h = getList(offset);
127  return h->getI64(offset, idx);
128  }
129  GT_String getS(GT_Offset offset, int idx=0) const override
130  {
131  const GT_DataArray *h = getList(offset);
132  return h->getS(offset, idx);
133  }
135  GT_Offset offset) const override
136  {
137  const GT_DataArray *h = getList(offset);
138  return h->getSA(a, offset);
139  }
140 
141  void doImport(GT_Offset off, uint8 *d,
142  GT_Size sz) const override
143  {
144  const GT_DataArray *h = getList(off);
145  h->import(off, d, sz);
146  }
147  void doImport(GT_Offset off, int8 *d,
148  GT_Size sz) const override
149  {
150  const GT_DataArray *h = getList(off);
151  h->import(off, d, sz);
152  }
153  void doImport(GT_Offset off, int16 *d,
154  GT_Size sz) const override
155  {
156  const GT_DataArray *h = getList(off);
157  h->import(off, d, sz);
158  }
159  void doImport(GT_Offset off, int32 *d,
160  GT_Size sz) const override
161  {
162  const GT_DataArray *h = getList(off);
163  h->import(off, d, sz);
164  }
165  void doImport(GT_Offset off, int64 *d,
166  GT_Size sz) const override
167  {
168  const GT_DataArray *h = getList(off);
169  h->import(off, d, sz);
170  }
172  GT_Size sz) const override
173  {
174  const GT_DataArray *h = getList(off);
175  h->import(off, d, sz);
176  }
178  GT_Size sz) const override
179  {
180  const GT_DataArray *h = getList(off);
181  h->import(off, d, sz);
182  }
184  GT_Size sz) const override
185  {
186  const GT_DataArray *h = getList(off);
187  h->import(off, d, sz);
188  }
189 
190 #define GT_IMPL_IMPORT_ARRAY(TYPE) \
191  virtual void doImportArray(GT_Offset off, UT_ValArray<TYPE> &data) const override \
192  { \
193  const GT_DataArray *h = getList(off); \
194  h->import(off, data); \
195  }
196 
205 
206 #undef GT_IMPL_IMPORT_ARRAY
207 
209  int tsize, int stride) const override;
211  int tsize, int stride) const override;
213  int tsize, int stride) const override;
215  int tsize, int stride) const override;
217  int tsize, int stride) const override;
218  void doFillArray(fpreal16 *dat, GT_Offset start, GT_Size len,
219  int tsize, int stride) const override;
220  void doFillArray(fpreal32 *dat, GT_Offset start, GT_Size len,
221  int tsize, int stride) const override;
222  void doFillArray(fpreal64 *dat, GT_Offset start, GT_Size len,
223  int tsize, int stride) const override;
224  /// @}
225 
226 
227 private:
228  const GT_DataArray *getList(GT_Offset &offset) const
229  {
230  // Figure out which list is
231  GT_Offset list = myListFromOffset(offset);
232  // Now, adjust the offset to be relative for the
233  // list in question.
234  offset -= myListCounts.getOffset(list);
235  return myList(list).get();
236  }
237 
238  const GT_DataArray *myFirst;
240  UT_IntArray myListFromOffset;
241  GT_CountArray myListCounts;
242  GT_Size myTotalEntries;
243  GT_Size myTotalArrayEntries;
244  GT_Storage myStorage;
245 };
246 
247 #endif
GT_Storage
Definition: GT_Types.h:19
void import(GT_Offset idx, int8 *data, GT_Size size=0) const
Definition: GT_DataArray.h:247
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:129
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:65
virtual fpreal64 getF64(GT_Offset offset, int idx=0) const
Definition: GT_DataArray.h:114
GT_DAList()
Default constructor.
Definition: GT_DAList.h:24
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:85
#define GT_API
Definition: GT_API.h:13
void doImport(GT_Offset off, fpreal16 *d, GT_Size sz) const override
Definition: GT_DAList.h:171
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:119
GT_Storage getStorage() const override
Definition: GT_DAList.h:59
fpreal64 getF64(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:109
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:153
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:89
GT_DAList(const UT_Array< GT_DataArrayHandle > &list)
Useful constructor.
Definition: GT_DAList.h:31
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:55
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:49
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:159
GT_Offset getStringIndex(GT_Offset, int idx) const override
Definition: GT_DAList.h:83
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:700
void getIndexedDicts(UT_Array< UT_OptionsHolder > &, UT_IntArray &) const override
Definition: GT_DAList.h:92
virtual bool getSA(UT_StringArray &a, GT_Offset offset) const
Definition: GT_DataArray.h:118
bool hasArrayEntries() const override
Definition: GT_DAList.h:67
GT_Size getTotalArrayEntries() const override
Definition: GT_DAList.h:73
signed char int8
Definition: SYS_Types.h:35
bool getSA(UT_StringArray &a, GT_Offset offset) const override
Definition: GT_DAList.h:134
fpreal16 getF16(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:99
GT_Type getTypeInfo() const override
Definition: GT_DAList.h:63
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:39
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:82
#define GT_IMPL_IMPORT_ARRAY(TYPE)
Definition: GT_DAList.h:190
short int16
Definition: SYS_Types.h:37
GT_Size getTupleSize() const override
Definition: GT_DAList.h:61
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:114
virtual int64 getMemoryUsage() const =0
void doImport(GT_Offset off, fpreal32 *d, GT_Size sz) const override
Definition: GT_DAList.h:177
#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:141
void doImport(GT_Offset off, fpreal64 *d, GT_Size sz) const override
Definition: GT_DAList.h:183
void doImport(GT_Offset off, int64 *d, GT_Size sz) const override
Definition: GT_DAList.h:165
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:104
void doImport(GT_Offset off, int8 *d, GT_Size sz) const override
Definition: GT_DAList.h:147
int64 getI64(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:124
Definition: format.h:895
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:90
GLenum src
Definition: glcorearb.h:1793