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  bool getSA(UT_StringArray &a, GT_Offset offset) const override \
107  { return myData->getSA(a, MAP_INDEX(offset)); } \
108  void doImport(GT_Offset off, uint8 *d, GT_Size sz) const override \
109  { myData->import(MAP_INDEX(off), d, sz); } \
110  void doImport(GT_Offset off, int8 *d, GT_Size sz) const override \
111  { myData->import(MAP_INDEX(off), d, sz); } \
112  void doImport(GT_Offset off, int16 *d, GT_Size sz) const override \
113  { myData->import(MAP_INDEX(off), d, sz); } \
114  void doImport(GT_Offset off, int32 *d, GT_Size sz) const override \
115  { myData->import(MAP_INDEX(off), d, sz); } \
116  void doImport(GT_Offset off, int64 *d, GT_Size sz) const override \
117  { myData->import(MAP_INDEX(off), d, sz); } \
118  void doImport(GT_Offset off, fpreal16 *d, GT_Size sz) const override\
119  { myData->import(MAP_INDEX(off), d, sz); } \
120  void doImport(GT_Offset off, fpreal32 *d, GT_Size sz) const override\
121  { myData->import(MAP_INDEX(off), d, sz); } \
122  void doImport(GT_Offset off, fpreal64 *d, \
123  GT_Size sz) const override \
124  { myData->import(MAP_INDEX(off), d, sz); } \
125  void doImportArray(GT_Offset off, \
126  UT_ValArray<fpreal16> &data) const override \
127  { myData->import(MAP_INDEX(off), data); } \
128  void doImportArray(GT_Offset off, \
129  UT_ValArray<fpreal32> &data) const override \
130  { myData->import(MAP_INDEX(off), data); } \
131  void doImportArray(GT_Offset off, \
132  UT_ValArray<fpreal64> &data) const override \
133  { myData->import(MAP_INDEX(off), data); } \
134  void doImportArray(GT_Offset off, \
135  UT_ValArray<uint8> &data) const override \
136  { myData->import(MAP_INDEX(off), data); } \
137  void doImportArray(GT_Offset off, \
138  UT_ValArray<int8> &data) const override \
139  { myData->import(MAP_INDEX(off), data); } \
140  void doImportArray(GT_Offset off, \
141  UT_ValArray<int16> &data) const override \
142  { myData->import(MAP_INDEX(off), data); } \
143  void doImportArray(GT_Offset off, \
144  UT_ValArray<int32> &data) const override \
145  { myData->import(MAP_INDEX(off), data); } \
146  void doImportArray(GT_Offset off, \
147  UT_ValArray<int64> &data) const override \
148  { myData->import(MAP_INDEX(off), data); } \
149  void fillStringArray(UT_StringArray &data, \
150  UT_ValArray<int> &sizes, \
151  GT_Offset start, GT_Size length) const override \
152  { \
153  UT_ASSERT(start >= 0 && length <= SIZE); \
154  if (myData->getStorage() == GT_STORE_STRING) \
155  { \
156  UT_StringArray attr_strings; \
157  for (GT_Offset off = start; off < length; ++off) \
158  { \
159  attr_strings.clear(); \
160  getSA(attr_strings, off); \
161  sizes.append(attr_strings.entries()); \
162  data.concat(attr_strings); \
163  } \
164  } \
165  }
166  /// @}
167 
168  const GT_DataArrayHandle &referencedData() const { return myData; }
169 
170 protected:
171 
173 };
174 
175 #endif
176 
GT_Size itemSize(GT_Offset offset) const override
Definition: GT_DAInherit.h:52
GT_Storage
Definition: GT_Types.h:18
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
GT_DataArrayHandle myData
Definition: GT_DAInherit.h:172
GT_Storage getStorage() const override
Definition: GT_DAInherit.h:39
#define GT_API
Definition: GT_API.h:11
GT_Type
Definition: GT_Types.h:34
const GT_DataArrayHandle & referencedData() const
Definition: GT_DAInherit.h:168
GLenum src
Definition: glcorearb.h:1793
GT_Type getTypeInfo() const override
Definition: GT_DAInherit.h:43
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:124
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:86
GT_DAInherit(const GT_DAInherit &src)
Copy constructor.
Definition: GT_DAInherit.h:25
GLboolean * data
Definition: glcorearb.h:131
int64 GT_Size
Definition: GT_Types.h:123
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
GLintptr offset
Definition: glcorearb.h:665
Definition: format.h:895