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 { return NULL; }
86  virtual GT_Size getStringIndexCount() const { return -1; }
87  virtual GT_Offset getStringIndex(GT_Offset, int) const { return -1; }
89  UT_IntArray &) const {}
90  /// @}
91 
92  virtual const int32 *get(GT_Offset offset, int32 *buf, int size) const
93  {
94  const T *data = myData + offset*myTupleSize;
95  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
96  for (int i = 0; i < size; i++)
97  buf[i] = data[i];
98  return buf;
99  }
100  virtual const int64 *get(GT_Offset offset, int64 *buf, int size) const
101  {
102  const T *data = myData + offset*myTupleSize;
103  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
104  for (int i = 0; i < size; i++)
105  buf[i] = data[i];
106  return buf;
107  }
108  virtual const fpreal16 *get(GT_Offset offset, fpreal16 *buf, int size) const
109  {
110  const T *data = myData + offset*myTupleSize;
111  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
112  for (int i = 0; i < size; i++)
113  buf[i] = data[i];
114  return buf;
115  }
116  virtual const fpreal32 *get(GT_Offset offset, fpreal32 *buf, int size) const
117  {
118  const T *data = myData + offset*myTupleSize;
119  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
120  for (int i = 0; i < size; i++)
121  buf[i] = data[i];
122  return buf;
123  }
124  virtual const fpreal64 *get(GT_Offset offset, fpreal64 *buf, int size) const
125  {
126  const T *data = myData + offset*myTupleSize;
127  UT_ASSERT_P(offset < mySize && size <= myTupleSize);
128  for (int i = 0; i < size; i++)
129  buf[i] = data[i];
130  return buf;
131  }
132 private:
133  const T *myData;
134  GT_Size myTupleSize;
135  GT_Size mySize;
136  GT_Type myType;
137 };
138 
144 
145 #endif
GT_Storage
Definition: GT_Types.h:17
virtual ~GT_DAValues()
Definition: GT_DAValues.h:33
const char * GT_String
Definition: GT_Types.h:111
GT_DAValues< int64 > GT_I64Values
Definition: GT_DAValues.h:140
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:87
virtual fpreal32 getF32(GT_Offset offset, int index=0) const
Definition: GT_DAValues.h:73
GT_Type
Definition: GT_Types.h:33
png_uint_32 i
Definition: png.h:2877
GT_DAValues< fpreal16 > GT_F16Values
Definition: GT_DAValues.h:141
GLsizeiptr size
Definition: glcorearb.h:663
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:143
virtual int64 getI64(GT_Offset offset, int index=0) const
Definition: GT_DAValues.h:61
long long int64
Definition: SYS_Types.h:107
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:38
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:125
double fpreal64
Definition: SYS_Types.h:192
GT_DAValues< int32 > GT_I32Values
Definition: GT_DAValues.h:139
GT_DAValues< fpreal32 > GT_F32Values
Definition: GT_DAValues.h:142
GLintptr offset
Definition: glcorearb.h:664
virtual GT_Size getStringIndexCount() const
Definition: GT_DAValues.h:86
virtual void getIndexedStrings(UT_StringArray &, UT_IntArray &) const
Definition: GT_DAValues.h:88
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1601
virtual GT_Size getTupleSize() const
Definition: GT_DAValues.h:44
GLboolean * data
Definition: glcorearb.h:130
int int32
Definition: SYS_Types.h:35
virtual GT_String getS(GT_Offset, int) const
Definition: GT_DAValues.h:85
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2539
virtual bool getPointerAliasing(const void *data) const
Return "true" if there's pointer aliasing.
Definition: GT_DAValues.h:38
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:32
GLuint index
Definition: glcorearb.h:785
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
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
int64 GT_Offset
Definition: GT_Types.h:113
int64 GT_Size
Definition: GT_Types.h:112
virtual fpreal16 getF16(GT_Offset offset, int index=0) const
Definition: GT_DAValues.h:67
float fpreal32
Definition: SYS_Types.h:191