HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PRM_BatchParm.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: PRM_BatchParm.h ( PRM Library, C++)
7  *
8  * COMMENTS: Batch evaluation of parameters. This class is the definition
9  * of a parameter.
10  */
11 
12 #ifndef __PRM_BatchParm__
13 #define __PRM_BatchParm__
14 
15 #include "PRM_API.h"
16 #include <SYS/SYS_Types.h>
17 #include <UT/UT_String.h>
18 
19 typedef enum {
25 
26 #define PRM_BATCH_CACHE_SIZE 4
27 
29 public:
30  PRM_BatchParm();
31  ~PRM_BatchParm();
32 
33  bool init(const char *name, PRM_BatchType type,
34  int vsize, void *userdata);
35 
36  const char *getName() const { return myName; }
37  PRM_BatchType getType() const { return myType; }
38  int getVectorSize() const { return myVectorSize; }
39  bool isEvaluated() const { return myEvaluated; }
40 
41  int getEvaluatingOp() const { return myOpId; }
42  int getEvaluatingParmIndex() const { return myParmIndex; }
43 
44  void clearEvaluated() { myEvaluated = false; }
45  void clearValueSet() { myValueSet = false; }
46 
47  // Determine whether we can set the value of the parm into the actual OP
48  // node's parameter.
49  bool isValueSet() const { return myValueSet && myEvaluated; }
50 
51  int *getInt() { return myVector.myInt; }
52  fpreal *getReal() { return myVector.myReal; }
53  UT_String *getString() { return myVector.myString; }
54 
55  void *getUserData() { return myUserData; }
56 
57  int getDefaultedInt(int def, int idx=0)
58  { return myEvaluated ? myVector.myInt[idx] : def; }
59  fpreal getDefaultedReal(fpreal def, int idx=0)
60  { return myEvaluated ? myVector.myReal[idx] : def; }
61  const char *getDefaultedString(const char *def, int idx=0)
62  {
63  if (myEvaluated)
64  def = (const char *)myVector.myString[idx];
65  return def;
66  }
67 
69  {
70  myValueSet = true;
71  for (int i = 0; i < myVectorSize; i++)
72  myVector.myInt[i] = (int)val[i];
73  }
75  {
76  myValueSet = true;
77  for (int i = 0; i < myVectorSize; i++)
78  myVector.myInt[i] = (int)val[i];
79  }
81  {
82  myValueSet = true;
83  for (int i = 0; i < myVectorSize; i++)
84  myVector.myReal[i] = (fpreal)val[i];
85  }
87  {
88  myValueSet = true;
89  for (int i = 0; i < myVectorSize; i++)
90  myVector.myReal[i] = (fpreal)val[i];
91  }
92  void setValue(const char **val)
93  {
94  myValueSet = true;
95  for (int i = 0; i < myVectorSize; i++)
96  myVector.myString[i].harden(val[i]);
97  }
98 
99  void dump();
100 
101 private:
102  void freeVector();
103  void setEvaluated(int opid, int pidx)
104  {
105  myEvaluated = true;
106  myOpId = opid;
107  myParmIndex = pidx;
108  }
109 
110  // Rather than allocating memory for small vectors, we just create a cache.
111  union {
114  } myCache;
115  union {
117  int *myInt;
119  } myVector;
120  const char *myName;
121  void *myUserData;
122  PRM_BatchType myType;
123  int myVectorSize;
124  int myOpId, myParmIndex;
125  bool myEvaluated;
126  bool myValueSet;
127 
128  friend class PRM_BatchList;
129 };
130 
131 #endif
const char * getDefaultedString(const char *def, int idx=0)
Definition: PRM_BatchParm.h:61
int int32
Definition: SYS_Types.h:39
void clearValueSet()
Definition: PRM_BatchParm.h:45
UT_String * getString()
Definition: PRM_BatchParm.h:53
fpreal * myReal
int getVectorSize() const
Definition: PRM_BatchParm.h:38
int getEvaluatingParmIndex() const
Definition: PRM_BatchParm.h:42
int getEvaluatingOp() const
Definition: PRM_BatchParm.h:41
void clearEvaluated()
Definition: PRM_BatchParm.h:44
fpreal getDefaultedReal(fpreal def, int idx=0)
Definition: PRM_BatchParm.h:59
float fpreal32
Definition: SYS_Types.h:200
bool isEvaluated() const
Definition: PRM_BatchParm.h:39
double fpreal64
Definition: SYS_Types.h:201
void setValue(const char **val)
Definition: PRM_BatchParm.h:92
void setValue(fpreal64 *val)
Definition: PRM_BatchParm.h:86
UT_String * myString
int * getInt()
Definition: PRM_BatchParm.h:51
void setValue(int32 *val)
Definition: PRM_BatchParm.h:68
#define PRM_BATCH_CACHE_SIZE
Definition: PRM_BatchParm.h:26
PRM_BatchType getType() const
Definition: PRM_BatchParm.h:37
bool isValueSet() const
Definition: PRM_BatchParm.h:49
long long int64
Definition: SYS_Types.h:116
void * getUserData()
Definition: PRM_BatchParm.h:55
GLuint const GLchar * name
Definition: glcorearb.h:786
PRM_BatchType
Definition: PRM_BatchParm.h:19
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint GLfloat * val
Definition: glcorearb.h:1608
void setValue(int64 *val)
Definition: PRM_BatchParm.h:74
int getDefaultedInt(int def, int idx=0)
Definition: PRM_BatchParm.h:57
type
Definition: core.h:1059
#define PRM_API
Definition: PRM_API.h:10
const char * getName() const
Definition: PRM_BatchParm.h:36
fpreal * getReal()
Definition: PRM_BatchParm.h:52
void setValue(fpreal32 *val)
Definition: PRM_BatchParm.h:80