HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  virtual ~GT_DAList();
48 
49  virtual const char *className() const { 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 { return myFirst != NULL; }
56 
57  /// @{
58  /// Method defined on GT_DataArray
59  virtual GT_Storage getStorage() const
60  { return myFirst->getStorage(); }
61  virtual GT_Size getTupleSize() const
62  { return myFirst->getTupleSize(); }
63  virtual GT_Type getTypeInfo() const
64  { return myFirst->getTypeInfo(); }
65  virtual GT_Size entries() const
66  { return myTotalEntries; }
67 
68  virtual int64 getMemoryUsage() const;
69  virtual bool getPointerAliasing(const void *data) const;
70  /// @}
71 
72  /// @{
73  /// Not supported since there's no easy way to merge string indices
74  virtual GT_Size getStringIndexCount() const { return 0; }
75  virtual GT_Offset getStringIndex(GT_Offset, int idx) const { return -1; }
77  {}
78  /// @}
79 
80 protected:
81  /// @{
82  /// Data accessor
83  virtual fpreal16 getF16(GT_Offset offset, int idx=0) const
84  {
85  const GT_DataArray *h = getList(offset);
86  return h->getF16(offset, idx);
87  }
88  virtual fpreal32 getF32(GT_Offset offset, int idx=0) const
89  {
90  const GT_DataArray *h = getList(offset);
91  return h->getF32(offset, idx);
92  }
93  virtual fpreal64 getF64(GT_Offset offset, int idx=0) const
94  {
95  const GT_DataArray *h = getList(offset);
96  return h->getF64(offset, idx);
97  }
98  virtual uint8 getU8(GT_Offset offset, int idx=0) const
99  {
100  const GT_DataArray *h = getList(offset);
101  return h->getU8(offset, idx);
102  }
103  virtual int32 getI32(GT_Offset offset, int idx=0) const
104  {
105  const GT_DataArray *h = getList(offset);
106  return h->getI32(offset, idx);
107  }
108  virtual int64 getI64(GT_Offset offset, int idx=0) const
109  {
110  const GT_DataArray *h = getList(offset);
111  return h->getI64(offset, idx);
112  }
113  virtual GT_String getS(GT_Offset offset, int idx=0) const
114  {
115  const GT_DataArray *h = getList(offset);
116  return h->getS(offset, idx);
117  }
118 
119  virtual void doImport(GT_Offset off, uint8 *d, GT_Size sz) const
120  {
121  const GT_DataArray *h = getList(off);
122  h->import(off, d, sz);
123  }
124  virtual void doImport(GT_Offset off, int32 *d, GT_Size sz) const
125  {
126  const GT_DataArray *h = getList(off);
127  h->import(off, d, sz);
128  }
129  virtual void doImport(GT_Offset off, int64 *d, GT_Size sz) const
130  {
131  const GT_DataArray *h = getList(off);
132  h->import(off, d, sz);
133  }
134  virtual void doImport(GT_Offset off, fpreal16 *d, GT_Size sz) const
135  {
136  const GT_DataArray *h = getList(off);
137  h->import(off, d, sz);
138  }
139  virtual void doImport(GT_Offset off, fpreal32 *d, GT_Size sz) const
140  {
141  const GT_DataArray *h = getList(off);
142  h->import(off, d, sz);
143  }
144  virtual void doImport(GT_Offset off, fpreal64 *d, GT_Size sz) const
145  {
146  const GT_DataArray *h = getList(off);
147  h->import(off, d, sz);
148  }
149 
150  virtual void doFillArray(uint8 *data, GT_Offset start, GT_Size len,
151  int tsize, int stride) const;
152  virtual void doFillArray(int32 *data, GT_Offset start, GT_Size len,
153  int tsize, int stride) const;
154  virtual void doFillArray(int64 *data, GT_Offset start, GT_Size len,
155  int tsize, int stride) const;
156  virtual void doFillArray(fpreal16 *dat, GT_Offset start, GT_Size len,
157  int tsize, int stride) const;
158  virtual void doFillArray(fpreal32 *dat, GT_Offset start, GT_Size len,
159  int tsize, int stride) const;
160  virtual void doFillArray(fpreal64 *dat, GT_Offset start, GT_Size len,
161  int tsize, int stride) const;
162  /// @}
163 
164 
165 private:
166  const GT_DataArray *getList(GT_Offset &offset) const
167  {
168  // Figure out which list is
169  GT_Offset list = myListFromOffset(offset);
170  // Now, adjust the offset to be relative for the
171  // list in question.
172  offset -= myListCounts.getOffset(list);
173  return myList(list).get();
174  }
175 
176  const GT_DataArray *myFirst;
178  UT_IntArray myListFromOffset;
179  GT_CountArray myListCounts;
180  GT_Size myTotalEntries;
181  GT_Storage myStorage;
182 };
183 
184 #endif
virtual void doImport(GT_Offset off, fpreal32 *d, GT_Size sz) const
Definition: GT_DAList.h:139
GT_Storage
Definition: GT_Types.h:17
virtual fpreal16 getF16(GT_Offset offset, int idx=0) const
Definition: GT_DataArray.h:91
virtual void doImport(GT_Offset off, fpreal16 *d, GT_Size sz) const
Definition: GT_DAList.h:134
virtual void getIndexedStrings(UT_StringArray &, UT_IntArray &) const
Definition: GT_DAList.h:76
virtual fpreal64 getF64(GT_Offset offset, int idx=0) const
Definition: GT_DataArray.h:94
virtual GT_Size getTupleSize() const
Definition: GT_DAList.h:61
GT_DAList()
Default constructor.
Definition: GT_DAList.h:24
GLuint start
Definition: glcorearb.h:474
const char * GT_String
Definition: GT_Types.h:108
virtual GT_Storage getStorage() const
Definition: GT_DAList.h:59
virtual void doImport(GT_Offset off, uint8 *d, GT_Size sz) const
Definition: GT_DAList.h:119
virtual void doImport(GT_Offset off, int32 *d, GT_Size sz) const
Definition: GT_DAList.h:124
virtual fpreal32 getF32(GT_Offset offset, int idx=0) const =0
#define GT_API
Definition: GT_API.h:11
GT_Type
Definition: GT_Types.h:31
virtual int64 getI64(GT_Offset offset, int idx=0) const
Definition: GT_DataArray.h:88
virtual void doImport(GT_Offset off, fpreal64 *d, GT_Size sz) const
Definition: GT_DAList.h:144
void import(GT_Offset idx, int32 *data, GT_Size size=0) const
Definition: GT_DataArray.h:165
virtual GT_String getS(GT_Offset offset, int idx=0) const
Definition: GT_DAList.h:113
long long int64
Definition: SYS_Types.h:106
virtual GT_Type getTypeInfo() const
Definition: GT_DAList.h:63
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:38
double fpreal64
Definition: SYS_Types.h:191
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:871
GLintptr offset
Definition: glcorearb.h:664
virtual bool getPointerAliasing(const void *data) const
Return "true" if there's pointer aliasing.
Definition: GT_DataArray.h:71
virtual const char * className() const
Definition: GT_DAList.h:49
virtual GT_Size entries() const
Definition: GT_DAList.h:65
virtual void doFillArray(uint8 *data, GT_Offset start, GT_Size length, int tuple_size, int stride) const
Definition: GT_DataArray.h:397
bool isValid() const
Test whether the array is valid.
Definition: GT_DAList.h:55
GLboolean * data
Definition: glcorearb.h:130
virtual fpreal64 getF64(GT_Offset offset, int idx=0) const
Definition: GT_DAList.h:93
int int32
Definition: SYS_Types.h:34
virtual fpreal16 getF16(GT_Offset offset, int idx=0) const
Definition: GT_DAList.h:83
virtual void doImport(GT_Offset off, int64 *d, GT_Size sz) const
Definition: GT_DAList.h:129
virtual int32 getI32(GT_Offset offset, int idx=0) const
Definition: GT_DAList.h:103
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
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
virtual fpreal32 getF32(GT_Offset offset, int idx=0) const
Definition: GT_DAList.h:88
unsigned char uint8
Definition: SYS_Types.h:31
virtual int64 getI64(GT_Offset offset, int idx=0) const
Definition: GT_DAList.h:108
virtual uint8 getU8(GT_Offset offset, int idx=0) const =0
virtual int64 getMemoryUsage() const =0
virtual GT_Offset getStringIndex(GT_Offset, int idx) const
Definition: GT_DAList.h:75
virtual uint8 getU8(GT_Offset offset, int idx=0) const
Definition: GT_DAList.h:98
int64 GT_Offset
Definition: GT_Types.h:110
int64 GT_Size
Definition: GT_Types.h:109
virtual int32 getI32(GT_Offset offset, int idx=0) const =0
float fpreal32
Definition: SYS_Types.h:190
virtual GT_String getS(GT_Offset offset, int idx=0) const =0
virtual GT_Size getStringIndexCount() const
Definition: GT_DAList.h:74
GLenum src
Definition: glcorearb.h:1792