HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VEX_Types.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: VEX_Types.h ( VEX Library, C++)
7  *
8  * COMMENTS: Data types for VEX variables
9  */
10 
11 #ifndef __VEX_Types__
12 #define __VEX_Types__
13 
14 #include "VEX_API.h"
15 #include <SYS/SYS_StaticAssert.h>
16 #include <UT/UT_Vector3.h>
17 #include <UT/UT_Vector4.h>
18 #include <UT/UT_Matrix3.h>
19 #include <UT/UT_Matrix4.h>
20 #include "VEX_PodTypes.h"
21 #include "VEX_VexTypes.h"
22 #include "VEX_RefObject.h"
23 
24 template <VEX_Precision PREC> class VEX_Value;
25 template <VEX_Precision PREC> class VEX_Instance;
26 class VEX_ProcArray;
27 class VEX_OpCode;
28 class FS_DiskCache;
29 
31 {
32  VEX_STORE_UNDEF, // Undefined until a later date
33 
34  VEX_STORE_PARAMETER, // Possibly bound to some other source
35  VEX_STORE_LOCAL, // Local variable - storage deferred until bind
36  VEX_STORE_CONST, // Constant
37  VEX_STORE_GLOBAL, // Global variable
38 
39  VEX_MAX_STORAGE // Last entry is a counter only
40 };
41 
43 {
45  VEX_BASETYPE_INT, // Integer
48 };
49 
51 {
52  VEX_UI_NONE, // No ui hint
53  VEX_UI_COLOR, // Parameter represents a color
54  VEX_UI_DIRECTION, // a direction vector
55  VEX_UI_VECTOR, // a position vector
56  VEX_UI_VECTOR4, // a position vector 4
57  VEX_UI_UV, // a uv position
58  VEX_UI_UVW, // a uvw position
59  VEX_UI_ANGLE, // an angle
60  VEX_UI_TOGGLE, // a boolean toggle
61  VEX_UI_BUTTON, // a button for executing a callback
62  VEX_UI_FILE, // a filename
63  VEX_UI_IMGFILE, // an image file/ramp
64  VEX_UI_GEOFILE, // a geometry file
65  VEX_UI_OPPATH, // an operator path
66  VEX_UI_OPLIST, // a list of operator paths
67  VEX_UI_EMBED, // an embedded set of parameters
69 };
70 
71 class VEX_RWType {
72 public:
74  : myRead(false)
75  , myWrite(false) {}
76  VEX_RWType(bool read, bool write)
77  : myRead(read)
78  , myWrite(write) {}
79 
80  void setRead(bool r = true) { myRead = r; }
81  void setWrite(bool w = true) { myWrite = w; }
82  bool isRead() const { return myRead; }
83  bool isWrite() const { return myWrite; }
84 
85  bool operator==(const VEX_RWType &rhs) const
86  { return myRead == rhs.myRead &&
87  myWrite == rhs.myWrite; }
88  bool operator!=(const VEX_RWType &rhs) const
89  { return !(*this == rhs); }
90 
91  const char *asString() const
92  {
93  if (myRead && myWrite) return "modify";
94  if (myRead) return "read";
95  if (myWrite) return "write";
96  return "unused";
97  }
98 
99 private:
100  bool myRead;
101  bool myWrite;
102 };
103 
104 static const VEX_RWType VEX_RW_NONE(false, false);
105 static const VEX_RWType VEX_RW_READ(true, false);
106 static const VEX_RWType VEX_RW_WRITE(false, true);
107 static const VEX_RWType VEX_RW_MODIFY(true, true);
108 
109 VEX_API const char *VEXgetType(VEX_Type type);
113 VEX_API VEX_Type VEXgetType(const char *label);
114 VEX_API VEX_Type VEXgetType(const char *label, bool &isarray);
115 // Dangerous as there is no unique mapping.
116 // VEX_API VEX_Type VEXgetType(int size);
117 VEX_API VEX_Type VEXgetMangleType(char mangle);
121 VEX_API const char *VEXgetUIHint(VEX_UIHint type);
122 VEX_API VEX_UIHint VEXgetUIHint(const char *label);
123 
125 
126 static inline size_t
127 VEXsizeof32(VEX_Type type)
128 {
129  switch (type)
130  {
131  case VEX_TYPE_VECTOR4: return sizeof(VEXvec4<VEX_32>);
132  case VEX_TYPE_VECTOR: return sizeof(VEXvec3<VEX_32>);
133  case VEX_TYPE_VECTOR2: return sizeof(VEXvec2<VEX_32>);
134  case VEX_TYPE_FLOAT: return sizeof(VEXfloat<VEX_32>);
135  case VEX_TYPE_INTEGER: return sizeof(VEXint<VEX_32>);
136  case VEX_TYPE_STRING: return sizeof(UT_StringHolder);
137  case VEX_TYPE_MATRIX2: return sizeof(VEXmat2<VEX_32>);
138  case VEX_TYPE_MATRIX3: return sizeof(VEXmat3<VEX_32>);
139  case VEX_TYPE_MATRIX4: return sizeof(VEXmat4<VEX_32>);
140  case VEX_TYPE_BSDF: return sizeof(VEX_RefObject *);
141  default: break;
142  }
143  return 0;
144 }
145 static inline size_t
146 VEXsizeof64(VEX_Type type)
147 {
148  switch (type)
149  {
150  case VEX_TYPE_VECTOR4: return sizeof(VEXvec4<VEX_64>);
151  case VEX_TYPE_VECTOR: return sizeof(VEXvec3<VEX_64>);
152  case VEX_TYPE_VECTOR2: return sizeof(VEXvec2<VEX_64>);
153  case VEX_TYPE_FLOAT: return sizeof(VEXfloat<VEX_64>);
154  case VEX_TYPE_INTEGER: return sizeof(VEXint<VEX_64>);
155  case VEX_TYPE_STRING: return sizeof(UT_StringHolder);
156  case VEX_TYPE_MATRIX2: return sizeof(VEXmat2<VEX_64>);
157  case VEX_TYPE_MATRIX3: return sizeof(VEXmat3<VEX_64>);
158  case VEX_TYPE_MATRIX4: return sizeof(VEXmat4<VEX_64>);
159  case VEX_TYPE_BSDF: return sizeof(VEX_RefObject *);
160  default: break;
161  }
162  return 0;
163 }
164 
165 static inline size_t VEXsizeof(VEX_Type type) { return VEXsizeof32(type); }
166 
167 VEX_API int VEXgetArgCount(VEX_Type type); // Tuple size
168 VEX_API int VEXgetFloatCount(VEX_Type type); // Float-tuple size
169 
170 template <typename T> static inline constexpr int VEXtupleSize()
171  { SYS_UNIMPLEMENTED_TEMPLATE(T); return 0; }
172 template <> inline constexpr int VEXtupleSize<VEXint<VEX_32>>() { return 1; }
173 template <> inline constexpr int VEXtupleSize<VEXint<VEX_64>>() { return 1; }
174 template <> inline constexpr int VEXtupleSize<VEXfloat<VEX_32>>() { return 1; }
175 template <> inline constexpr int VEXtupleSize<VEXfloat<VEX_64>>() { return 1; }
176 template <> inline constexpr int VEXtupleSize<VEXvec2<VEX_32>>() { return 2; }
177 template <> inline constexpr int VEXtupleSize<VEXvec2<VEX_64>>() { return 2; }
178 template <> inline constexpr int VEXtupleSize<VEXvec3<VEX_32>>() { return 3; }
179 template <> inline constexpr int VEXtupleSize<VEXvec3<VEX_64>>() { return 3; }
180 template <> inline constexpr int VEXtupleSize<VEXvec4<VEX_32>>() { return 4; }
181 template <> inline constexpr int VEXtupleSize<VEXvec4<VEX_64>>() { return 4; }
182 template <> inline constexpr int VEXtupleSize<VEXmat2<VEX_32>>() { return 4; }
183 template <> inline constexpr int VEXtupleSize<VEXmat2<VEX_64>>() { return 4; }
184 template <> inline constexpr int VEXtupleSize<VEXmat3<VEX_32>>() { return 9; }
185 template <> inline constexpr int VEXtupleSize<VEXmat3<VEX_64>>() { return 9; }
186 template <> inline constexpr int VEXtupleSize<VEXmat4<VEX_32>>() { return 16; }
187 template <> inline constexpr int VEXtupleSize<VEXmat4<VEX_64>>() { return 16; }
188 
189 #endif
190 
VEX_Storage
Definition: VEX_Types.h:30
VEX_Type
VEX variable types.
Definition: VEX_VexTypes.h:18
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
VEX_API const char * VEXgetBaseType(VEX_BaseType type)
VEX_API const char * VEXgetUIHint(VEX_UIHint type)
VEX_API FS_DiskCache & VEXcompileCache()
#define VEX_API
Definition: VEX_API.h:11
VEX_API const char * VEXgetStorage(VEX_Storage type)
void read(T &in, bool &v)
Definition: ImfXdr.h:611
typename VEX_PrecisionResolver< P >::vec3_type VEXvec3
Definition: VEX_PodTypes.h:67
bool isWrite() const
Definition: VEX_Types.h:83
VEX_API int VEXgetFloatCount(VEX_Type type)
VEX_API int VEXgetArgCount(VEX_Type type)
typename VEX_PrecisionResolver< P >::float_type VEXfloat
Definition: VEX_PodTypes.h:64
VEX_API const char * VEXgetShortStorage(VEX_Storage type)
VEX_RWType()
Definition: VEX_Types.h:73
typename VEX_PrecisionResolver< P >::mat4_type VEXmat4
Definition: VEX_PodTypes.h:71
VEX_BaseType
Definition: VEX_Types.h:42
typename VEX_PrecisionResolver< P >::mat2_type VEXmat2
Definition: VEX_PodTypes.h:69
VEX_API const char * VEXgetType(VEX_Type type)
bool isRead() const
Definition: VEX_Types.h:82
typename VEX_PrecisionResolver< P >::vec2_type VEXvec2
Definition: VEX_PodTypes.h:66
typename VEX_PrecisionResolver< P >::vec4_type VEXvec4
Definition: VEX_PodTypes.h:68
#define SYS_UNIMPLEMENTED_TEMPLATE(T)
bool operator!=(const VEX_RWType &rhs) const
Definition: VEX_Types.h:88
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
typename VEX_PrecisionResolver< P >::int_type VEXint
Definition: VEX_PodTypes.h:65
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
GLboolean r
Definition: glcorearb.h:1221
VEX_UIHint
Definition: VEX_Types.h:50
VEX_RWType(bool read, bool write)
Definition: VEX_Types.h:76
void write(T &out, bool v)
Definition: ImfXdr.h:332
void setRead(bool r=true)
Definition: VEX_Types.h:80
typename VEX_PrecisionResolver< P >::mat3_type VEXmat3
Definition: VEX_PodTypes.h:70
bool operator==(const VEX_RWType &rhs) const
Definition: VEX_Types.h:85
void setWrite(bool w=true)
Definition: VEX_Types.h:81
VEX_API char VEXgetMangleType(VEX_Type type)
const char * asString() const
Definition: VEX_Types.h:91