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