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 0; }
83  GT_Offset getStringIndex(GT_Offset, int idx) const override
84  { return -1; }
86  UT_IntArray&) const override
87  {}
88  /// @}
89 
90 protected:
91  /// @{
92  /// Data accessor
93  fpreal16 getF16(GT_Offset offset, int idx=0) const override
94  {
95  const GT_DataArray *h = getList(offset);
96  return h->getF16(offset, idx);
97  }
98  fpreal32 getF32(GT_Offset offset, int idx=0) const override
99  {
100  const GT_DataArray *h = getList(offset);
101  return h->getF32(offset, idx);
102  }
103  fpreal64 getF64(GT_Offset offset, int idx=0) const override
104  {
105  const GT_DataArray *h = getList(offset);
106  return h->getF64(offset, idx);
107  }
108  uint8 getU8(GT_Offset offset, int idx=0) const override
109  {
110  const GT_DataArray *h = getList(offset);
111  return h->getU8(offset, idx);
112  }
113  int32 getI32(GT_Offset offset, int idx=0) const override
114  {
115  const GT_DataArray *h = getList(offset);
116  return h->getI32(offset, idx);
117  }
118  int64 getI64(GT_Offset offset, int idx=0) const override
119  {
120  const GT_DataArray *h = getList(offset);
121  return h->getI64(offset, idx);
122  }
123  GT_String getS(GT_Offset offset, int idx=0) const override
124  {
125  const GT_DataArray *h = getList(offset);
126  return h->getS(offset, idx);
127  }
129  GT_Offset offset) const override
130  {
131  const GT_DataArray *h = getList(offset);
132  return h->getSA(a, offset);
133  }
134 
135  void doImport(GT_Offset off, uint8 *d,
136  GT_Size sz) const override
137  {
138  const GT_DataArray *h = getList(off);
139  h->import(off, d, sz);
140  }
141  void doImport(GT_Offset off, int8 *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, int16 *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, int32 *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, int64 *d,
160  GT_Size sz) const override
161  {
162  const GT_DataArray *h = getList(off);
163  h->import(off, d, sz);
164  }
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  }
183 
184 #define GT_IMPL_IMPORT_ARRAY(TYPE) \
185  virtual void doImportArray(GT_Offset off, UT_ValArray<TYPE> &data) const override \
186  { \
187  const GT_DataArray *h = getList(off); \
188  h->import(off, data); \
189  }
190 
199 
200 #undef GT_IMPL_IMPORT_ARRAY
201 
203  int tsize, int stride) const override;
205  int tsize, int stride) const override;
207  int tsize, int stride) const override;
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  /// @}
219 
220 
221 private:
222  const GT_DataArray *getList(GT_Offset &offset) const
223  {
224  // Figure out which list is
225  GT_Offset list = myListFromOffset(offset);
226  // Now, adjust the offset to be relative for the
227  // list in question.
228  offset -= myListCounts.getOffset(list);
229  return myList(list).get();
230  }
231 
232  const GT_DataArray *myFirst;
234  UT_IntArray myListFromOffset;
235  GT_CountArray myListCounts;
236  GT_Size myTotalEntries;
237  GT_Size myTotalArrayEntries;
238  GT_Storage myStorage;
239 };
240 
241 #endif
GT_Storage
Definition: GT_Types.h:18
void import(GT_Offset idx, int8 *data, GT_Size size=0) const
Definition: GT_DataArray.h:211
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:123
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:11
void doImport(GT_Offset off, fpreal16 *d, GT_Size sz) const override
Definition: GT_DAList.h:165
GT_Type
Definition: GT_Types.h:34
virtual int64 getI64(GT_Offset offset, int idx=0) const
Definition: GT_DataArray.h:108
int32 getI32(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:113
GT_Storage getStorage() const override
Definition: GT_DAList.h:59
fpreal64 getF64(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:103
GLenum src
Definition: glcorearb.h:1793
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:147
unsigned char uint8
Definition: SYS_Types.h:36
GT_DAList(const UT_Array< GT_DataArrayHandle > &list)
Useful constructor.
Definition: GT_DAList.h:31
Abstract data class for an array of float, int or string data.
Definition: GT_DataArray.h:40
GLenum GLsizei len
Definition: glew.h:7782
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
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
void doImport(GT_Offset off, int32 *d, GT_Size sz) const override
Definition: GT_DAList.h:153
GT_Offset getStringIndex(GT_Offset, int idx) const override
Definition: GT_DAList.h:83
int64 GT_Offset
Definition: GT_Types.h:124
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:662
virtual bool getSA(UT_StringArray &a, GT_Offset offset) const
Definition: GT_DataArray.h:119
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:128
fpreal16 getF16(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:93
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:123
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:184
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:108
virtual int64 getMemoryUsage() const =0
void doImport(GT_Offset off, fpreal32 *d, GT_Size sz) const override
Definition: GT_DAList.h:171
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:153
GLintptr offset
Definition: glcorearb.h:665
void doImport(GT_Offset off, uint8 *d, GT_Size sz) const override
Definition: GT_DAList.h:135
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:872
void doImport(GT_Offset off, fpreal64 *d, GT_Size sz) const override
Definition: GT_DAList.h:177
void doImport(GT_Offset off, int64 *d, GT_Size sz) const override
Definition: GT_DAList.h:159
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:98
void doImport(GT_Offset off, int8 *d, GT_Size sz) const override
Definition: GT_DAList.h:141
int64 getI64(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:118
Definition: format.h:895
virtual GT_String getS(GT_Offset offset, int idx=0) const =0