HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_DAInherit.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_DAInherit.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_DAInherit__
12 #define __GT_DAInherit__
13 
14 #include "GT_API.h"
15 #include "GT_DataArray.h"
16 
17 /// @brief Base class for a data array which references another data array
19 public:
20  /// Default constructor
21  GT_DAInherit() : myData() {}
22  /// Convenience constructor
23  GT_DAInherit(const GT_DataArrayHandle &data) : myData(data) { }
24  /// Copy constructor
26  : myData(src.myData)
27  , GT_DataArray()
28  {
29  }
30  ~GT_DAInherit() override;
31 
33  {
34  myData = data;
35  }
36 
37  /// @{
38  /// Methods defined on GT_DataArray
39  GT_Storage getStorage() const override
40  { return myData->getStorage(); }
41  GT_Size getTupleSize() const override
42  { return myData->getTupleSize(); }
43  GT_Type getTypeInfo() const override
44  { return myData->getTypeInfo(); }
45  int64 getMemoryUsage() const override
46  { return myData->getMemoryUsage() + sizeof(*this); }
47  bool hasArrayEntries() const override
48  { return myData->hasArrayEntries(); }
49 
50  /// This method may need to be overridden by derived classes depending on
51  /// how the underlying data is referenced.
52  GT_Size itemSize(GT_Offset offset) const override
53  { return myData->itemSize(offset); }
54 
55  /// This method may need to be overridden by derived classes depending on
56  /// how the underlying data is referenced.
57  GT_Size getTotalArrayEntries() const override
58  { return myData->getTotalArrayEntries(); }
59 
60  /// Return "true" if there's pointer aliasing
61  bool getPointerAliasing(const void *data) const override
62  { return myData->getPointerAliasing(data); }
63  bool isValid() const override { return myData && myData->isValid(); }
64  int64 getDataId() const override { return myData->getDataId(); }
66  const char *attrib_name,
67  GT_Owner attrib_owner,
68  const int expected_size) override
69  {
70  myData->updateGeoDetail(dtl, attrib_name,
71  attrib_owner,
72  expected_size);
73  }
74  /// @}
75 
76  /// @{
77  /// Implement the specific methods of the inherited array.
78  /// @param MAP_INDEX @n
79  /// A function which takes an offset an maps it to the index in the
80  /// source array
81  /// @param SIZE @n
82  /// The size of this array
83 #define GT_IMPL_INHERIT_ARRAY(MAP_INDEX, SIZE) \
84  GT_Size entries() const override { return SIZE; } \
85  fpreal16 getF16(GT_Offset offset, int idx=0) const override \
86  { return myData->getF16(MAP_INDEX(offset), idx); } \
87  fpreal32 getF32(GT_Offset offset, int idx=0) const override \
88  { return myData->getF32(MAP_INDEX(offset), idx); } \
89  fpreal64 getF64(GT_Offset offset, int idx=0) const override \
90  { return myData->getF64(MAP_INDEX(offset), idx); } \
91  uint8 getU8(GT_Offset offset, int idx=0) const override \
92  { return myData->getU8(MAP_INDEX(offset), idx); } \
93  int32 getI32(GT_Offset offset, int idx=0) const override \
94  { return myData->getI32(MAP_INDEX(offset), idx); } \
95  int64 getI64(GT_Offset offset, int idx=0) const override \
96  { return myData->getI64(MAP_INDEX(offset), idx); } \
97  GT_String getS(GT_Offset offset, int idx=0) const override \
98  { return myData->getS(MAP_INDEX(offset), idx); } \
99  GT_Size getStringIndexCount() const override \
100  { return myData->getStringIndexCount(); } \
101  GT_Offset getStringIndex(GT_Offset offset, int idx) const override \
102  { return myData->getStringIndex(MAP_INDEX(offset), idx); } \
103  void getIndexedStrings(UT_StringArray &strings, \
104  UT_IntArray &indices) const override \
105  { myData->getIndexedStrings(strings, indices); } \
106  GT_Size getDictIndexCount() const override \
107  { return myData->getDictIndexCount(); } \
108  GT_Offset getDictIndex(GT_Offset offset, int idx) const override \
109  { return myData->getDictIndex(MAP_INDEX(offset), idx); } \
110  void getIndexedDicts(UT_Array<UT_OptionsHolder> &dicts, \
111  UT_IntArray &indices) const override \
112  { myData->getIndexedDicts(dicts, indices); } \
113  bool getSA(UT_StringArray &a, GT_Offset offset) const override \
114  { return myData->getSA(a, MAP_INDEX(offset)); } \
115  void doImport(GT_Offset off, uint8 *d, GT_Size sz) const override \
116  { myData->import(MAP_INDEX(off), d, sz); } \
117  void doImport(GT_Offset off, int8 *d, GT_Size sz) const override \
118  { myData->import(MAP_INDEX(off), d, sz); } \
119  void doImport(GT_Offset off, int16 *d, GT_Size sz) const override \
120  { myData->import(MAP_INDEX(off), d, sz); } \
121  void doImport(GT_Offset off, int32 *d, GT_Size sz) const override \
122  { myData->import(MAP_INDEX(off), d, sz); } \
123  void doImport(GT_Offset off, int64 *d, GT_Size sz) const override \
124  { myData->import(MAP_INDEX(off), d, sz); } \
125  void doImport(GT_Offset off, fpreal16 *d, GT_Size sz) const override\
126  { myData->import(MAP_INDEX(off), d, sz); } \
127  void doImport(GT_Offset off, fpreal32 *d, GT_Size sz) const override\
128  { myData->import(MAP_INDEX(off), d, sz); } \
129  void doImport(GT_Offset off, fpreal64 *d, \
130  GT_Size sz) const override \
131  { myData->import(MAP_INDEX(off), d, sz); } \
132  void doImportArray(GT_Offset off, \
133  UT_ValArray<fpreal16> &data) const override \
134  { myData->import(MAP_INDEX(off), data); } \
135  void doImportArray(GT_Offset off, \
136  UT_ValArray<fpreal32> &data) const override \
137  { myData->import(MAP_INDEX(off), data); } \
138  void doImportArray(GT_Offset off, \
139  UT_ValArray<fpreal64> &data) const override \
140  { myData->import(MAP_INDEX(off), data); } \
141  void doImportArray(GT_Offset off, \
142  UT_ValArray<uint8> &data) const override \
143  { myData->import(MAP_INDEX(off), data); } \
144  void doImportArray(GT_Offset off, \
145  UT_ValArray<int8> &data) const override \
146  { myData->import(MAP_INDEX(off), data); } \
147  void doImportArray(GT_Offset off, \
148  UT_ValArray<int16> &data) const override \
149  { myData->import(MAP_INDEX(off), data); } \
150  void doImportArray(GT_Offset off, \
151  UT_ValArray<int32> &data) const override \
152  { myData->import(MAP_INDEX(off), data); } \
153  void doImportArray(GT_Offset off, \
154  UT_ValArray<int64> &data) const override \
155  { myData->import(MAP_INDEX(off), data); } \
156  void fillStringArray(UT_StringArray &data, \
157  UT_ValArray<int> &sizes, \
158  GT_Offset start, GT_Size length) const override \
159  { \
160  UT_ASSERT(start >= 0 && length <= SIZE); \
161  if (myData->getStorage() == GT_STORE_STRING) \
162  { \
163  UT_StringArray attr_strings; \
164  for (GT_Offset off = start; off < length; ++off) \
165  { \
166  attr_strings.clear(); \
167  getSA(attr_strings, off); \
168  sizes.append(attr_strings.entries()); \
169  data.concat(attr_strings); \
170  } \
171  } \
172  }
173  /// @}
174 
175  const GT_DataArrayHandle &referencedData() const { return myData; }
176 
177 protected:
178 
180 };
181 
182 #endif
183 
GT_Size itemSize(GT_Offset offset) const override
Definition: GT_DAInherit.h:52
GT_Storage
Definition: GT_Types.h:19
bool getPointerAliasing(const void *data) const override
Return "true" if there's pointer aliasing.
Definition: GT_DAInherit.h:61
GT_Size getTupleSize() const override
Definition: GT_DAInherit.h:41
GLboolean * data
Definition: glcorearb.h:131
GT_DataArrayHandle myData
Definition: GT_DAInherit.h:179
GT_Storage getStorage() const override
Definition: GT_DAInherit.h:39
#define GT_API
Definition: GT_API.h:13
GT_Type
Definition: GT_Types.h:36
const GT_DataArrayHandle & referencedData() const
Definition: GT_DAInherit.h:175
GT_Type getTypeInfo() const override
Definition: GT_DAInherit.h:43
GLintptr offset
Definition: glcorearb.h:665
Abstract data class for an array of float, int or string data.
Definition: GT_DataArray.h:40
int64 getDataId() const override
Definition: GT_DAInherit.h:64
int64 getMemoryUsage() const override
Definition: GT_DAInherit.h:45
int64 GT_Offset
Definition: GT_Types.h:129
long long int64
Definition: SYS_Types.h:116
void updateGeoDetail(const GU_ConstDetailHandle &dtl, const char *attrib_name, GT_Owner attrib_owner, const int expected_size) override
Definition: GT_DAInherit.h:65
bool isValid() const override
Definition: GT_DAInherit.h:63
GT_Owner
Definition: GT_Types.h:90
GT_DAInherit(const GT_DAInherit &src)
Copy constructor.
Definition: GT_DAInherit.h:25
int64 GT_Size
Definition: GT_Types.h:128
Base class for a data array which references another data array.
Definition: GT_DAInherit.h:18
bool hasArrayEntries() const override
Definition: GT_DAInherit.h:47
GT_DAInherit()
Default constructor.
Definition: GT_DAInherit.h:21
GT_Size getTotalArrayEntries() const override
Definition: GT_DAInherit.h:57
void init(const GT_DataArrayHandle &data)
Definition: GT_DAInherit.h:32
GT_DAInherit(const GT_DataArrayHandle &data)
Convenience constructor.
Definition: GT_DAInherit.h:23
Definition: format.h:895
GLenum src
Definition: glcorearb.h:1793