HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PRM_ParmOwner.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_ParmOwner.h (Parameter Library)
7  *
8  * COMMENTS:
9  * This class is the base class of OP_Parameters. It provides
10  * a method for a PRM_Instance to communicate with its owner
11  * OP_Node through virtual functions.
12  */
13 
14 #ifndef __PRM_ParmOwner__
15 #define __PRM_ParmOwner__
16 
17 #include "PRM_API.h"
18 #include <SYS/SYS_Types.h>
19 #include <UT/UT_Error.h>
20 #include <UT/UT_String.h>
21 #include <UT/UT_WorkBuffer.h>
22 #include <UT/UT_ValArray.h>
23 #include <PY/PY_Result.h>
24 #include <CH/CH_ExprLanguage.h>
25 #include <iosfwd>
26 
27 class UT_StringArray;
28 class PY_CompiledCode;
30 class PRM_Conditional;
31 class PRM_Instance;
32 class PRM_Parm;
33 class PRM_ParmList;
34 class PRM_ParmMicroNode;
35 class PRM_ParmNameMap;
36 
37 // Forward declare of OP_Node so that we can provide a mechanism to cast to it
38 // safely.
39 class OP_Node;
40 
42 {
43 public:
44  virtual OP_Node * castToOPNode() { return 0; }
45  virtual const OP_Node * castToOPNode() const { return 0; }
46 
47  const char *getFullPath(UT_String &str) const
48  {
50  doGetFullPath(buf);
51  buf.copyIntoString(str);
52  return str.buffer();
53  }
54  const char *getFullPath(UT_WorkBuffer &str) const
55  {
56  doGetFullPath(str);
57  return str.buffer();
58  }
60  {
62  doGetFullPath(buf);
63  return UT_StringHolder(buf);
64  }
66  { return myParmList; }
67  const PRM_ParmList *getParmList() const
68  { return myParmList; }
69 
70  virtual bool createSpareParametersForLoad(
73  UT_String &);
74 
75  virtual PRM_ParmList *createObsoleteParmList() = 0;
76  virtual void resolveAndDeleteObsoleteParmList(
77  PRM_ParmList *&obsolete_parms) = 0;
78 
79  // Runs a command using the OPgetDirector()->getCommandManager()
80  // at the OP level. The cwd is set to the current node before
81  // executing the command.
82  virtual void executeCommand(const char *command,
83  std::ostream *out,
84  std::ostream *err) const = 0;
85 
86  // Run some Python code, but set the cwd before running it and restore it
87  // after running it.
88  virtual void pushAsPwdAndRunPython(
89  PY_CompiledCode &compiled_code,
90  PY_Result::Type desired_result_type,
91  PY_Result &result,
92  PY_EvaluationContext *context=NULL) const = 0;
93 
94  // Pending overrides are strings giving a list of op nodes which
95  // will be overridden. These are used higher up at the OP_Node level.
96  bool isPendingOverride() const
97  {
98  return myIsPendingOverride;
99  }
100  virtual bool isParmPendingOverride(const char * /*parm_name*/,
101  int /*vec_idx*/) const
102  {
103  // default implementation that is too coarse
104  return isPendingOverride();
105  }
106  const char *getPendingOverrideString() const
107  {
108  return (const char *) myOverridePending;
109  }
110  void setPendingOverrideString(const char *s);
111  virtual UT_ErrorSeverity
112  prmCookOverrides(fpreal /*t*/, int /*thread*/,
113  const char * /*parm_name*/,
114  int /*vec_idx*/)
115  { return UT_ERROR_NONE; }
116 
117  // Activates the parm for the take if it should be automatically
118  // activated based on its current state and the current take state.
119  virtual void takeAutoActivateParm(PRM_Parm *) = 0;
120 
121  // Rebuild the node dependency information for a particular parm on
122  // a node. This allows the PRM library to force nodes to update their
123  // dependency information.
124  virtual void rebuildParmDependency(int parmidx) = 0;
125 
126  // Clear all parm dependency information
127  virtual void clearParmDependency(int parmidx) = 0;
128 
129  // Converts opdef and oplib format paths from opdef:nodepath to
130  // opdef:tablename/optype.
131  virtual void convertOpdefToAbsolutePath(UT_String &str) const = 0;
132 
133  // This function is called when a spare parameter is being removed
134  // from our parm list. This is called from PRM_ParmList::updateSpareParms,
135  // and provides a way for the OP library to respond to individual parm
136  // removals without understanding the internals of the whole operation.
137  virtual void spareParmRemoved(const char *parmname) = 0;
138 
139  // This function is caled when any multiparm has a new instance added.
140  // It gives the parm owner a chance to initialize the multiparm values.
141  virtual void initMultiparmInstance(UT_ValArray<PRM_Parm *> &p) = 0;
142 
143  // This function is called when a multiparm instance is added or removed.
144  virtual void addOrRemoveMultiparmInstance() = 0;
145 
146  virtual bool savePresetContents(std::ostream &os) = 0;
147  virtual bool loadPresetContents(const char *token,
148  UT_IStream &is) = 0;
149 
150  virtual CH_ExprLanguage getExprLanguage() const = 0;
151 
152  // Creates an array of parm micronodes, one per component for the given
153  // parm.
154  virtual PRM_ParmMicroNode *createParmMicroNodes(PRM_Parm &parm) const;
155 
156 
157  // There are special bespoke functions for the disablewhen and hidewhen
158  // conditionals that are parsed through this callback. They have to
159  // move upstream to OP to get access to nInputs(), etc.
160  virtual UT_StringHolder evaluateDisableExpression(const PRM_Parm &prm, const UT_StringRef &function) const;
161 
162  // Traverse channel references building dependencies. Vector index of
163  // final parameter is returned in 'sub_idx'.
164  virtual const PRM_Parm *traverseRef(int *sub_idx, fpreal time,
165  int parm_idx, int vec_idx) const = 0;
166 
167 protected:
169  : myIsPendingOverride(false)
170  , myParmList(0)
171  { }
172  virtual ~PRM_ParmOwner()
173  { }
174 
175  virtual int64 getMemoryUsage(bool inclusive) const
176  {
177  int64 mem = inclusive ? sizeof(*this) : 0;
178  mem += myOverridePending.getMemoryUsage(false);
179  return mem;
180  }
181 
182  /// Compute the full path of the node
183  virtual void doGetFullPath(UT_WorkBuffer &buf) const = 0;
184 
186 
187 private:
188  UT_String myOverridePending;
189  bool myIsPendingOverride;
190 };
191 
192 #endif
193 
virtual UT_ErrorSeverity prmCookOverrides(fpreal, int, const char *, int)
const char * getFullPath(UT_WorkBuffer &str) const
Definition: PRM_ParmOwner.h:54
virtual int64 getMemoryUsage(bool inclusive) const
CH_ExprLanguage
virtual const OP_Node * castToOPNode() const
Definition: PRM_ParmOwner.h:45
UT_ErrorSeverity
Definition: UT_Error.h:25
void copyIntoString(UT_String &str) const
PRM_ParmList * getParmList()
Definition: PRM_ParmOwner.h:65
long long int64
Definition: SYS_Types.h:106
const char * buffer() const
Definition: UT_String.h:503
const char * getFullPath(UT_String &str) const
Definition: PRM_ParmOwner.h:47
UT_StringHolder getFullPath() const
Definition: PRM_ParmOwner.h:59
PRM_ParmList * myParmList
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2539
double fpreal
Definition: SYS_Types.h:269
bool isPendingOverride() const
Definition: PRM_ParmOwner.h:96
const char * buffer() const
virtual OP_Node * castToOPNode()
Definition: PRM_ParmOwner.h:44
const PRM_ParmList * getParmList() const
Definition: PRM_ParmOwner.h:67
#define PRM_API
Definition: PRM_API.h:10
virtual ~PRM_ParmOwner()
virtual bool isParmPendingOverride(const char *, int) const
const char * getPendingOverrideString() const