HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_DAConstant.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_DAConstant.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_DAConstant__
12 #define __GT_DAConstant__
13 
14 #include "GT_API.h"
15 #include "GT_DAInherit.h"
16 
17 #include <UT/UT_ValArray.h>
18 
19 /// @brief Extend a single element from a source array to emulate a larger array
20 ///
21 /// Given a source data array, this class will emulate a larger array by
22 /// extending a single element from the source array over a given size.
23 /// For example: @code
24 /// GT_DataArray &src;
25 /// GT_DAConstant varying;
26 /// varying.init(32, 100);
27 /// @endcode
28 /// Creates an array of 100 entries referencing element 32 from the source
29 /// array.
31 public:
32  /// Default constructor
34  : mySize(0)
35  , myOffset(0)
36  , GT_DAInherit()
37  {
38  }
39  /// Useful constructor
42  : myOffset(offset)
43  , mySize(size)
44  , GT_DAInherit(data)
45  {
46  }
47  /// Copy constructor
49  : myOffset(src.myOffset),
50  mySize(src.mySize),
51  GT_DAInherit(src)
52  {
53  }
54  ~GT_DAConstant() override;
55 
56  const char *className() const override { return "GT_DAConstant"; }
57 
58  GT_Size itemSize(GT_Offset) const override
59  { return GT_DAInherit::itemSize(myOffset); }
60  GT_Size getTotalArrayEntries() const override
61  { return mySize * itemSize(myOffset); }
62 
63  /// Create a constant data array from the existing data array.
64  static const GT_DataArrayHandle createConstant(
65  const GT_DataArrayHandle &h,
67  GT_Size size);
68 
69  /// Initialize with given data
72  {
73  GT_DAInherit::init(data);
74  myOffset = offset;
75  mySize = size;
76  }
77 
78  GT_IMPL_INHERIT_ARRAY(getIndirect, mySize)
79 
80 private:
81  /// Map the requested offset to the offset in my data
82  inline GT_Offset getIndirect(GT_Offset) const
83  { return myOffset; }
84 
85  GT_Offset myOffset;
86  GT_Size mySize;
87 };
88 
89 #endif
GT_Size itemSize(GT_Offset offset) const override
Definition: GT_DAInherit.h:52
const char * className() const override
Definition: GT_DAConstant.h:56
Extend a single element from a source array to emulate a larger array.
Definition: GT_DAConstant.h:30
#define GT_API
Definition: GT_API.h:11
GT_Size getTotalArrayEntries() const override
Definition: GT_DAConstant.h:60
GLenum src
Definition: glcorearb.h:1793
GLsizeiptr size
Definition: glcorearb.h:664
GT_DAConstant(const GT_DAConstant &src)
Copy constructor.
Definition: GT_DAConstant.h:48
void init(const GT_DataArrayHandle &data, GT_Offset offset, GT_Size size)
Initialize with given data.
Definition: GT_DAConstant.h:70
int64 GT_Offset
Definition: GT_Types.h:124
GT_DAConstant(const GT_DataArrayHandle &data, GT_Offset offset, GT_Size size)
Useful constructor.
Definition: GT_DAConstant.h:40
int64 GT_Size
Definition: GT_Types.h:123
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
Base class for a data array which references another data array.
Definition: GT_DAInherit.h:18
#define GT_IMPL_INHERIT_ARRAY(MAP_INDEX, SIZE)
Definition: GT_DAInherit.h:83
GT_Size itemSize(GT_Offset) const override
Return the number of elements in the array for the given item.
Definition: GT_DAConstant.h:58
void init(const GT_DataArrayHandle &data)
Definition: GT_DAInherit.h:32
GLintptr offset
Definition: glcorearb.h:665
GT_DAConstant()
Default constructor.
Definition: GT_DAConstant.h:33
Definition: format.h:895