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