HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 { return NULL; }
49  virtual GT_Size getStringIndexCount() const { return -1; }
50  virtual GT_Offset getStringIndex(GT_Offset, int) const { return -1; }
52  UT_IntArray &) const {}
53  /// @}
54 
55  /// Get the bit at the given index
56  bool getBit(GT_Offset i, GT_Size tidx=0) const
57  {
58  UT_ASSERT(tidx >= 0 && tidx < myTupleSize);
59  return myBits[tidx]->getBit(i);
60  }
61  /// Set the bit at the given index -- returns the previous value
62  bool setBit(GT_Offset i, bool v, GT_Size tidx=0)
63  {
64  UT_ASSERT(tidx >= 0 && tidx < myTupleSize);
65  return myBits[tidx]->setBit(i, v);
66  }
67  void setAllBits(bool v, GT_Size tidx=0)
68  {
69  UT_ASSERT(tidx >= 0 && tidx < myTupleSize);
70  myBits[tidx]->setAllBits(v);
71  }
72 
73 protected:
74  /// {@
75  /// Import data
76  virtual void doImport(GT_Offset i, uint8 *data, GT_Size sz) const;
77  virtual void doImport(GT_Offset i, int32 *data, GT_Size sz) const;
78  virtual void doImport(GT_Offset i, int64 *data, GT_Size sz) const;
79  virtual void doImport(GT_Offset i, fpreal16 *data, GT_Size sz) const;
80  virtual void doImport(GT_Offset i, fpreal32 *data, GT_Size sz) const;
81  virtual void doImport(GT_Offset i, fpreal64 *data, GT_Size sz) const;
82 
83  virtual void dofillArray(uint8 *buf, GT_Offset start, GT_Size len,
84  int tsize, int stride) const;
85  virtual void dofillArray(int32 *buf, GT_Offset start, GT_Size len,
86  int tsize, int stride) const;
87  virtual void dofillArray(int64 *buf, GT_Offset start, GT_Size len,
88  int tsize, int stride) const;
89  virtual void dofillArray(fpreal16 *buf, GT_Offset start, GT_Size len,
90  int tsize, int stride) const;
91  virtual void dofillArray(fpreal32 *buf, GT_Offset start, GT_Size len,
92  int tsize, int stride) const;
93  virtual void dofillArray(fpreal64 *buf, GT_Offset start, GT_Size len,
94  int tsize, int stride) const;
95  /// @}
96 
97  /// @{
98  /// Virtual interface implemented by calling existing methods
100  GT_Size length, int tsize, int stride,
101  fpreal, fpreal) const
102  {
103  doFillArray(data, start, length, tsize, stride);
104  }
106  GT_Size length, int nrepeats,
107  int tsize, int stride,
108  fpreal black, fpreal white) const
109  {
110  if (nrepeats == 1)
111  {
112  doFillQuantizedArray(data, start, length, tsize,
113  stride, black, white);
114  }
115  else
116  {
118  start, length, tsize,
119  nrepeats, stride, black, white);
120  }
121  }
122  /// @}
123 
124 private:
125  UT_BitArray **myBits;
126  GT_Size myTupleSize;
127  GT_Type myType;
128 };
129 
130 #endif
GT_Storage
Definition: GT_Types.h:17
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:417
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:105
virtual GT_Size entries() const
Definition: GT_DABool.h:30
const GLdouble * v
Definition: glcorearb.h:836
GLuint start
Definition: glcorearb.h:474
const char * GT_String
Definition: GT_Types.h:108
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:31
GT Data Array for booleans.
Definition: GT_DABool.h:19
void setAllBits(bool v, GT_Size tidx=0)
Definition: GT_DABool.h:67
virtual GT_String getS(GT_Offset, int) const
Definition: GT_DABool.h:48
png_uint_32 i
Definition: png.h:2877
virtual void getIndexedStrings(UT_StringArray &, UT_IntArray &) const
Definition: GT_DABool.h:51
long long int64
Definition: SYS_Types.h:100
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:62
Abstract data class for an array of float, int or string data.
Definition: GT_DataArray.h:38
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
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:102
virtual void doFillQuantizedArray(uint8 *data, GT_Offset start, GT_Size length, int tsize, int stride, fpreal, fpreal) const
Definition: GT_DABool.h:99
virtual GT_Type getTypeInfo() const
Definition: GT_DABool.h:34
double fpreal64
Definition: SYS_Types.h:185
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:871
virtual void doFillArray(uint8 *data, GT_Offset start, GT_Size length, int tuple_size, int stride) const
Definition: GT_DataArray.h:397
GLboolean * data
Definition: glcorearb.h:130
virtual GT_Size getStringIndexCount() const
Definition: GT_DABool.h:49
int int32
Definition: SYS_Types.h:28
virtual fpreal16 getF16(GT_Offset i, int tidx=0) const
Definition: GT_DABool.h:42
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2539
double fpreal
Definition: SYS_Types.h:263
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:25
virtual int32 getI32(GT_Offset i, int tidx=0) const
Definition: GT_DABool.h:38
virtual int64 getMemoryUsage() const =0
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
virtual void doExtendedQuantizedFill(uint8 *data, GT_Offset start, GT_Size length, int tuple_size, int nrepeats, int stride, fpreal black, fpreal white) const
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:56
int64 GT_Offset
Definition: GT_Types.h:110
int64 GT_Size
Definition: GT_Types.h:109
virtual GT_DataArrayHandle harden() const
Create a "hardened" version of the array.
float fpreal32
Definition: SYS_Types.h:184
virtual GT_Offset getStringIndex(GT_Offset, int) const
Definition: GT_DABool.h:50
virtual int64 getI64(GT_Offset i, int tidx=0) const
Definition: GT_DABool.h:40
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:794