00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Side Effects Software Inc 00008 * 123 Front Street West, Suite 1401 00009 * Toronto, Ontario 00010 * Canada M5J 2M2 00011 * 416-504-9876 00012 * 00013 * NAME: CVEX_Value.h ( CVEX Library, C++) 00014 * 00015 * COMMENTS: C++ interface to VEX. This class is used to specify 00016 * input/output variable data. 00017 */ 00018 00019 #ifndef __CVEX_Value__ 00020 #define __CVEX_Value__ 00021 00022 #include "CVEX_API.h" 00023 00024 class UT_StringArray; 00025 00026 /// The CVEX_Type enum defines the VEX types available to CVEX. 00027 typedef enum { 00028 CVEX_TYPE_INVALID = -1, // Invalid type 00029 CVEX_TYPE_INTEGER, // 32 bit integer 00030 CVEX_TYPE_FLOAT, // 32 bit float 00031 CVEX_TYPE_VECTOR3, // 3-tuple of 32 bit float 00032 CVEX_TYPE_VECTOR4, // 4-tuple of 32 bit float 00033 CVEX_TYPE_MATRIX3, // 9-tuple of 32 bit float 00034 CVEX_TYPE_MATRIX4, // 16-tuple of 32 bit float 00035 CVEX_TYPE_STRING // string values 00036 } CVEX_Type; 00037 00038 /// @brief A class representing a VEX value. 00039 /// 00040 /// The CVEX_Value objects are created internally in the CVEX library. They 00041 /// provide a mapping from the CVEX library to the underlying VEX 00042 /// representation of objects. 00043 class CVEX_API CVEX_Value { 00044 public: 00045 CVEX_Value(const char *name, CVEX_Type type, bool varying); 00046 ~CVEX_Value(); 00047 00048 /// Query name of VEX value 00049 const char *getName() const { return myName; } 00050 /// Query type of VEX value 00051 CVEX_Type getType() const { return myType; } 00052 /// Query whether the VEX value is an export (or read-only) 00053 bool isExport() const { return myExport; } 00054 /// Query whether the VEX value is uniform or varying 00055 bool isVarying() const { return myVarying; } 00056 /// Query the array size of the VEX value. 00057 /// @note This is @b not the used for VEX arrays, but rather represents the 00058 /// number of entries in the varying array. 00059 int getArraySize() const { return myArraySize; } 00060 00061 /// Get the raw data pointer. 00062 /// For numeric types, the data refers to a raw array of data (depending on 00063 /// the getType() of the value. 00064 /// - CVEX_TYPE_INTEGER @c int 00065 /// - CVEX_TYPE_FLOAT @c fpreal32 00066 /// - CVEX_TYPE_VECTOR3 @c UT_Vector3 00067 /// - CVEX_TYPE_VECTOR4 @c UT_Vector4 00068 /// - CVEX_TYPE_MATRIX3 @c UT_Matrix3 00069 /// - CVEX_TYPE_MATRIX4 @c UT_Matrix4 00070 /// For CVEX_TYPE_STRING, the data will point to a UT_StringArray. 00071 void *getData() { return myData; } 00072 00073 /// The array size is NOT the size in bytes, but rather the array size of 00074 /// the input data. It should either be 1 or N, where N is the number of 00075 /// values being computed by VEX. 00076 /// 00077 /// When passing data for output variables, please check to see whether 00078 /// the output variable is uniform or varying. Varying values need to 00079 /// have a full array of data (including string arrays). 00080 /// 00081 /// The CVEX_Value object will hold a pointer to the UT_StringArray, so the 00082 /// data must be persistent. 00083 bool setData(void *data, int array_size); 00084 00085 /// When setting values for string types, you need to pass in a 00086 /// UT_StringArray instead of a void *. For input variables, the length 00087 /// of the array will determine whether the parameter is varying or 00088 /// uniform. 00089 /// 00090 /// The CVEX_Value object will hold a pointer to the UT_StringArray, so the 00091 /// data must be persistent. 00092 bool setData(UT_StringArray &stringdata); 00093 00094 private: 00095 static int cvexToVexType(CVEX_Type type); 00096 static CVEX_Type vexToCVexType(int vextype); 00097 00098 void *myData; 00099 const char *myName; 00100 CVEX_Type myType; // Data type 00101 int myVexType; // VEX Type (mapped from CVEX_Type) 00102 int myVexIndex; // Offset into VEX symbol table 00103 int myArraySize; // Array size 00104 bool myExport; // Whether the data is output by VEX 00105 bool myVarying; // Whether the data is varying 00106 00107 friend class CVEX_Context; 00108 }; 00109 00110 #endif
1.5.9