HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_DAValues.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_DAValues.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_DAValue__
12 #define __GT_DAValue__
13 
14 #include "GT_API.h"
15 #include "GT_DataArray.h"
16 #include <UT/UT_Assert.h>
17 
18 /// @brief An array of const values.
19 ///
20 /// The data in the array is @b not owned by the array, but needs to exist
21 /// while the array is in use.
22 template <typename T>
23 class GT_DAValues : public GT_DataArray {
24 public:
25  GT_DAValues(const T *values, GT_Size array_size,
26  int tuple_size, GT_Type type=GT_TYPE_NONE)
27  : myData(values)
28  , mySize(array_size)
29  , myTupleSize(tuple_size)
30  , myType(type)
31  {
32  }
33  ~GT_DAValues() override {}
34 
35  const T *getData() const { return myData; }
36 
37  const char *className() const override { return "GT_DAValues"; }
38  bool getPointerAliasing(const void *data) const override
39  { return myData == data; }
40 
41  /// @{
42  /// Methods defined on GT_DataArray
43  GT_Storage getStorage() const override
44  { return GTstorage<T>(); }
45  GT_Size getTupleSize() const override
46  { return myTupleSize; }
47  int64 getMemoryUsage() const override
48  { return sizeof(*this); }
49  GT_Size entries() const override
50  { return mySize; }
51  GT_Type getTypeInfo() const override
52  { return myType; }
53 
54  uint8 getU8(GT_Offset offset, int index=0) const override
55  {
56  offset = offset * myTupleSize + index;
57  UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
58  return myData[offset];
59  }
60  int32 getI32(GT_Offset offset, int index=0) const override
61  {
62  offset = offset * myTupleSize + index;
63  UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
64  return myData[offset];
65  }
66  int64 getI64(GT_Offset offset, int index=0) const override
67  {
68  offset = offset * myTupleSize + index;
69  UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
70  return myData[offset];
71  }
72  fpreal16 getF16(GT_Offset offset, int index=0) const override
73  {
74  offset = offset * myTupleSize + index;
75  UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
76  return myData[offset];
77  }
78  fpreal32 getF32(GT_Offset offset, int index=0) const override
79  {
80  offset = offset * myTupleSize + index;
81  UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
82  return myData[offset];
83  }
84  fpreal64 getF64(GT_Offset offset, int index=0) const override
85  {
86  offset = offset * myTupleSize + index;
87  UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
88  return myData[offset];
89  }
90  GT_String getS(GT_Offset, int) const override
92  GT_Size getStringIndexCount() const override
93  { return -1; }
94  GT_Offset getStringIndex(GT_Offset, int) const override
95  { return -1; }
97  UT_IntArray &) const override {}
98  /// @}
99 
100  const int32 *get(GT_Offset offset,
101  int32 *buf, int size) const override
102  {
103  const T *data = myData + offset*myTupleSize;
104  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
105  for (int i = 0; i < size; i++)
106  buf[i] = data[i];
107  return buf;
108  }
109  const int64 *get(GT_Offset offset,
110  int64 *buf, int size) const override
111  {
112  const T *data = myData + offset*myTupleSize;
113  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
114  for (int i = 0; i < size; i++)
115  buf[i] = data[i];
116  return buf;
117  }
119  fpreal16 *buf, int size) const override
120  {
121  const T *data = myData + offset*myTupleSize;
122  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
123  for (int i = 0; i < size; i++)
124  buf[i] = data[i];
125  return buf;
126  }
128  fpreal32 *buf, int size) const override
129  {
130  const T *data = myData + offset*myTupleSize;
131  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
132  for (int i = 0; i < size; i++)
133  buf[i] = data[i];
134  return buf;
135  }
137  fpreal64 *buf, int size) const override
138  {
139  const T *data = myData + offset*myTupleSize;
140  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
141  for (int i = 0; i < size; i++)
142  buf[i] = data[i];
143  return buf;
144  }
145 private:
146  const T *myData;
147  GT_Size myTupleSize;
148  GT_Size mySize;
149  GT_Type myType;
150 };
151 
157 
158 #endif
GT_Storage
Definition: GT_Types.h:18
int int32
Definition: SYS_Types.h:39
fpreal32 getF32(GT_Offset offset, int index=0) const override
Definition: GT_DAValues.h:78
bool getPointerAliasing(const void *data) const override
Return "true" if there's pointer aliasing.
Definition: GT_DAValues.h:38
GT_DAValues< int64 > GT_I64Values
Definition: GT_DAValues.h:153
GT_Size entries() const override
Definition: GT_DAValues.h:49
GT_Type
Definition: GT_Types.h:34
int64 getI64(GT_Offset offset, int index=0) const override
Definition: GT_DAValues.h:66
GT_Size getStringIndexCount() const override
Definition: GT_DAValues.h:92
float fpreal32
Definition: SYS_Types.h:200
GT_DAValues< fpreal16 > GT_F16Values
Definition: GT_DAValues.h:154
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
GT_DAValues(const T *values, GT_Size array_size, int tuple_size, GT_Type type=GT_TYPE_NONE)
Definition: GT_DAValues.h:25
GLsizeiptr size
Definition: glcorearb.h:664
GT_DAValues< fpreal64 > GT_F64Values
Definition: GT_DAValues.h:156
double fpreal64
Definition: SYS_Types.h:201
unsigned char uint8
Definition: SYS_Types.h:36
const T * getData() const
Definition: GT_DAValues.h:35
const char * className() const override
Definition: GT_DAValues.h:37
Abstract data class for an array of float, int or string data.
Definition: GT_DataArray.h:40
GT_Offset getStringIndex(GT_Offset, int) const override
Definition: GT_DAValues.h:94
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:152
static const UT_StringHolder theEmptyString
GT_DAValues< int32 > GT_I32Values
Definition: GT_DAValues.h:152
GT_DAValues< fpreal32 > GT_F32Values
Definition: GT_DAValues.h:155
GT_Type getTypeInfo() const override
Definition: GT_DAValues.h:51
int64 GT_Offset
Definition: GT_Types.h:124
long long int64
Definition: SYS_Types.h:116
GT_Storage getStorage() const override
Definition: GT_DAValues.h:43
fpreal16 getF16(GT_Offset offset, int index=0) const override
Definition: GT_DAValues.h:72
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
fpreal64 getF64(GT_Offset offset, int index=0) const override
Definition: GT_DAValues.h:84
GLboolean * data
Definition: glcorearb.h:131
uint8 getU8(GT_Offset offset, int index=0) const override
Definition: GT_DAValues.h:54
int64 GT_Size
Definition: GT_Types.h:123
GLuint index
Definition: glcorearb.h:786
~GT_DAValues() override
Definition: GT_DAValues.h:33
int64 getMemoryUsage() const override
Definition: GT_DAValues.h:47
GT_String getS(GT_Offset, int) const override
Definition: GT_DAValues.h:90
void getIndexedStrings(UT_StringArray &, UT_IntArray &) const override
Definition: GT_DAValues.h:96
GLintptr offset
Definition: glcorearb.h:665
An array of const values.
Definition: GT_DAValues.h:23
int32 getI32(GT_Offset offset, int index=0) const override
Definition: GT_DAValues.h:60
type
Definition: core.h:1059
GT_Size getTupleSize() const override
Definition: GT_DAValues.h:45
Definition: format.h:895