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