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