HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_DABool.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_DABool.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_DABool__
12 #define __GT_DABool__
13 
14 #include "GT_API.h"
15 #include <UT/UT_BitArray.h>
16 #include "GT_DataArray.h"
17 
18 /// GT Data Array for booleans
20 {
21 public:
22  GT_DABool(GT_Size array_size, GT_Size tuple_size=1,
24  ~GT_DABool() override;
25 
26  /// @{
27  /// Virtual interface defined on GT_DataArray
28  const char *className() const override { return "GT_DABool"; }
29  GT_DataArrayHandle harden() const override;
30  GT_Size entries() const override { return myBits[0]->size(); }
31  GT_Storage getStorage() const override { return GT_STORE_UINT8; }
32  GT_Size getTupleSize() const override { return myTupleSize; }
33  int64 getMemoryUsage() const override;
34  GT_Type getTypeInfo() const override { return myType; }
35 
36  uint8 getU8(GT_Offset i, int tidx=0) const override
37  { return getBit(i, tidx); }
38  int32 getI32(GT_Offset i, int tidx=0) const override
39  { return getBit(i, tidx); }
40  int64 getI64(GT_Offset i, int tidx=0) const override
41  { return getBit(i, tidx); }
42  fpreal16 getF16(GT_Offset i, int tidx=0) const override
43  { return getBit(i, tidx); }
44  fpreal32 getF32(GT_Offset i, int tidx=0) const override
45  { return getBit(i, tidx); }
46  fpreal64 getF64(GT_Offset i, int tidx=0) const override
47  { return getBit(i, tidx); }
48  GT_String getS(GT_Offset, int) const override
50  GT_Size getStringIndexCount() const override
51  { return -1; }
52  GT_Offset getStringIndex(GT_Offset, int) const override
53  { return -1; }
55  UT_IntArray &) const override {}
56  /// @}
57 
58  /// Get the bit at the given index
59  bool getBit(GT_Offset i, GT_Size tidx=0) const
60  {
61  UT_ASSERT(tidx >= 0 && tidx < myTupleSize);
62  return myBits[tidx]->getBit(i);
63  }
64  /// Set the bit at the given index -- returns the previous value
65  bool setBit(GT_Offset i, bool v, GT_Size tidx=0)
66  {
67  UT_ASSERT(tidx >= 0 && tidx < myTupleSize);
68  return myBits[tidx]->setBit(i, v);
69  }
70  void setAllBits(bool v, GT_Size tidx=0)
71  {
72  UT_ASSERT(tidx >= 0 && tidx < myTupleSize);
73  myBits[tidx]->setAllBits(v);
74  }
75 
76 protected:
77  /// {@
78  /// Import data
79  void doImport(GT_Offset i, uint8 *data, GT_Size sz) const override;
80  void doImport(GT_Offset i, int8 *data, GT_Size sz) const override;
81  void doImport(GT_Offset i, int16 *data, GT_Size sz) const override;
82  void doImport(GT_Offset i, int32 *data, GT_Size sz) const override;
83  void doImport(GT_Offset i, int64 *data, GT_Size sz) const override;
84  void doImport(GT_Offset i, fpreal16 *data, GT_Size sz) const override;
85  void doImport(GT_Offset i, fpreal32 *data, GT_Size sz) const override;
86  void doImport(GT_Offset i, fpreal64 *data, GT_Size sz) const override;
87 
88  virtual void dofillArray(uint8 *buf, GT_Offset start, GT_Size len,
89  int tsize, int stride) const;
90  virtual void dofillArray(int32 *buf, GT_Offset start, GT_Size len,
91  int tsize, int stride) const;
92  virtual void dofillArray(int64 *buf, GT_Offset start, GT_Size len,
93  int tsize, int stride) const;
94  virtual void dofillArray(fpreal16 *buf, GT_Offset start, GT_Size len,
95  int tsize, int stride) const;
96  virtual void dofillArray(fpreal32 *buf, GT_Offset start, GT_Size len,
97  int tsize, int stride) const;
98  virtual void dofillArray(fpreal64 *buf, GT_Offset start, GT_Size len,
99  int tsize, int stride) const;
100  /// @}
101 
102  /// @{
103  /// Virtual interface implemented by calling existing methods
105  GT_Size length, int tsize, int stride,
106  fpreal, fpreal) const override
107  {
108  doFillArray(data, start, length, tsize, stride);
109  }
111  GT_Size length, int nrepeats,
112  int tsize, int stride,
113  fpreal black, fpreal white) const override
114  {
115  if (nrepeats == 1)
116  {
117  doFillQuantizedArray(data, start, length, tsize,
118  stride, black, white);
119  }
120  else
121  {
123  start, length, tsize,
124  nrepeats, stride, black, white);
125  }
126  }
127  /// @}
128 
129 private:
130  UT_BitArray **myBits;
131  GT_Size myTupleSize;
132  GT_Type myType;
133 };
134 
135 #endif
GT_Storage
Definition: GT_Types.h:18
virtual void doFillQuantizedArray(uint8 *data, GT_Offset start, GT_Size length, int tuple_size, int stride, fpreal black, fpreal white) const
Definition: GT_DataArray.h:710
int int32
Definition: SYS_Types.h:39
GT_Size getTupleSize() const override
Definition: GT_DABool.h:32
void doFillQuantizedArray(uint8 *data, GT_Offset start, GT_Size length, int tsize, int stride, fpreal, fpreal) const override
Definition: GT_DABool.h:104
uint8 getU8(GT_Offset i, int tidx=0) const override
Definition: GT_DABool.h:36
GT_String getS(GT_Offset, int) const override
Definition: GT_DABool.h:48
virtual void doImport(GT_Offset idx, uint8 *data, GT_Size size) const
int32 getI32(GT_Offset i, int tidx=0) const override
Definition: GT_DABool.h:38
#define GT_API
Definition: GT_API.h:11
GT_Type
Definition: GT_Types.h:34
GT Data Array for booleans.
Definition: GT_DABool.h:19
int64 getI64(GT_Offset i, int tidx=0) const override
Definition: GT_DABool.h:40
const GLdouble * v
Definition: glew.h:1391
GT_Type getTypeInfo() const override
Definition: GT_DABool.h:34
void setAllBits(bool v, GT_Size tidx=0)
Definition: GT_DABool.h:70
float fpreal32
Definition: SYS_Types.h:200
double fpreal64
Definition: SYS_Types.h:201
GT_Size entries() const override
Definition: GT_DABool.h:30
unsigned char uint8
Definition: SYS_Types.h:36
fpreal32 getF32(GT_Offset i, int tidx=0) const override
Definition: GT_DABool.h:44
GT_Storage getStorage() const override
Definition: GT_DABool.h:31
void doExtendedQuantizedFill(uint8 *data, GT_Offset start, GT_Size length, int nrepeats, int tsize, int stride, fpreal black, fpreal white) const override
Definition: GT_DABool.h:110
const char * className() const override
Definition: GT_DABool.h:28
bool setBit(GT_Offset i, bool v, GT_Size tidx=0)
Set the bit at the given index – returns the previous value.
Definition: GT_DABool.h:65
Abstract data class for an array of float, int or string data.
Definition: GT_DataArray.h:40
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
static const UT_StringHolder theEmptyString
GLuint GLsizei GLsizei * length
Definition: glew.h:1825
int64 GT_Offset
Definition: GT_Types.h:114
long long int64
Definition: SYS_Types.h:116
virtual void doFillArray(uint8 *data, GT_Offset start, GT_Size length, int tuple_size, int stride) const
Definition: GT_DataArray.h:660
signed char int8
Definition: SYS_Types.h:35
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
GLuint start
Definition: glew.h:1253
GLsizei stride
Definition: glew.h:1523
int64 GT_Size
Definition: GT_Types.h:113
fpreal64 getF64(GT_Offset i, int tidx=0) const override
Definition: GT_DABool.h:46
short int16
Definition: SYS_Types.h:37
fpreal64 fpreal
Definition: SYS_Types.h:277
GT_Size getStringIndexCount() const override
Definition: GT_DABool.h:50
virtual int64 getMemoryUsage() const =0
GT_Offset getStringIndex(GT_Offset, int) const override
Definition: GT_DABool.h:52
virtual void doExtendedQuantizedFill(uint8 *data, GT_Offset start, GT_Size length, int tuple_size, int nrepeats, int stride, fpreal black, fpreal white) const
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:135
bool getBit(GT_Offset i, GT_Size tidx=0) const
Get the bit at the given index.
Definition: GT_DABool.h:59
GLenum GLuint GLsizei const GLchar * buf
Definition: glew.h:2580
virtual GT_DataArrayHandle harden() const
Create a "hardened" version of the array.
fpreal16 getF16(GT_Offset i, int tidx=0) const override
Definition: GT_DABool.h:42
GLenum GLsizei len
Definition: glew.h:7752
void getIndexedStrings(UT_StringArray &, UT_IntArray &) const override
Definition: GT_DABool.h:54