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  GT_Size getDictIndexCount() const override
57  { return -1; }
58  GT_Offset getDictIndex(GT_Offset, int) const override
59  { return -1; }
61  UT_IntArray &) const override {}
62  /// @}
63 
64  /// Get the bit at the given index
65  bool getBit(GT_Offset i, GT_Size tidx=0) const
66  {
67  UT_ASSERT(tidx >= 0 && tidx < myTupleSize);
68  return myBits[tidx]->getBit(i);
69  }
70  /// Set the bit at the given index -- returns the previous value
71  bool setBit(GT_Offset i, bool v, GT_Size tidx=0)
72  {
73  UT_ASSERT(tidx >= 0 && tidx < myTupleSize);
74  return myBits[tidx]->setBit(i, v);
75  }
76  void setAllBits(bool v, GT_Size tidx=0)
77  {
78  UT_ASSERT(tidx >= 0 && tidx < myTupleSize);
79  myBits[tidx]->setAllBits(v);
80  }
81 
82 protected:
83  /// {@
84  /// Import data
85  void doImport(GT_Offset i, uint8 *data, GT_Size sz) const override;
86  void doImport(GT_Offset i, int8 *data, GT_Size sz) const override;
87  void doImport(GT_Offset i, int16 *data, GT_Size sz) const override;
88  void doImport(GT_Offset i, int32 *data, GT_Size sz) const override;
89  void doImport(GT_Offset i, int64 *data, GT_Size sz) const override;
90  void doImport(GT_Offset i, fpreal16 *data, GT_Size sz) const override;
91  void doImport(GT_Offset i, fpreal32 *data, GT_Size sz) const override;
92  void doImport(GT_Offset i, fpreal64 *data, GT_Size sz) const override;
93 
94  virtual void dofillArray(uint8 *buf, GT_Offset start, GT_Size len,
95  int tsize, int stride) const;
96  virtual void dofillArray(int32 *buf, GT_Offset start, GT_Size len,
97  int tsize, int stride) const;
98  virtual void dofillArray(int64 *buf, GT_Offset start, GT_Size len,
99  int tsize, int stride) const;
100  virtual void dofillArray(fpreal16 *buf, GT_Offset start, GT_Size len,
101  int tsize, int stride) const;
102  virtual void dofillArray(fpreal32 *buf, GT_Offset start, GT_Size len,
103  int tsize, int stride) const;
104  virtual void dofillArray(fpreal64 *buf, GT_Offset start, GT_Size len,
105  int tsize, int stride) const;
106  /// @}
107 
108  /// @{
109  /// Virtual interface implemented by calling existing methods
111  GT_Size length, int tsize, int stride,
112  fpreal, fpreal) const override
113  {
114  doFillArray(data, start, length, tsize, stride);
115  }
117  GT_Size length, int nrepeats,
118  int tsize, int stride,
119  fpreal black, fpreal white) const override
120  {
121  if (nrepeats == 1)
122  {
123  doFillQuantizedArray(data, start, length, tsize,
124  stride, black, white);
125  }
126  else
127  {
129  start, length, tsize,
130  nrepeats, stride, black, white);
131  }
132  }
133  /// @}
134 
135 private:
136  UT_BitArray **myBits;
137  GT_Size myTupleSize;
138  GT_Type myType;
139 };
140 
141 #endif
GT_Storage
Definition: GT_Types.h:19
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
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:750
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:110
uint8 getU8(GT_Offset i, int tidx=0) const override
Definition: GT_DABool.h:36
const GLdouble * v
Definition: glcorearb.h:837
GLuint start
Definition: glcorearb.h:475
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:13
GT_Type
Definition: GT_Types.h:36
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
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
GT_Type getTypeInfo() const override
Definition: GT_DABool.h:34
void setAllBits(bool v, GT_Size tidx=0)
Definition: GT_DABool.h:76
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:116
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:71
Abstract data class for an array of float, int or string data.
Definition: GT_DataArray.h:40
GT_Offset getDictIndex(GT_Offset, int) const override
Definition: GT_DABool.h:58
static const UT_StringHolder theEmptyString
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:872
int64 GT_Offset
Definition: GT_Types.h:129
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:700
signed char int8
Definition: SYS_Types.h:35
int64 GT_Size
Definition: GT_Types.h:128
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
void getIndexedDicts(UT_Array< UT_OptionsHolder > &, UT_IntArray &) const override
Definition: GT_DABool.h:60
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
GT_Size getDictIndexCount() const override
Definition: GT_DABool.h:56
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
bool getBit(GT_Offset i, GT_Size tidx=0) const
Get the bit at the given index.
Definition: GT_DABool.h:65
type
Definition: core.h:1059
virtual GT_DataArrayHandle harden() const
Create a "hardened" version of the array.
Definition: format.h:895
fpreal16 getF16(GT_Offset i, int tidx=0) const override
Definition: GT_DABool.h:42
void getIndexedStrings(UT_StringArray &, UT_IntArray &) const override
Definition: GT_DABool.h:54