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