00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __PRM_BatchParm__
00020 #define __PRM_BatchParm__
00021
00022 #include "PRM_API.h"
00023 #include <SYS/SYS_Types.h>
00024 #include <UT/UT_String.h>
00025
00026 typedef enum {
00027 PRM_BATCH_INT,
00028 PRM_BATCH_REAL,
00029 PRM_BATCH_STRING,
00030 PRM_BATCH_RAWSTRING,
00031 } PRM_BatchType;
00032
00033 #define PRM_BATCH_CACHE_SIZE 4
00034
00035 class UT_IntArray;
00036
00037 class PRM_API PRM_BatchParm {
00038 public:
00039 PRM_BatchParm();
00040 ~PRM_BatchParm();
00041
00042 bool init(const char *name, PRM_BatchType type,
00043 int vsize, void *userdata);
00044
00045 const char *getName() const { return myName; }
00046 PRM_BatchType getType() const { return myType; }
00047 int getVectorSize() const { return myVectorSize; }
00048 bool isEvaluated() const { return myEvaluated; }
00049
00050 int getEvaluatingOp() const { return myOpId; }
00051 int getEvaluatingParmIndex() const { return myParmIndex; }
00052
00053 void clearEvaluated() { myEvaluated = false; }
00054 void clearValueSet() { myValueSet = false; }
00055
00056
00057
00058 bool isValueSet() const { return myValueSet && myEvaluated; }
00059
00060 int *getInt() { return myVector.myInt; }
00061 fpreal *getReal() { return myVector.myReal; }
00062 UT_String *getString() { return myVector.myString; }
00063
00064 void *getUserData() { return myUserData; }
00065
00066 int getDefaultedInt(int def, int idx=0)
00067 { return myEvaluated ? myVector.myInt[idx] : def; }
00068 fpreal getDefaultedReal(fpreal def, int idx=0)
00069 { return myEvaluated ? myVector.myReal[idx] : def; }
00070 const char *getDefaultedString(const char *def, int idx=0)
00071 {
00072 if (myEvaluated)
00073 def = (const char *)myVector.myString[idx];
00074 return def;
00075 }
00076
00077 void setValue(int32 *val)
00078 {
00079 myValueSet = true;
00080 for (int i = 0; i < myVectorSize; i++)
00081 myVector.myInt[i] = (int)val[i];
00082 }
00083 void setValue(int64 *val)
00084 {
00085 myValueSet = true;
00086 for (int i = 0; i < myVectorSize; i++)
00087 myVector.myInt[i] = (int)val[i];
00088 }
00089 void setValue(fpreal32 *val)
00090 {
00091 myValueSet = true;
00092 for (int i = 0; i < myVectorSize; i++)
00093 myVector.myReal[i] = (fpreal)val[i];
00094 }
00095 void setValue(fpreal64 *val)
00096 {
00097 myValueSet = true;
00098 for (int i = 0; i < myVectorSize; i++)
00099 myVector.myReal[i] = (fpreal)val[i];
00100 }
00101 void setValue(const char **val)
00102 {
00103 myValueSet = true;
00104 for (int i = 0; i < myVectorSize; i++)
00105 myVector.myString[i].harden(val[i]);
00106 }
00107
00108 void dump();
00109
00110 private:
00111 void freeVector();
00112 void setEvaluated(int opid, int pidx)
00113 {
00114 myEvaluated = true;
00115 myOpId = opid;
00116 myParmIndex = pidx;
00117 }
00118
00119
00120 union {
00121 fpreal myReal[PRM_BATCH_CACHE_SIZE];
00122 int myInt[PRM_BATCH_CACHE_SIZE];
00123 } myCache;
00124 union {
00125 fpreal *myReal;
00126 int *myInt;
00127 UT_String *myString;
00128 } myVector;
00129 const char *myName;
00130 void *myUserData;
00131 PRM_BatchType myType;
00132 int myVectorSize;
00133 int myOpId, myParmIndex;
00134 bool myEvaluated;
00135 bool myValueSet;
00136
00137 friend class PRM_BatchList;
00138 };
00139
00140 #endif