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  virtual ~GT_DAValues() {}
34 
35  const T *getData() const { return myData; }
36 
37  virtual const char *className() const { return "GT_DAValues"; }
38  virtual bool getPointerAliasing(const void *data) const
39  { return myData == data; }
40 
41  /// @{
42  /// Methods defined on GT_DataArray
43  virtual GT_Storage getStorage() const { return GTstorage<T>(); }
44  virtual GT_Size getTupleSize() const { return myTupleSize; }
45  virtual int64 getMemoryUsage() const { return sizeof(*this); }
46  virtual GT_Size entries() const { return mySize; }
47  virtual GT_Type getTypeInfo() const { return myType; }
48 
49  virtual uint8 getU8(GT_Offset offset, int index=0) const
50  {
51  offset = offset * myTupleSize + index;
52  UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
53  return myData[offset];
54  }
55  virtual int32 getI32(GT_Offset offset, int index=0) const
56  {
57  offset = offset * myTupleSize + index;
58  UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
59  return myData[offset];
60  }
61  virtual int64 getI64(GT_Offset offset, int index=0) const
62  {
63  offset = offset * myTupleSize + index;
64  UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
65  return myData[offset];
66  }
67  virtual fpreal16 getF16(GT_Offset offset, int index=0) const
68  {
69  offset = offset * myTupleSize + index;
70  UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
71  return myData[offset];
72  }
73  virtual fpreal32 getF32(GT_Offset offset, int index=0) const
74  {
75  offset = offset * myTupleSize + index;
76  UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
77  return myData[offset];
78  }
79  virtual fpreal64 getF64(GT_Offset offset, int index=0) const
80  {
81  offset = offset * myTupleSize + index;
82  UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
83  return myData[offset];
84  }
85  virtual GT_String getS(GT_Offset, int) const
87  virtual GT_Size getStringIndexCount() const { return -1; }
88  virtual GT_Offset getStringIndex(GT_Offset, int) const { return -1; }
90  UT_IntArray &) const {}
91  /// @}
92 
93  virtual const int32 *get(GT_Offset offset, int32 *buf, int size) const
94  {
95  const T *data = myData + offset*myTupleSize;
96  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
97  for (int i = 0; i < size; i++)
98  buf[i] = data[i];
99  return buf;
100  }
101  virtual const int64 *get(GT_Offset offset, int64 *buf, int size) const
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  virtual const fpreal16 *get(GT_Offset offset, fpreal16 *buf, int size) const
110  {
111  const T *data = myData + offset*myTupleSize;
112  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
113  for (int i = 0; i < size; i++)
114  buf[i] = data[i];
115  return buf;
116  }
117  virtual const fpreal32 *get(GT_Offset offset, fpreal32 *buf, int size) const
118  {
119  const T *data = myData + offset*myTupleSize;
120  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
121  for (int i = 0; i < size; i++)
122  buf[i] = data[i];
123  return buf;
124  }
125  virtual const fpreal64 *get(GT_Offset offset, fpreal64 *buf, int size) const
126  {
127  const T *data = myData + offset*myTupleSize;
128  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
129  for (int i = 0; i < size; i++)
130  buf[i] = data[i];
131  return buf;
132  }
133 private:
134  const T *myData;
135  GT_Size myTupleSize;
136  GT_Size mySize;
137  GT_Type myType;
138 };
139 
145 
146 #endif
GT_Storage
Definition: GT_Types.h:18
virtual ~GT_DAValues()
Definition: GT_DAValues.h:33
GLsizeiptr size
Definition: glew.h:1681
GLuint index
Definition: glew.h:1814
GT_DAValues< int64 > GT_I64Values
Definition: GT_DAValues.h:141
virtual uint8 getU8(GT_Offset offset, int index=0) const
Definition: GT_DAValues.h:49
virtual GT_Offset getStringIndex(GT_Offset, int) const
Definition: GT_DAValues.h:88
GLint GLsizei const GLuint64 * values
Definition: glew.h:3612
virtual fpreal32 getF32(GT_Offset offset, int index=0) const
Definition: GT_DAValues.h:73
GT_Type
Definition: GT_Types.h:34
GT_DAValues< fpreal16 > GT_F16Values
Definition: GT_DAValues.h:142
virtual GT_Type getTypeInfo() const
Definition: GT_DAValues.h:47
virtual GT_Storage getStorage() const
Definition: GT_DAValues.h:43
virtual int64 getMemoryUsage() const
Definition: GT_DAValues.h:45
GT_DAValues(const T *values, GT_Size array_size, int tuple_size, GT_Type type=GT_TYPE_NONE)
Definition: GT_DAValues.h:25
GT_DAValues< fpreal64 > GT_F64Values
Definition: GT_DAValues.h:144
virtual int64 getI64(GT_Offset offset, int index=0) const
Definition: GT_DAValues.h:61
long long int64
Definition: SYS_Types.h:111
const T * getData() const
Definition: GT_DAValues.h:35
Abstract data class for an array of float, int or string data.
Definition: GT_DataArray.h:39
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:134
static const UT_StringHolder theEmptyString
double fpreal64
Definition: SYS_Types.h:196
GT_DAValues< int32 > GT_I32Values
Definition: GT_DAValues.h:140
GT_DAValues< fpreal32 > GT_F32Values
Definition: GT_DAValues.h:143
int64 GT_Offset
Definition: GT_Types.h:114
virtual GT_Size getStringIndexCount() const
Definition: GT_DAValues.h:87
virtual void getIndexedStrings(UT_StringArray &, UT_IntArray &) const
Definition: GT_DAValues.h:89
virtual GT_Size getTupleSize() const
Definition: GT_DAValues.h:44
int int32
Definition: SYS_Types.h:39
virtual GT_String getS(GT_Offset, int) const
Definition: GT_DAValues.h:85
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
virtual bool getPointerAliasing(const void *data) const
Return "true" if there's pointer aliasing.
Definition: GT_DAValues.h:38
int64 GT_Size
Definition: GT_Types.h:113
virtual const char * className() const
Definition: GT_DAValues.h:37
virtual GT_Size entries() const
Definition: GT_DAValues.h:46
unsigned char uint8
Definition: SYS_Types.h:36
virtual fpreal64 getF64(GT_Offset offset, int index=0) const
Definition: GT_DAValues.h:79
virtual int32 getI32(GT_Offset offset, int index=0) const
Definition: GT_DAValues.h:55
An array of const values.
Definition: GT_DAValues.h:23
virtual fpreal16 getF16(GT_Offset offset, int index=0) const
Definition: GT_DAValues.h:67
GLenum GLuint GLsizei const GLchar * buf
Definition: glew.h:2580
float fpreal32
Definition: SYS_Types.h:195
GLintptr offset
Definition: glew.h:1682