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