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 
73  int64 getMemoryUsage() const override;
74  bool getPointerAliasing(const void *data) const override;
75  /// @}
76 
77  /// @{
78  /// Not supported since there's no easy way to merge string indices
79  GT_Size getStringIndexCount() const override { return 0; }
80  GT_Offset getStringIndex(GT_Offset, int idx) const override
81  { return -1; }
83  UT_IntArray&) const override
84  {}
85  /// @}
86 
87 protected:
88  /// @{
89  /// Data accessor
90  fpreal16 getF16(GT_Offset offset, int idx=0) const override
91  {
92  const GT_DataArray *h = getList(offset);
93  return h->getF16(offset, idx);
94  }
95  fpreal32 getF32(GT_Offset offset, int idx=0) const override
96  {
97  const GT_DataArray *h = getList(offset);
98  return h->getF32(offset, idx);
99  }
100  fpreal64 getF64(GT_Offset offset, int idx=0) const override
101  {
102  const GT_DataArray *h = getList(offset);
103  return h->getF64(offset, idx);
104  }
105  uint8 getU8(GT_Offset offset, int idx=0) const override
106  {
107  const GT_DataArray *h = getList(offset);
108  return h->getU8(offset, idx);
109  }
110  int32 getI32(GT_Offset offset, int idx=0) const override
111  {
112  const GT_DataArray *h = getList(offset);
113  return h->getI32(offset, idx);
114  }
115  int64 getI64(GT_Offset offset, int idx=0) const override
116  {
117  const GT_DataArray *h = getList(offset);
118  return h->getI64(offset, idx);
119  }
120  GT_String getS(GT_Offset offset, int idx=0) const override
121  {
122  const GT_DataArray *h = getList(offset);
123  return h->getS(offset, idx);
124  }
126  GT_Offset offset) const override
127  {
128  const GT_DataArray *h = getList(offset);
129  return h->getSA(a, offset);
130  }
131 
132  void doImport(GT_Offset off, uint8 *d,
133  GT_Size sz) const override
134  {
135  const GT_DataArray *h = getList(off);
136  h->import(off, d, sz);
137  }
138  void doImport(GT_Offset off, int8 *d,
139  GT_Size sz) const override
140  {
141  const GT_DataArray *h = getList(off);
142  h->import(off, d, sz);
143  }
144  void doImport(GT_Offset off, int16 *d,
145  GT_Size sz) const override
146  {
147  const GT_DataArray *h = getList(off);
148  h->import(off, d, sz);
149  }
150  void doImport(GT_Offset off, int32 *d,
151  GT_Size sz) const override
152  {
153  const GT_DataArray *h = getList(off);
154  h->import(off, d, sz);
155  }
156  void doImport(GT_Offset off, int64 *d,
157  GT_Size sz) const override
158  {
159  const GT_DataArray *h = getList(off);
160  h->import(off, d, sz);
161  }
163  GT_Size sz) const override
164  {
165  const GT_DataArray *h = getList(off);
166  h->import(off, d, sz);
167  }
169  GT_Size sz) const override
170  {
171  const GT_DataArray *h = getList(off);
172  h->import(off, d, sz);
173  }
175  GT_Size sz) const override
176  {
177  const GT_DataArray *h = getList(off);
178  h->import(off, d, sz);
179  }
180 
181 #define GT_IMPL_IMPORT_ARRAY(TYPE) \
182  virtual void doImportArray(GT_Offset off, UT_ValArray<TYPE> &data) const override \
183  { \
184  const GT_DataArray *h = getList(off); \
185  h->import(off, data); \
186  }
187 
194 
195 #undef GT_IMPL_IMPORT_ARRAY
196 
198  int tsize, int stride) const override;
200  int tsize, int stride) const override;
202  int tsize, int stride) const override;
204  int tsize, int stride) const override;
206  int tsize, int stride) const override;
208  int tsize, int stride) const override;
210  int tsize, int stride) const override;
212  int tsize, int stride) const override;
213  /// @}
214 
215 
216 private:
217  const GT_DataArray *getList(GT_Offset &offset) const
218  {
219  // Figure out which list is
220  GT_Offset list = myListFromOffset(offset);
221  // Now, adjust the offset to be relative for the
222  // list in question.
223  offset -= myListCounts.getOffset(list);
224  return myList(list).get();
225  }
226 
227  const GT_DataArray *myFirst;
229  UT_IntArray myListFromOffset;
230  GT_CountArray myListCounts;
231  GT_Size myTotalEntries;
232  GT_Storage myStorage;
233 };
234 
235 #endif
GT_Storage
Definition: GT_Types.h:18
void import(GT_Offset idx, int8 *data, GT_Size size=0) const
Definition: GT_DataArray.h:205
virtual bool isValid() const
Data array is valid; can be sampled from.
Definition: GT_DataArray.h:81
GT_String getS(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:120
GLenum src
Definition: glew.h:2410
int int32
Definition: SYS_Types.h:39
virtual fpreal16 getF16(GT_Offset offset, int idx=0) const
Definition: GT_DataArray.h:109
GT_Size entries() const override
Definition: GT_DAList.h:65
virtual fpreal64 getF64(GT_Offset offset, int idx=0) const
Definition: GT_DataArray.h:112
GT_DAList()
Default constructor.
Definition: GT_DAList.h:24
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:9477
virtual fpreal32 getF32(GT_Offset offset, int idx=0) const =0
void getIndexedStrings(UT_StringArray &, UT_IntArray &) const override
Definition: GT_DAList.h:82
#define GT_API
Definition: GT_API.h:11
void doImport(GT_Offset off, fpreal16 *d, GT_Size sz) const override
Definition: GT_DAList.h:162
GT_Type
Definition: GT_Types.h:34
virtual int64 getI64(GT_Offset offset, int idx=0) const
Definition: GT_DataArray.h:106
int32 getI32(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:110
GT_Storage getStorage() const override
Definition: GT_DAList.h:59
fpreal64 getF64(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:100
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:144
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
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
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:77
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:150
GT_Offset getStringIndex(GT_Offset, int idx) const override
Definition: GT_DAList.h:80
int64 GT_Offset
Definition: GT_Types.h:114
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:641
virtual bool getSA(UT_StringArray &a, GT_Offset offset) const
Definition: GT_DataArray.h:117
bool hasArrayEntries() const override
Definition: GT_DAList.h:67
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:8011
signed char int8
Definition: SYS_Types.h:35
bool getSA(UT_StringArray &a, GT_Offset offset) const override
Definition: GT_DAList.h:125
fpreal16 getF16(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:90
GT_Type getTypeInfo() const override
Definition: GT_DAList.h:63
GLuint start
Definition: glew.h:1253
GLsizei stride
Definition: glew.h:1523
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:113
GT_Size getStringIndexCount() const override
Definition: GT_DAList.h:79
#define GT_IMPL_IMPORT_ARRAY(TYPE)
Definition: GT_DAList.h:181
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:105
virtual int64 getMemoryUsage() const =0
void doImport(GT_Offset off, fpreal32 *d, GT_Size sz) const override
Definition: GT_DAList.h:168
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:135
void doImport(GT_Offset off, uint8 *d, GT_Size sz) const override
Definition: GT_DAList.h:132
void doImport(GT_Offset off, fpreal64 *d, GT_Size sz) const override
Definition: GT_DAList.h:174
void doImport(GT_Offset off, int64 *d, GT_Size sz) const override
Definition: GT_DAList.h:156
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:95
void doImport(GT_Offset off, int8 *d, GT_Size sz) const override
Definition: GT_DAList.h:138
int64 getI64(GT_Offset offset, int idx=0) const override
Definition: GT_DAList.h:115
virtual GT_String getS(GT_Offset offset, int idx=0) const =0
GLenum GLsizei len
Definition: glew.h:7752
GLintptr offset
Definition: glew.h:1682