HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PRM_Instance.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_Instance.h (Parameter Library)
7  *
8  * COMMENTS:
9  * A PRM_Instance contains all the variable data relating to
10  * parameters. In other words it contains the actual values
11  * of the parameter. The types and format of the values are
12  * specified in the PRM_Template portion of a parameter. A
13  * PRM_Instance is to a PRM_Template as an object is to a
14  * class in C++.
15  */
16 
17 #ifndef __PRM_Instance_h__
18 #define __PRM_Instance_h__
19 
20 #include "PRM_API.h"
21 #include "PRM_Callback.h"
22 #include "PRM_ChanState.h"
23 #include "PRM_Default.h"
24 #include "PRM_Error.h"
25 #include "PRM_KeySetType.h"
26 #include "PRM_Parm.h"
27 #include "PRM_ParmList.h"
28 #include "PRM_Template.h"
29 #include "PRM_Type.h"
30 
31 #include <CH/CH_Collection.h>
32 #include <CH/CH_ExprLanguage.h>
33 #include <CH/CH_Manager.h>
34 #include <CH/CH_Types.h>
35 #include <DEP/DEP_MicroNode.h>
36 
37 #include <EXPR/EX_Error.h>
38 #include <UT/UT_Array.h>
39 #include <UT/UT_Assert.h>
40 #include <UT/UT_Color.h>
41 #include <UT/UT_SmallObject.h>
42 #include <UT/UT_String.h>
43 #include <UT/UT_StringHolder.h>
44 #include <UT/UT_TBBSpinLock.h>
45 #include <UT/UT_UniquePtr.h>
46 #include <UT/UT_VectorTypes.h>
47 #include <SYS/SYS_Inline.h>
48 #include <SYS/SYS_Types.h>
49 
50 #include <iosfwd>
51 
52 
53 class PRM_ChoiceList;
54 class PRM_Multi;
55 class PRM_ConstMicroNode;
56 class PRM_ParmMicroNode;
57 class PRM_ParmOwner;
58 class PRM_Range;
59 class PRM_RefId;
60 class PRM_Value;
61 class CH_Channel;
62 class CH_FullKey;
63 class UT_IStream;
64 class UT_JSONValueMap;
65 class UT_Packet;
66 class UT_TokenString;
67 class UT_WorkBuffer;
68 
69 
70 class PRM_API PRM_Instance : public UT_SmallObject<PRM_Instance,
71  UT_SMALLOBJECT_CLEANPAGES_DEFAULT,
72  UT_SMALLOBJECT_PAGESIZE_DEFAULT,
73  UT_SMALLOBJECT_THREADSAFE_OFF>
74 {
75 public:
76  PRM_Instance(PRM_Template *thetemplateptr,
77  PRM_Parm *parm);
78  PRM_Instance(PRM_Instance *thesrcptr,
79  PRM_Parm *parm);
80  virtual ~PRM_Instance();
81 
82  virtual void adopt(PRM_Instance &thesrcinstance);
83  virtual void adoptOverrides(PRM_Instance &thesrcinstance);
84 
85  virtual PRM_Instance *duplicateSelf(PRM_Parm *node) = 0;
86 
87  virtual void setValueToDefault(fpreal time, int index,
88  PRM_AddKeyType add_key) = 0;
89  virtual void revertToDefault(int index) = 0;
90  virtual void revertToDefaults(bool clear_channels =true) = 0;
91  virtual void restoreFactoryDefault(int index) = 0;
92  virtual void overwriteDefault(fpreal time, int index) = 0;
93  virtual void overwriteDefaults(fpreal time) = 0;
94  virtual int isDefault(int index, enum PRM_DefaultType deftype,
95  bool basiccheck = true) const;
96  bool isAllDefault(enum PRM_DefaultType deftype) const;
97 
98  virtual void save(std::ostream &os, int binary, bool compiled) const=0;
99  virtual bool load(UT_IStream &is) = 0;
100 
101  virtual void saveUndoData(PRM_UndoDataHandle &data) const;
102  virtual bool loadUndoData(const PRM_UndoDataHandle &data);
103 
104  virtual void saveCommand(std::ostream &os, int values=0, int index = -1)
105  const = 0;
106  virtual int loadCommand(int argc, const char *const argv[],
107  int index,
108  bool values_only,
109  PRM_AddKeyType add_key,
110  PRM_KeySetType set_type) = 0;
111 
112  virtual void getValue(PRM_ParmList *parm_list, fpreal time,
113  int32 &value, int index,
114  int thread) const = 0;
115  virtual void getValue(PRM_ParmList *parm_list, fpreal time,
116  int64 &value, int index,
117  int thread) const = 0;
118  virtual void getValue(PRM_ParmList *parm_list, fpreal time,
119  fpreal &value, int index,
120  int thread) const = 0;
121  virtual void getValue(PRM_ParmList *parm_list, fpreal time,
122  UT_String &value, int index,
123  bool expand, int thread) const = 0;
124  virtual void getValue(PRM_ParmList *parm_list, fpreal time,
125  PRM_DataItemHandle &value, int index,
126  int thread) const = 0;
127  virtual void getValue(PRM_ParmList *parm_list, fpreal time,
128  UT_JSONValueMap &value, int index,
129  bool expand, int thread) const = 0;
130  virtual void getValues(PRM_ParmList *parm_list, fpreal time,
131  fpreal32 *value, int thread) const;
132  virtual void getValues(PRM_ParmList *parm_list, fpreal time,
133  fpreal64 *value, int thread) const;
134  virtual void getValues(PRM_ParmList *parm_list, fpreal time,
135  int32 *theints, int thread) const;
136  virtual void getValues(PRM_ParmList *parm_list, fpreal time,
137  int64 *theints, int thread) const;
138  virtual void getDefaultValue(fpreal &value, int index) const;
139  virtual void getDefaultValue(int32 &value, int index) const;
140  virtual void getDefaultValue(int64 &value, int index) const;
141  virtual void getDefaultValue(UT_String &value, int index) const;
142 
143  virtual void getExpressionStringForUI(fpreal time,
144  UT_String &value,
145  int index,
146  int thread) const = 0;
147  virtual void getExpression(fpreal time, UT_String &value,
148  int index, bool allow_value,
149  int thread) const = 0;
150  virtual void setExpression(fpreal time,
151  const char *value,
152  CH_ExprLanguage language,
153  int index, bool evaluate = true,
154  bool rmchannel = false);
155 
156  CH_StringMeaning getStringMeaning(fpreal time, int index) const;
157 
158  // If this parm contains an expression this function returns that
159  // expression's language. Otherwise, it returns the language that it
160  // would be if it was turned into an expression.
161  CH_ExprLanguage getExprLanguageIfMadeAnExpression(fpreal time,
162  int index) const;
163 
164  // If there is an expression, this function returns whether the
165  // expression's language for the segment at the given time is Old Expr.
166  // If there is no expression, this function returns true.
167  bool isLanguageOldExprOrLiteral(fpreal time, int index) const;
168 
169  // set value of a parameter
170  // setkey - determines how the value is set at keyframes.
171  // Whether the preference is used or always set as pending
172  virtual void setValue(fpreal time,
173  const char *value,
174  CH_StringMeaning meaning,
175  bool kill_expr = false,
176  int index = 0,
179 
180  virtual void setValue(fpreal time,
181  fpreal value,
182  bool kill_expr = false,
183  const int index = 0,
186 
187  virtual void setValue(fpreal time,
188  int32 value,
189  bool kill_expr = false,
190  const int index = 0,
193 
194  virtual void setValue(fpreal time,
195  int64 value,
196  bool kill_expr = false,
197  const int index = 0,
200 
201  virtual void setValue(fpreal time,
202  const PRM_DataItemHandle &value,
203  bool kill_expr = false,
204  const int index = 0,
207 
208  //
209  // The setValues methods set all entries in the vector...
210  //
211  virtual void setValues(fpreal time,
212  const fpreal *values,
213  bool kill_expr = false,
216 
217  virtual void setValues(fpreal time,
218  const int64 *values,
219  bool kill_expr = false,
222 
223  virtual void setDefaultChannelValue(CH_Channel *channelptr,
224  int index = 0) = 0;
225 
226  virtual bool isMultiParm() const;
227  virtual int getMultiParmNumItems() const;
228  virtual int getMultiParmInstancesPerItem() const;
229  virtual const char *getMultiParmToken(int p, int index) const;
230  // Only PRM_ParmList should directly call these insert/remove methods.
231  // All other users, should use the insert/remove methods in OP_Parameter.
232  virtual void insertMultiParmItem(int index);
233  virtual void removeMultiParmItem(int index);
234 
235  virtual void buildOpDependencies(const PRM_RefId &ref, int thread);
236  virtual void changeOpRef(const char *new_fullpath,
237  const char *old_fullpath,
238  const char *old_cwd,
239  const char *chan_name,
240  const char *old_chan_name,
241  void (*undo_callback)(void *),
242  void *undo_data,
243  int thread);
244 
245  fpreal findNextKey(fpreal theoldtime, int index=-1);
246  fpreal findPrevKey(fpreal theoldtime, int index=-1);
247 
248  virtual int findString(const char *str, bool fullword,
249  bool usewildcards) const;
250  virtual int changeString(const char *from, const char *to,
251  bool fullword);
252 
253  virtual bool notifyVarChange(int subindex, const char *varname);
254 
255  virtual bool getMagicString(UT_TokenString &magic,
256  PRM_ParmList *list, int size,
257  fpreal t, bool add_if_default /*=true*/,
258  int thread) = 0;
259 
260  unsigned getEnableState(int comp = -1) const;
261  bool setEnableState(bool f, int comp = -1);
262 
263  int getExpressionState() const
264  {
265  return myBitField & BITFLAG_EXPRESSIONSTATE;
266  }
268  {
269  if (state)
270  myBitField |= BITFLAG_EXPRESSIONSTATE;
271  else
272  myBitField &= ~BITFLAG_EXPRESSIONSTATE;
273  }
274  int getValueState() const
275  {
276  return myBitField & BITFLAG_VALUESTATE;
277  }
279  {
280  if (state)
281  myBitField |= BITFLAG_VALUESTATE;
282  else
283  myBitField &= ~BITFLAG_VALUESTATE;
284  }
285 
286  virtual bool isEditable(PRM_ParmList *thelist, fpreal time,
287  int index) const { return true; }
288  virtual bool isEditableByUI(PRM_ParmList *thelist, fpreal time,
289  int index) const { return true; }
290 
292  {
293  return getParmList()
294  ? getParmList()->getChannelGroupPtr()
295  : nullptr;
296  }
297  fpreal getEvalTime(int thread) const
298  {
299  CH_Collection *coll = getChannelGroupPtr();
300  if (!coll)
301  return 0.0;
302  return coll->getManager()
303  ->getEvaluateTime(thread);
304  }
306  {
307  CH_Collection *coll = getChannelGroupPtr();
308  if (!coll)
309  return 0.0;
310  return coll->getManager()->getGlobalStart();
311  }
312 
313  CH_Channel *getChannel(int subindex) const
314  {
315  UT_ASSERT(subindex >= 0
316  && subindex < getVectorSize());
317  return myChannelPtrs[subindex];
318  }
319  void setChannel(int subindex, CH_Channel *chp)
320  {
321  myChannelPtrs[subindex] = chp;
322  }
323 
324  void reloadChannelPtrs();
325  int channelPtrModified(const UT_StringRef &name);
326  void internalAddChannel(int index,
327  const char *theexpr,
328  CH_ExprLanguage language,
329  bool add_seg = true);
330  void addChannel(int index);
331  int addChannel(const UT_StringRef &name);
332  void addChannel(int index, const char *theexpr,
333  CH_ExprLanguage language);
334  int addChannel(const UT_StringRef &name, const char *expr,
335  CH_ExprLanguage language);
336  bool removeChannel(int index);
337  int getChannelCount() const;
338 
339  // Determine if a given component if time/data dependent. Use -1 if you
340  // want to know this for any of the components in the parm.
341  virtual bool isTimeDependent(int subindex) const;
342  virtual bool isDataDependent(fpreal gtime, int subindex) const;
343 
344  virtual void setTimeDependent(int subindex, bool timedep);
345  // Form for setTimeDependent() for the evaluation code path
346  void setTimeDependentForEval(int vi, bool timedep) const
347  { SYSconst_cast(this)->setTimeDependent(vi, timedep);}
348 
349  bool hasContextOptionDeps(int subindex) const;
350  const DEP_ContextOptionDeps &getContextOptionDeps(int subindex) const;
351  bool hasGlobalContextOptionDependency(int subindex,
352  const UT_StringRef &opt) const;
353  void addContextOptionDep(int subindex,
354  const UT_StringHolder &opt,
355  bool set_dependency_on_global);
356 
357  int changePending(int index);
358  virtual PRM_ChanState getChanState(fpreal time, int index) const;
359  virtual PRM_ChanState getChanState(fpreal time) const;
360 
361  // add keyframes if changes are pending
362  virtual void hardenChanges(fpreal time,
363  int index,
364  bool theforceflag,
365  const char *patt = nullptr,
366  CH_ChannelRefList *list = nullptr) = 0;
367 
368  // sets a key even if no channel exists
369  void setKey(fpreal time, int index);
370  void setKey(fpreal time, int index, const char *expr,
371  CH_ExprLanguage language,
372  const char *patt = nullptr,
373  CH_ChannelRefList *list = nullptr);
374 
375  void setFullKey(fpreal gtime, int index,
376  CH_FullKey const& key,
377  bool accel_ratios = true);
378 
379  unsigned int getSaveFlags() const
380  { return myBitField & BITFLAG_SAVE_MASK; }
381  void setSaveFlags(unsigned int f)
382  { myBitField |= (f & BITFLAG_SAVE_MASK); }
383 
384  bool getActiveTakeFlag() const
385  { return myBitField & BITFLAG_ACTIVETAKE; }
386  bool getAlwaysTakeFlag() const
387  { return myBitField & BITFLAG_TAKEALWAYSACTIVE; }
388  void setActiveTakeFlag(int onoff)
389  {
390  if (onoff) myBitField |= BITFLAG_ACTIVETAKE;
391  else
392  {
393  if (!(myBitField & BITFLAG_TAKEALWAYSACTIVE))
394  myBitField &= ~BITFLAG_ACTIVETAKE;
395  else myBitField |= BITFLAG_ACTIVETAKE;
396  }
397  }
398 
399  bool getBypassFlag() const
400  { return myBitField & BITFLAG_BYPASS; }
401  void setBypassFlag(bool onoff)
402  {
403  // Only allow bypass on spare parameters
404  if (isSpareParm() && onoff)
405  myBitField |= BITFLAG_BYPASS;
406  else
407  myBitField &= ~BITFLAG_BYPASS;
408  }
409 
410  bool getVisibleState(int comp = -1) const;
411  void setVisibleState(bool f, int comp = -1);
412 
414  { return myBitField & BITFLAG_UNDOSAVED; }
415  void setUndoSavedFlag(bool f)
416  { if (f) myBitField |= BITFLAG_UNDOSAVED;
417  else myBitField &= ~BITFLAG_UNDOSAVED;}
419  { return myBitField & BITFLAG_AUTOTAKEUNDOSAVED; }
421  { if (f) myBitField |= BITFLAG_AUTOTAKEUNDOSAVED;
422  else myBitField &= ~BITFLAG_AUTOTAKEUNDOSAVED;}
423 
424  bool getSaveAutoScopeFlag() const
425  { return myBitField & BITFLAG_SAVEAUTOSCOPE; }
426 
428  { return myBitField & BITFLAG_SAVEAUTOSELECT; }
429 
430  void setSaveLabelFlag(bool f);
431  bool getSaveLabelFlag() const
432  { return myBitField & BITFLAG_SAVELABEL; }
433 
434  bool getLockedFlag(int vec_idx) const;
435  bool areAllComponentsLocked() const;
436  void setLockedFlag(int vec_idx, bool f);
437  bool getAutoScopedFlag(int vec_idx) const;
438  void setAutoScopedFlag(int vec_idx, bool f);
439 
440  bool getDefaultsInitFlag() const
441  { return (myBitField & BITFLAG_DEFAULTSINIT) != 0; }
442  void setDefaultsInitFlag(bool f)
443  { if (f) myBitField |= BITFLAG_DEFAULTSINIT;
444  else myBitField &= ~BITFLAG_DEFAULTSINIT;}
445 
446  unsigned int getLockField() const
447  { return myLockField; }
448  unsigned int getAutoScopeField() const
449  { return myAutoScopeField; }
450 
451  virtual int setOverride(int index, int data_idx,
452  const char *source,
454  virtual int setOverrideDisable(int index, int onoff);
455  virtual const char *getOverride(int index) const;
456  virtual bool getOverrideType(int index,
457  PRM_OverrideType& type) const;
458  virtual int getOverrideDataIndex(int index) const;
459 
460  ///Sometimes we may want to make an existing and enabled override
461  ///temporarily inactive, so that we can "shut off" the override without
462  ///losing any dependencies between the parm and the source of its exported
463  ///override values. (e.g. might want to temporarily change the parm's
464  ///display colour)
465  virtual int getIsOverrideActive(int index) const;
466 
467  virtual void destroyChildParms() { }
468 
469  // A parameter becomes dirty whenever its value is set.
470  bool isDirty(int vec_idx) const
471  { return getFieldBit(myDirtyParmFlags, vec_idx); }
472  bool areAllFlagsClean() const
473  { return !myDirtyParmFlags; }
475  { myDirtyParmFlags = 0; }
476  void setDirtyFlags(int vec_idx)
477  {
478  setFieldBit(myDirtyParmFlags, vec_idx, true);
479  setSendExtra(vec_idx);
480  }
481 
482  // mySendExtraFlags is a per-component bitfield that has its bit set
483  // if it needs to be dirty propagated.
484  bool isSendExtra(int vi) const
485  { return getFieldBit(mySendExtraFlags, vi); }
486  bool hasAnySendExtraFlags() const
487  { return (mySendExtraFlags != 0); }
488  void setSendExtra(int vi)
489  {
490  if (!getFieldBit(mySendExtraFlags, vi))
491  {
492  setFieldBit(mySendExtraFlags, vi, true);
493  getParmList()->bumpNumSendExtra(
494  vi < 0 ? getVectorSize() : +1);
495  }
496  }
497 
498  // The input notify value is not created by default. Call
499  // createInputNotifyValue when you need it. Handles use this
500  // notify value to add an interest in input fields so they can know
501  // when the input has changed. Op's trigger this notify value when
502  // they generate their input groups, if this value exists.
503  void createInputNotifyValue();
504  PRM_Value *inputNotifyValue() { return myNotifyValue; }
505  const PRM_Value *inputNotifyValue() const { return myNotifyValue; }
506 
507  const PRM_Type &getType() const
508  { return myTemplatePtr->getType(); }
510  { return myTemplatePtr->getTypeExtended(); }
512  { return myTemplatePtr->getMultiType(); }
514  { return myTemplatePtr->getMultiSize(); }
516  { return myTemplatePtr->getMultiStartOffset(); }
518  { return myTemplatePtr->getMultiParmTemplate(); }
520  { return myTemplatePtr->getMultiParmTemplate(); }
521  const char *getToken() const
522  { return myTemplatePtr->getToken(); }
523  const char *getLabel() const
524  { return myTemplatePtr->getLabel(); }
526  { return myTemplatePtr->getCallback(); }
527  int getVectorSize() const
528  { return myTemplatePtr->getVectorSize(); }
529  const PRM_Range * getRangePtr() const
530  { return myTemplatePtr->getRangePtr(); }
531  void getChannelToken(UT_String &chname, int i) const
532  { myTemplatePtr->getChannelToken(chname, i); }
533  const UT_StringHolder& getChannelToken(int i) const
534  { return myTemplatePtr->getChannelToken(i); }
536  { return myTemplatePtr->getChoiceListPtr(); }
537 
538  const PRM_Template *getTemplatePtr() const { return myTemplatePtr; }
539  PRM_Template *getTemplatePtr() { return myTemplatePtr; }
540 
541  // get/setChannelAlias allow the manipulation of channel aliases.
542  // setChannelAlias will return false if the operation fails and true
543  // otherwise. Do not use the set method directly, only PRM_ParmList should
544  // do that. To set a channel alias, use the OP_Node method.
545  bool hasChannelAlias(int index) const;
546  void getChannelAlias(UT_String &strref, int index) const;
547  const UT_StringHolder& getChannelAlias(int index) const;
548  bool setChannelAlias(const UT_StringHolder &token_alias,
549  int index);
550 
551  // Returns the sub-index of the parm given by the name thechannelname. If
552  // allow_alias is true, the channel name aliases are also searched,
553  // otherwise they are ignored.
554  int findSubIndex(const UT_StringRef &thechannelname,
555  bool allow_alias) const;
556 
558  { return myParm->getParmOwner(); }
560  { return myParm->getOwner(); }
561  PRM_Parm *getParm() const
562  { return myParm; }
563 
564  static bool isChanRefString(const char *str, bool is_expr,
565  UT_String *chref = nullptr);
566  static bool isObsoleteDirectChanRefString(
567  const char *str,
568  UT_String *chref = nullptr);
569 
570  // Returns true if the channame is the token (or alias) of the channel at
571  // vec_index, and returns false otherwise.
572  // The length of channame can be given in channamelen to speed up rejections
573  // if the caller caches the string length.
574  bool hasChannelName(const UT_StringRef &s, int vi) const;
575 
576  // Methods for accessing and setting the active handle binding flag
577  bool isActive(const int index) const;
578  void setActive(const int index, const bool active);
579 
580  // Spare parameter flag
581  bool isSpareParm() const;
582  void setSpareParm(bool spare);
583 
584  // Multiparm instance information
585  const PRM_Instance *getMultiParmOwner() const;
586  void setMultiParmOwner(const PRM_Multi *multiparmowner);
587 
588  /// Returns the multi-parm template for this child parm. Returns nullptr
589  /// if this parm is not part of a multi-parm
590  const PRM_Template *findMultiParmTemplate() const;
591 
592  /// Return the list of instance indicies for this parameter.
593  /// If this parameter is part of a multi-parameter, then its index in the
594  /// multi-parm array will be inserted into the indices array. If the
595  /// multi-parm is nested in other multi-parms, then the indices array will
596  /// have multiple entries (with the outer multi-parm listed first, and the
597  /// inner-most multi-parm last in the array).
598  /// \param indices The list of index instances.
599  /// \param instance_index Each multi-parm can have multiple parameters in
600  /// each instance. If instance_index is true, the instance number will be
601  /// returned. Otherwise the raw offset into the multi-parm will be
602  /// extracted.
603  int getMultiInstanceIndex(UT_Array<int> &indices,
604  bool instance_index=true) const;
605 
606  bool validIndex(int index) const;
607 
608  virtual int64 getMemoryUsage(bool inclusive) const;
609 
610  virtual bool isRotationParm() const
611  { return false; }
612 
613  /// During loading we need to validate that the channels tied to the
614  /// parameter indices are correclty mapped.
615  void validateChannelNames(PRM_ParmList &list);
616 
617  /// Thread-safe access to get or create a micronode
618  DEP_MicroNode & microNode(int vi);
619 
620 
621  /// Thread-safe access to get micronodes
622  void getMicroNodes(DEP_MicroNodeList &micronodes) const;
623 
624  /// Return true if this parameter has micronodes, NOT thread-safe
625  bool hasMicroNodes() const
626  { return (myMicroNodes != nullptr); }
627 
628  void clearMicroNodeInputs();
629  void getMicroNodeInputList(DEP_MicroNodeList &inputs) const;
630  int getMicroNodeNumInputs() const;
631  void getMicroNodeOutputList(DEP_MicroNodeList &outputs) const;
632 
633  void propagateDirty(
634  const DEP_MicroNode::Visitor& client_visit,
635  DEP_MicroNode *parmlist_micronode,
636  bool force,
637  bool *dirtied_data = nullptr);
638  void dumpMicroNodes(
639  std::ostream &os,
640  bool as_DOT,
641  int indent_level) const;
642  int64 getMicroNodesMemoryUsage() const;
643 
644  /// Custom Channel Color
645  bool hasChannelCustomColor(int index) const;
646  const UT_Color &getChannelCustomColor(int index) const;
647  void setChannelCustomColor(int index, const UT_Color &c);
648  void resetChannelCustomColor(int index);
649 
650  bool getAutoSelectFlag(int vec_idx) const;
651  void setAutoSelectFlag(int vec_idx, bool f);
652  unsigned int getAutoSelectField() const
653  { return myAutoSelectField; }
654 
655  void setTimeDependentMicroNode(int subindex, bool timedep);
656 
657  /// Thread-safe access to get or create a const micronode
658  /// A const micro node gives the same dependencies as
659  /// microNode(), but the time dependent flag will always be
660  /// false.
661  /// It also creates missing base microNodes.
662  DEP_MicroNode & constMicroNode(int vi);
663 protected:
664  void clearAndDestroyChannels();
665 
666  void addParmWarning(PRM_ErrorCode code) const;
667  void indexError(int index);
668 
669  void setLockField(unsigned int locks)
670  { myLockField = locks; }
671  void setAutoScopeField(unsigned int field)
672  {
673  myAutoScopeField = field;
674  myBitField |= BITFLAG_SAVEAUTOSCOPE;
675  }
676 
677  void setAutoSelectField(unsigned int field)
678  {
679  myAutoSelectField = field;
680  myBitField |= BITFLAG_SAVEAUTOSELECT;
681  }
682 
683  SYS_FORCE_INLINE void
685  const PRM_ParmList *thelist, int vector_index, int thread) const
686  {
687  int err;
688  err = ev_GetErrNo(thread);
689  if (err != EV_NOERROR)
690  evaluationError(thelist, vector_index, err, thread);
691  }
692 
693  bool validateAccess();
694 
695  // This helper method is called by loadCommand() in derived classes to
696  // load the token either as a reference to our channel, or failing that,
697  // as an expression.
698  void loadTokenAsChannelNameOrExpression(
699  const UT_String &token, int index);
700 
701  // This method loads the options of the parm that are within '[]' before
702  // the parm value. The istream must be positioned after the first '['
703  // and this method will leave it after the ']' and return true. If it
704  // could not correctly parse the options, it will return false.
705  bool loadAsciiOptions(UT_IStream &is, uint &pending_mask);
706 
707  // This method checks the given binary packet id against the list of
708  // options it supports, if successful, it loads the packet and returns
709  // true, otherwise returns false.
710  bool loadBinaryOption(UT_IStream &is, short packet_id);
711 
712  // This method will save the options of the parm if there are any to set.
713  // Currently, only the locked flag is saved. If the parm is not locked,
714  // this method won't do anything in an effort to maintain forwards
715  // compatibility with older versions of Houdini.
716  // Returns true if anything was written to the stream.
717  void saveAsciiOptions(std::ostream &os) const;
718  bool saveBinaryOptions(int class_packet_id,
719  UT_Packet &packet,
720  std::ostream &os) const;
721 
722  CH_ExprLanguage stringMeaningToExprLanguage(
723  CH_StringMeaning meaning) const;
724 
726  {
737  PRM_IO_TOKEN_NUM
738  };
739 
740  // Returns the token used in parm IO.
741  static const char *getPacketIOToken(PRM_ParmIOToken token);
742  static int getPacketIOTokenLen(PRM_ParmIOToken token);
743  static int getPacketIOBinaryId(PRM_ParmIOToken token);
744 
745  // Compares if the given text matches a given token. You
746  // must provide the length of the text, which has the virtue
747  // of avoiding having to harden buffers!
748  static bool comparePacketIOToken(PRM_ParmIOToken token,
749  const char *text,
750  int textlen);
751 
752  // returns true if myData should be saved. Used for caching just within a
753  // session or preventing expensive copy/pastes.
754  bool shouldSaveData() const;
755 
756 private:
757 
758  inline bool getFieldBit(unsigned int field, int i) const
759  {
760  if (i < 0)
761  return (field != 0);
762  else
763  return ((field & (1 << (unsigned)i)) != 0);
764  }
765  inline void setFieldBit(unsigned int &field, int i, bool f)
766  {
767  if (i < 0)
768  {
769  if (f) // enable lowermost vector size bits
770  field = (1<<(unsigned)getVectorSize()) - 1;
771  else
772  field = 0;
773  }
774  else
775  {
776  if (f)
777  field |= (1 << (unsigned)i);
778  else
779  field &= ~(1 << (unsigned)i);
780  }
781  }
782 
783  void getFullParmPath(UT_WorkBuffer &path) const;
784 
785  /// When loading a file, it's possible that the channel mapping doesn't
786  /// match the expected channel name. In this case, we want to either
787  /// rename the channel, or delete the channel (if there are name
788  /// collisions).
789  void validateChannelName(PRM_ParmList &list, int subindex);
790 
791  void evaluationError(
792  const PRM_ParmList *thelist,
793  int vector_index, int err, int thread) const;
794 
795  // This method is *NOT* thread-safe wrt microNode() so do not access the
796  // source and destination PRM_Instance pointers from multiple threads when
797  // calling this.
798  void adoptMicroNodes(PRM_Instance &thesrcinstance);
799 
800  /// Thread-safe version of hasMicroNodes() that can be called at the same
801  /// time as microNode().
802  inline PRM_ParmMicroNode *threadSafeMicroNodes() const;
803 
804 private:
805 
806  enum // bitflags for myBitField
807  {
808  /*BITFLAG_UNUSED_BIT = 0x0002,*/
809  /*BITFLAG_UNUSED_BIT = 0x0004,*/
810  BITFLAG_EXPRESSIONSTATE = 0x0008,
811  BITFLAG_UNDOSAVED = 0x0010,
812  BITFLAG_ACTIVETAKE = 0x0020,
813  BITFLAG_TAKEALWAYSACTIVE = 0x0040,
814  BITFLAG_SAVEAUTOSCOPE = 0x0080,
815  BITFLAG_SPAREPARM = 0x0100,
816  BITFLAG_AUTOTAKEUNDOSAVED = 0x0400,
817  BITFLAG_DEFAULTSINIT = 0x0800,
818  BITFLAG_VALUESTATE = 0x1000,
819  BITFLAG_BYPASS = 0x2000,
820  BITFLAG_SAVELABEL = 0x4000,
821  BITFLAG_SAVEAUTOSELECT = 0x8000,
822 
823  // Flags that should be saved
824  BITFLAG_SAVE_MASK = (BITFLAG_EXPRESSIONSTATE)
825  };
826 
827  unsigned int myBitField;
828  unsigned int myEnableField;
829  unsigned int myLockField;
830  unsigned int myAutoScopeField;
831  unsigned int myVisibleField;
832  unsigned int myAutoSelectField;
833 
834  // Flag to indicate that the handle binded to this parm is active
835  unsigned int myActiveField;
836 
837  PRM_Template *myTemplatePtr;
838 
839  PRM_Value *myNotifyValue;
840  unsigned myDirtyParmFlags;
841  unsigned mySendExtraFlags;
842 
843  CH_Channel **myChannelPtrs;
845  myChannelAliases;
846 
847  struct ChannelCustomColor
848  {
849  ChannelCustomColor()
850  { myHasCustomColor = false; }
851  UT_Color myColor;
852  bool myHasCustomColor;
853  };
854  ChannelCustomColor *myChannelColors;
855 
856  PRM_Parm *myParm;
857  const PRM_Multi *myMultiParmOwner;
858 
859  PRM_ParmMicroNode *myMicroNodes;
860  PRM_ConstMicroNode *myConstMicroNodes;
861  mutable UT_TBBSpinLock myMicroNodesLock;
862 };
863 
864 inline int
866  bool allow_alias) const
867 {
868  int size = myTemplatePtr->getVectorSize();
869  int retval = -1;
870  int i = 0;
871 
872  if (allow_alias && myChannelAliases)
873  {
874  for (i = 0; i < size; i++)
875  {
876  if (myChannelAliases[i] == thechannelname)
877  {
878  retval = i;
879  break;
880  }
881  }
882  }
883 
884  if (retval == -1)
885  retval = myTemplatePtr->findSubIndex(thechannelname);
886 
887  return retval;
888 }
889 
890 inline unsigned
892 {
893  if(comp < 0)
894  return myEnableField;
895 
896  return ( myEnableField & (1<<comp) ) ? 1 : 0;
897 }
898 
899 inline bool
901 {
902  // Separators, labels and headings have no values, so we use the entire
903  // visible field for them.
904  if (!getVectorSize())
905  return (myVisibleField != 0);
906 
907  return getFieldBit(myVisibleField, comp);
908 }
909 
910 inline void
912 {
913  if (getVectorSize())
914  setFieldBit(myVisibleField, comp, f);
915  else
916  myVisibleField = f ? SYS_UINT32_MAX : 0;
917 }
918 
919 #endif
CH_Manager * getManager() const
unsigned int getSaveFlags() const
Definition: PRM_Instance.h:379
bool getVisibleState(int comp=-1) const
Definition: PRM_Instance.h:900
PRM_OverrideType
Definition: PRM_Parm.h:70
PRM_AddKeyType
Definition: PRM_Parm.h:59
bool isSendExtra(int vi) const
Definition: PRM_Instance.h:484
#define EV_NOERROR
Definition: EX_Error.h:18
void setUndoSavedFlag(bool f)
Definition: PRM_Instance.h:415
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
const PRM_Template * getTemplatePtr() const
Definition: PRM_Instance.h:538
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
int int32
Definition: SYS_Types.h:39
void setAutoScopeField(unsigned int field)
Definition: PRM_Instance.h:671
void setSaveFlags(unsigned int f)
Definition: PRM_Instance.h:381
CH_ExprLanguage
const UT_StringHolder & getChannelToken(int i) const
Definition: PRM_Instance.h:533
CH_StringMeaning
GT_API const UT_StringHolder time
UT_SharedPtr< PRM_UndoData > PRM_UndoDataHandle
Definition: PRM_Parm.h:140
const PRM_Template * getMultiParmTemplate() const
Definition: PRM_Template.h:275
bool isDirty(int vec_idx) const
Definition: PRM_Instance.h:470
const PRM_ChoiceList * getChoiceListPtr() const
Definition: PRM_Instance.h:535
GLsizei const GLfloat * value
Definition: glcorearb.h:824
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
UT_ConcurrentSet< UT_StringHolder > DEP_ContextOptionDeps
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
Definition: SYS_Types.h:136
PRM_DefaultType
Definition: PRM_Default.h:19
int getExpressionState() const
Definition: PRM_Instance.h:263
bool getSaveAutoSelectFlag() const
Definition: PRM_Instance.h:427
PRM_KeySetType
GLdouble s
Definition: glad.h:3009
const char * getToken() const
Definition: PRM_Instance.h:521
int getVectorSize() const
Definition: PRM_Instance.h:527
unsigned getEnableState(int comp=-1) const
Definition: PRM_Instance.h:891
__hostdev__ void setValue(uint32_t offset, bool v)
Definition: NanoVDB.h:5750
const PRM_Value * inputNotifyValue() const
Definition: PRM_Instance.h:505
bool getSaveLabelFlag() const
Definition: PRM_Instance.h:431
bool hasAnySendExtraFlags() const
Definition: PRM_Instance.h:486
float fpreal32
Definition: SYS_Types.h:200
void setChannel(int subindex, CH_Channel *chp)
Definition: PRM_Instance.h:319
void setDefaultsInitFlag(bool f)
Definition: PRM_Instance.h:442
__hostdev__ float getValue(uint32_t i) const
Definition: NanoVDB.h:5578
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
virtual bool isRotationParm() const
Definition: PRM_Instance.h:610
double fpreal64
Definition: SYS_Types.h:201
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: APEX_Include.h:55
PRM_TypeExtended getTypeExtended() const
Definition: PRM_Instance.h:509
CH_Channel * getChannel(int subindex) const
Definition: PRM_Instance.h:313
void clearAllDirtyFlags()
Definition: PRM_Instance.h:474
PRM_Template * getTemplatePtr()
Definition: PRM_Instance.h:539
int findSubIndex(const UT_StringRef &thechannelname, bool allow_alias) const
Definition: PRM_Instance.h:865
void setDirtyFlags(int vec_idx)
Definition: PRM_Instance.h:476
GLfloat f
Definition: glcorearb.h:1926
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
bool getDefaultsInitFlag() const
Definition: PRM_Instance.h:440
virtual bool isEditable(PRM_ParmList *thelist, fpreal time, int index) const
Definition: PRM_Instance.h:286
bool getBypassFlag() const
Definition: PRM_Instance.h:399
fpreal getGlobalStart() const
Definition: CH_Manager.h:1223
GLint ref
Definition: glcorearb.h:124
void setVisibleState(bool f, int comp=-1)
Definition: PRM_Instance.h:911
PRM_ChanState
Definition: PRM_ChanState.h:14
SYS_FORCE_INLINE void checkForExpressionErrors(const PRM_ParmList *thelist, int vector_index, int thread) const
Definition: PRM_Instance.h:684
PRM_Template * getMultiParmTemplate()
Definition: PRM_Instance.h:519
UT_Function< void(DEP_MicroNode &, DEP_MicroNode &) > Visitor
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
fpreal getMultiSize() const
Definition: PRM_Instance.h:513
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
bool getUndoSavedFlag()
Definition: PRM_Instance.h:413
void setLockField(unsigned int locks)
Definition: PRM_Instance.h:669
void setActiveTakeFlag(int onoff)
Definition: PRM_Instance.h:388
PRM_ErrorCode
Definition: PRM_Error.h:21
const char * getLabel() const
Definition: PRM_Instance.h:523
long long int64
Definition: SYS_Types.h:116
void setBypassFlag(bool onoff)
Definition: PRM_Instance.h:401
GLuint const GLchar * name
Definition: glcorearb.h:786
bool getAlwaysTakeFlag() const
Definition: PRM_Instance.h:386
#define SYS_UINT32_MAX
Definition: SYS_Types.h:172
unsigned int getAutoScopeField() const
Definition: PRM_Instance.h:448
const PRM_Type & getType() const
Definition: PRM_Instance.h:507
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate active
virtual void destroyChildParms()
Definition: PRM_Instance.h:467
GLdouble t
Definition: glad.h:2397
unsigned int getLockField() const
Definition: PRM_Instance.h:446
PRM_Callback getCallback() const
Definition: PRM_Instance.h:525
fpreal getEvaluateTime(int thread) const
Functions for obtaining and setting the current evaluation time.
Definition: CH_Manager.h:1476
GLsizeiptr size
Definition: glcorearb.h:664
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
PRM_MultiType getMultiType() const
Definition: PRM_Instance.h:511
bool getSaveAutoScopeFlag() const
Definition: PRM_Instance.h:424
const PRM_Template * getMultiParmTemplate() const
Definition: PRM_Instance.h:517
virtual bool isEditableByUI(PRM_ParmList *thelist, fpreal time, int index) const
Definition: PRM_Instance.h:288
const PRM_Range * getRangePtr() const
Definition: PRM_Instance.h:529
SIM_API const UT_StringHolder force
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
PRM_TypeExtended
Definition: PRM_Type.h:521
fpreal64 fpreal
Definition: SYS_Types.h:278
PRM_ParmOwner * getParmOwner() const
Definition: PRM_Instance.h:557
GLuint index
Definition: glcorearb.h:786
bool areAllFlagsClean() const
Definition: PRM_Instance.h:472
PRM_Parm * getParm() const
Definition: PRM_Instance.h:561
int getValueState() const
Definition: PRM_Instance.h:274
void setExpressionState(int state)
Definition: PRM_Instance.h:267
bool getAutoTakeUndoSavedFlag()
Definition: PRM_Instance.h:418
fpreal getGlobalStartTime() const
Definition: PRM_Instance.h:305
void getChannelToken(UT_String &chname, int i) const
Definition: PRM_Instance.h:531
void setTimeDependentForEval(int vi, bool timedep) const
Definition: PRM_Instance.h:346
void setSendExtra(int vi)
Definition: PRM_Instance.h:488
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
unsigned int getAutoSelectField() const
Definition: PRM_Instance.h:652
bool hasMicroNodes() const
Return true if this parameter has micronodes, NOT thread-safe.
Definition: PRM_Instance.h:625
CH_Collection * getChannelGroupPtr() const
Definition: PRM_Instance.h:291
void setAutoTakeUndoSavedFlag(bool f)
Definition: PRM_Instance.h:420
#define PRM_API
Definition: PRM_API.h:10
unsigned int uint
Definition: SYS_Types.h:45
int getMultiStartOffset() const
Definition: PRM_Instance.h:515
void setAutoSelectField(unsigned int field)
Definition: PRM_Instance.h:677
state
Definition: core.h:2289
void setValueState(int state)
Definition: PRM_Instance.h:278
PRM_Value * inputNotifyValue()
Definition: PRM_Instance.h:504
Definition: format.h:1821
PRM_MultiType
This type enum defines the different types of multi (dynamic) parameters.
Definition: PRM_Type.h:426
bool getActiveTakeFlag() const
Definition: PRM_Instance.h:384
fpreal getEvalTime(int thread) const
Definition: PRM_Instance.h:297
PRM_ParmList * getParmList() const
Definition: PRM_Instance.h:559