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  bool node_is_cooking);
357 
358  int changePending(int index);
359  virtual PRM_ChanState getChanState(fpreal time, int index) const;
360  virtual PRM_ChanState getChanState(fpreal time) const;
361 
362  // add keyframes if changes are pending
363  virtual void hardenChanges(fpreal time,
364  int index,
365  bool theforceflag,
366  const char *patt = nullptr,
367  CH_ChannelRefList *list = nullptr) = 0;
368 
369  // sets a key even if no channel exists
370  void setKey(fpreal time, int index);
371  void setKey(fpreal time, int index, const char *expr,
372  CH_ExprLanguage language,
373  const char *patt = nullptr,
374  CH_ChannelRefList *list = nullptr);
375 
376  void setFullKey(fpreal gtime, int index,
377  CH_FullKey const& key,
378  bool accel_ratios = true);
379 
380  unsigned int getSaveFlags() const
381  { return myBitField & BITFLAG_SAVE_MASK; }
382  void setSaveFlags(unsigned int f)
383  { myBitField |= (f & BITFLAG_SAVE_MASK); }
384 
385  bool getActiveTakeFlag() const
386  { return myBitField & BITFLAG_ACTIVETAKE; }
387  bool getAlwaysTakeFlag() const
388  { return myBitField & BITFLAG_TAKEALWAYSACTIVE; }
389  void setActiveTakeFlag(int onoff)
390  {
391  if (onoff) myBitField |= BITFLAG_ACTIVETAKE;
392  else
393  {
394  if (!(myBitField & BITFLAG_TAKEALWAYSACTIVE))
395  myBitField &= ~BITFLAG_ACTIVETAKE;
396  else myBitField |= BITFLAG_ACTIVETAKE;
397  }
398  }
399 
400  bool getBypassFlag() const
401  { return myBitField & BITFLAG_BYPASS; }
402  void setBypassFlag(bool onoff)
403  {
404  // Only allow bypass on spare parameters
405  if (isSpareParm() && onoff)
406  myBitField |= BITFLAG_BYPASS;
407  else
408  myBitField &= ~BITFLAG_BYPASS;
409  }
410 
411  bool getVisibleState(int comp = -1) const;
412  void setVisibleState(bool f, int comp = -1);
413 
415  { return myBitField & BITFLAG_UNDOSAVED; }
416  void setUndoSavedFlag(bool f)
417  { if (f) myBitField |= BITFLAG_UNDOSAVED;
418  else myBitField &= ~BITFLAG_UNDOSAVED;}
420  { return myBitField & BITFLAG_AUTOTAKEUNDOSAVED; }
422  { if (f) myBitField |= BITFLAG_AUTOTAKEUNDOSAVED;
423  else myBitField &= ~BITFLAG_AUTOTAKEUNDOSAVED;}
424 
425  bool getSaveAutoScopeFlag() const
426  { return myBitField & BITFLAG_SAVEAUTOSCOPE; }
427 
429  { return myBitField & BITFLAG_SAVEAUTOSELECT; }
430 
431  void setSaveLabelFlag(bool f);
432  bool getSaveLabelFlag() const
433  { return myBitField & BITFLAG_SAVELABEL; }
434 
435  bool getLockedFlag(int vec_idx) const;
436  bool areAllComponentsLocked() const;
437  void setLockedFlag(int vec_idx, bool f);
438  bool getAutoScopedFlag(int vec_idx) const;
439  void setAutoScopedFlag(int vec_idx, bool f);
440 
441  bool getDefaultsInitFlag() const
442  { return (myBitField & BITFLAG_DEFAULTSINIT) != 0; }
443  void setDefaultsInitFlag(bool f)
444  { if (f) myBitField |= BITFLAG_DEFAULTSINIT;
445  else myBitField &= ~BITFLAG_DEFAULTSINIT;}
446 
447  unsigned int getLockField() const
448  { return myLockField; }
449  unsigned int getAutoScopeField() const
450  { return myAutoScopeField; }
451 
452  virtual int setOverride(int index, int data_idx,
453  const char *source,
455  virtual int setOverrideDisable(int index, int onoff);
456  virtual const char *getOverride(int index) const;
457  virtual bool getOverrideType(int index,
458  PRM_OverrideType& type) const;
459  virtual int getOverrideDataIndex(int index) const;
460 
461  ///Sometimes we may want to make an existing and enabled override
462  ///temporarily inactive, so that we can "shut off" the override without
463  ///losing any dependencies between the parm and the source of its exported
464  ///override values. (e.g. might want to temporarily change the parm's
465  ///display colour)
466  virtual int getIsOverrideActive(int index) const;
467 
468  virtual void destroyChildParms() { }
469 
470  // A parameter becomes dirty whenever its value is set.
471  bool isDirty(int vec_idx) const
472  { return getFieldBit(myDirtyParmFlags, vec_idx); }
473  bool areAllFlagsClean() const
474  { return !myDirtyParmFlags; }
476  { myDirtyParmFlags = 0; }
477  void setDirtyFlags(int vec_idx)
478  {
479  setFieldBit(myDirtyParmFlags, vec_idx, true);
480  setSendExtra(vec_idx);
481  }
482 
483  // mySendExtraFlags is a per-component bitfield that has its bit set
484  // if it needs to be dirty propagated.
485  bool isSendExtra(int vi) const
486  { return getFieldBit(mySendExtraFlags, vi); }
487  bool hasAnySendExtraFlags() const
488  { return (mySendExtraFlags != 0); }
489  void setSendExtra(int vi)
490  {
491  if (!getFieldBit(mySendExtraFlags, vi))
492  {
493  setFieldBit(mySendExtraFlags, vi, true);
494  getParmList()->bumpNumSendExtra(
495  vi < 0 ? getVectorSize() : +1);
496  }
497  }
498 
499  // The input notify value is not created by default. Call
500  // createInputNotifyValue when you need it. Handles use this
501  // notify value to add an interest in input fields so they can know
502  // when the input has changed. Op's trigger this notify value when
503  // they generate their input groups, if this value exists.
504  void createInputNotifyValue();
505  PRM_Value *inputNotifyValue() { return myNotifyValue; }
506  const PRM_Value *inputNotifyValue() const { return myNotifyValue; }
507 
508  const PRM_Type &getType() const
509  { return myTemplatePtr->getType(); }
511  { return myTemplatePtr->getTypeExtended(); }
513  { return myTemplatePtr->getMultiType(); }
515  { return myTemplatePtr->getMultiSize(); }
517  { return myTemplatePtr->getMultiStartOffset(); }
519  { return myTemplatePtr->getMultiParmTemplate(); }
521  { return myTemplatePtr->getMultiParmTemplate(); }
522  const char *getToken() const
523  { return myTemplatePtr->getToken(); }
524  const char *getLabel() const
525  { return myTemplatePtr->getLabel(); }
527  { return myTemplatePtr->getCallback(); }
528  int getVectorSize() const
529  { return myTemplatePtr->getVectorSize(); }
530  const PRM_Range * getRangePtr() const
531  { return myTemplatePtr->getRangePtr(); }
532  void getChannelToken(UT_String &chname, int i) const
533  { myTemplatePtr->getChannelToken(chname, i); }
534  const UT_StringHolder& getChannelToken(int i) const
535  { return myTemplatePtr->getChannelToken(i); }
537  { return myTemplatePtr->getChoiceListPtr(); }
538 
539  const PRM_Template *getTemplatePtr() const { return myTemplatePtr; }
540  PRM_Template *getTemplatePtr() { return myTemplatePtr; }
541 
542  // get/setChannelAlias allow the manipulation of channel aliases.
543  // setChannelAlias will return false if the operation fails and true
544  // otherwise. Do not use the set method directly, only PRM_ParmList should
545  // do that. To set a channel alias, use the OP_Node method.
546  bool hasChannelAlias(int index) const;
547  void getChannelAlias(UT_String &strref, int index) const;
548  const UT_StringHolder& getChannelAlias(int index) const;
549  bool setChannelAlias(const UT_StringHolder &token_alias,
550  int index);
551 
552  // Returns the sub-index of the parm given by the name thechannelname. If
553  // allow_alias is true, the channel name aliases are also searched,
554  // otherwise they are ignored.
555  int findSubIndex(const UT_StringRef &thechannelname,
556  bool allow_alias) const;
557 
559  { return myParm->getParmOwner(); }
561  { return myParm->getOwner(); }
562  PRM_Parm *getParm() const
563  { return myParm; }
564 
565  static bool isChanRefString(const char *str, bool is_expr,
566  UT_String *chref = nullptr);
567  static bool isObsoleteDirectChanRefString(
568  const char *str,
569  UT_String *chref = nullptr);
570 
571  // Returns true if the channame is the token (or alias) of the channel at
572  // vec_index, and returns false otherwise.
573  // The length of channame can be given in channamelen to speed up rejections
574  // if the caller caches the string length.
575  bool hasChannelName(const UT_StringRef &s, int vi) const;
576 
577  // Methods for accessing and setting the active handle binding flag
578  bool isActive(const int index) const;
579  void setActive(const int index, const bool active);
580 
581  // Spare parameter flag
582  bool isSpareParm() const;
583  void setSpareParm(bool spare);
584 
585  // Multiparm instance information
586  const PRM_Instance *getMultiParmOwner() const;
587  void setMultiParmOwner(const PRM_Multi *multiparmowner);
588 
589  /// Returns the multi-parm template for this child parm. Returns nullptr
590  /// if this parm is not part of a multi-parm
591  const PRM_Template *findMultiParmTemplate() const;
592 
593  /// Return the list of instance indicies for this parameter.
594  /// If this parameter is part of a multi-parameter, then its index in the
595  /// multi-parm array will be inserted into the indices array. If the
596  /// multi-parm is nested in other multi-parms, then the indices array will
597  /// have multiple entries (with the outer multi-parm listed first, and the
598  /// inner-most multi-parm last in the array).
599  /// \param indices The list of index instances.
600  /// \param instance_index Each multi-parm can have multiple parameters in
601  /// each instance. If instance_index is true, the instance number will be
602  /// returned. Otherwise the raw offset into the multi-parm will be
603  /// extracted.
604  int getMultiInstanceIndex(UT_Array<int> &indices,
605  bool instance_index=true) const;
606 
607  bool validIndex(int index) const;
608 
609  virtual int64 getMemoryUsage(bool inclusive) const;
610 
611  virtual bool isRotationParm() const
612  { return false; }
613 
614  /// During loading we need to validate that the channels tied to the
615  /// parameter indices are correclty mapped.
616  void validateChannelNames(PRM_ParmList &list);
617 
618  /// Thread-safe access to get or create a micronode
619  DEP_MicroNode & microNode(int vi);
620 
621 
622  /// Thread-safe access to get micronodes
623  void getMicroNodes(DEP_MicroNodeList &micronodes) const;
624 
625  /// Return true if this parameter has micronodes, NOT thread-safe
626  bool hasMicroNodes() const
627  { return (myMicroNodes != nullptr); }
628 
629  void clearMicroNodeInputs();
630  void getMicroNodeInputList(DEP_MicroNodeList &inputs) const;
631  int getMicroNodeNumInputs() const;
632  void getMicroNodeOutputList(DEP_MicroNodeList &outputs) const;
633 
634  void propagateDirty(
635  const DEP_MicroNode::Visitor& client_visit,
636  DEP_MicroNode *parmlist_micronode,
637  bool force,
638  bool *dirtied_data = nullptr);
639  void dumpMicroNodes(
640  std::ostream &os,
641  bool as_DOT,
642  int indent_level) const;
643  int64 getMicroNodesMemoryUsage() const;
644 
645  /// Custom Channel Color
646  bool hasChannelCustomColor(int index) const;
647  const UT_Color &getChannelCustomColor(int index) const;
648  void setChannelCustomColor(int index, const UT_Color &c);
649  void resetChannelCustomColor(int index);
650 
651  bool getAutoSelectFlag(int vec_idx) const;
652  void setAutoSelectFlag(int vec_idx, bool f);
653  unsigned int getAutoSelectField() const
654  { return myAutoSelectField; }
655 
656  void setTimeDependentMicroNode(int subindex, bool timedep);
657 
658  /// Thread-safe access to get or create a const micronode
659  /// A const micro node gives the same dependencies as
660  /// microNode(), but the time dependent flag will always be
661  /// false.
662  /// It also creates missing base microNodes.
663  DEP_MicroNode & constMicroNode(int vi);
664 protected:
665  void clearAndDestroyChannels();
666 
667  void addParmWarning(PRM_ErrorCode code) const;
668  void indexError(int index);
669 
670  void setLockField(unsigned int locks)
671  { myLockField = locks; }
672  void setAutoScopeField(unsigned int field)
673  {
674  myAutoScopeField = field;
675  myBitField |= BITFLAG_SAVEAUTOSCOPE;
676  }
677 
678  void setAutoSelectField(unsigned int field)
679  {
680  myAutoSelectField = field;
681  myBitField |= BITFLAG_SAVEAUTOSELECT;
682  }
683 
684  SYS_FORCE_INLINE void
686  const PRM_ParmList *thelist, int vector_index, int thread) const
687  {
688  int err;
689  err = ev_GetErrNo(thread);
690  if (err != EV_NOERROR)
691  evaluationError(thelist, vector_index, err, thread);
692  }
693 
694  bool validateAccess();
695 
696  // This helper method is called by loadCommand() in derived classes to
697  // load the token either as a reference to our channel, or failing that,
698  // as an expression.
699  void loadTokenAsChannelNameOrExpression(
700  const UT_String &token, int index);
701 
702  // This method loads the options of the parm that are within '[]' before
703  // the parm value. The istream must be positioned after the first '['
704  // and this method will leave it after the ']' and return true. If it
705  // could not correctly parse the options, it will return false.
706  bool loadAsciiOptions(UT_IStream &is, uint &pending_mask);
707 
708  // This method checks the given binary packet id against the list of
709  // options it supports, if successful, it loads the packet and returns
710  // true, otherwise returns false.
711  bool loadBinaryOption(UT_IStream &is, short packet_id);
712 
713  // This method will save the options of the parm if there are any to set.
714  // Currently, only the locked flag is saved. If the parm is not locked,
715  // this method won't do anything in an effort to maintain forwards
716  // compatibility with older versions of Houdini.
717  // Returns true if anything was written to the stream.
718  void saveAsciiOptions(std::ostream &os) const;
719  bool saveBinaryOptions(int class_packet_id,
720  UT_Packet &packet,
721  std::ostream &os) const;
722 
723  CH_ExprLanguage stringMeaningToExprLanguage(
724  CH_StringMeaning meaning) const;
725 
727  {
738  PRM_IO_TOKEN_NUM
739  };
740 
741  // Returns the token used in parm IO.
742  static const char *getPacketIOToken(PRM_ParmIOToken token);
743  static int getPacketIOTokenLen(PRM_ParmIOToken token);
744  static int getPacketIOBinaryId(PRM_ParmIOToken token);
745 
746  // Compares if the given text matches a given token. You
747  // must provide the length of the text, which has the virtue
748  // of avoiding having to harden buffers!
749  static bool comparePacketIOToken(PRM_ParmIOToken token,
750  const char *text,
751  int textlen);
752 
753  // returns true if myData should be saved. Used for caching just within a
754  // session or preventing expensive copy/pastes.
755  bool shouldSaveData() const;
756 
757 private:
758 
759  inline bool getFieldBit(unsigned int field, int i) const
760  {
761  if (i < 0)
762  return (field != 0);
763  else
764  return ((field & (1 << (unsigned)i)) != 0);
765  }
766  inline void setFieldBit(unsigned int &field, int i, bool f)
767  {
768  if (i < 0)
769  {
770  if (f) // enable lowermost vector size bits
771  field = (1<<(unsigned)getVectorSize()) - 1;
772  else
773  field = 0;
774  }
775  else
776  {
777  if (f)
778  field |= (1 << (unsigned)i);
779  else
780  field &= ~(1 << (unsigned)i);
781  }
782  }
783 
784  void getFullParmPath(UT_WorkBuffer &path) const;
785 
786  /// When loading a file, it's possible that the channel mapping doesn't
787  /// match the expected channel name. In this case, we want to either
788  /// rename the channel, or delete the channel (if there are name
789  /// collisions).
790  void validateChannelName(PRM_ParmList &list, int subindex);
791 
792  void evaluationError(
793  const PRM_ParmList *thelist,
794  int vector_index, int err, int thread) const;
795 
796  // This method is *NOT* thread-safe wrt microNode() so do not access the
797  // source and destination PRM_Instance pointers from multiple threads when
798  // calling this.
799  void adoptMicroNodes(PRM_Instance &thesrcinstance);
800 
801  /// Thread-safe version of hasMicroNodes() that can be called at the same
802  /// time as microNode().
803  inline PRM_ParmMicroNode *threadSafeMicroNodes() const;
804 
805 private:
806 
807  enum // bitflags for myBitField
808  {
809  /*BITFLAG_UNUSED_BIT = 0x0002,*/
810  /*BITFLAG_UNUSED_BIT = 0x0004,*/
811  BITFLAG_EXPRESSIONSTATE = 0x0008,
812  BITFLAG_UNDOSAVED = 0x0010,
813  BITFLAG_ACTIVETAKE = 0x0020,
814  BITFLAG_TAKEALWAYSACTIVE = 0x0040,
815  BITFLAG_SAVEAUTOSCOPE = 0x0080,
816  BITFLAG_SPAREPARM = 0x0100,
817  BITFLAG_AUTOTAKEUNDOSAVED = 0x0400,
818  BITFLAG_DEFAULTSINIT = 0x0800,
819  BITFLAG_VALUESTATE = 0x1000,
820  BITFLAG_BYPASS = 0x2000,
821  BITFLAG_SAVELABEL = 0x4000,
822  BITFLAG_SAVEAUTOSELECT = 0x8000,
823 
824  // Flags that should be saved
825  BITFLAG_SAVE_MASK = (BITFLAG_EXPRESSIONSTATE)
826  };
827 
828  unsigned int myBitField;
829  unsigned int myEnableField;
830  unsigned int myLockField;
831  unsigned int myAutoScopeField;
832  unsigned int myVisibleField;
833  unsigned int myAutoSelectField;
834 
835  // Flag to indicate that the handle binded to this parm is active
836  unsigned int myActiveField;
837 
838  PRM_Template *myTemplatePtr;
839 
840  PRM_Value *myNotifyValue;
841  unsigned myDirtyParmFlags;
842  unsigned mySendExtraFlags;
843 
844  CH_Channel **myChannelPtrs;
846  myChannelAliases;
847 
848  struct ChannelCustomColor
849  {
850  ChannelCustomColor()
851  { myHasCustomColor = false; }
852  UT_Color myColor;
853  bool myHasCustomColor;
854  };
855  ChannelCustomColor *myChannelColors;
856 
857  PRM_Parm *myParm;
858  const PRM_Multi *myMultiParmOwner;
859 
860  PRM_ParmMicroNode *myMicroNodes;
861  PRM_ConstMicroNode *myConstMicroNodes;
862  mutable UT_TBBSpinLock myMicroNodesLock;
863 };
864 
865 inline int
867  bool allow_alias) const
868 {
869  int size = myTemplatePtr->getVectorSize();
870  int retval = -1;
871  int i = 0;
872 
873  if (allow_alias && myChannelAliases)
874  {
875  for (i = 0; i < size; i++)
876  {
877  if (myChannelAliases[i] == thechannelname)
878  {
879  retval = i;
880  break;
881  }
882  }
883  }
884 
885  if (retval == -1)
886  retval = myTemplatePtr->findSubIndex(thechannelname);
887 
888  return retval;
889 }
890 
891 inline unsigned
893 {
894  if(comp < 0)
895  return myEnableField;
896 
897  return ( myEnableField & (1<<comp) ) ? 1 : 0;
898 }
899 
900 inline bool
902 {
903  // Separators, labels and headings have no values, so we use the entire
904  // visible field for them.
905  if (!getVectorSize())
906  return (myVisibleField != 0);
907 
908  return getFieldBit(myVisibleField, comp);
909 }
910 
911 inline void
913 {
914  if (getVectorSize())
915  setFieldBit(myVisibleField, comp, f);
916  else
917  myVisibleField = f ? SYS_UINT32_MAX : 0;
918 }
919 
920 #endif
CH_Manager * getManager() const
unsigned int getSaveFlags() const
Definition: PRM_Instance.h:380
bool getVisibleState(int comp=-1) const
Definition: PRM_Instance.h:901
PRM_OverrideType
Definition: PRM_Parm.h:70
PRM_AddKeyType
Definition: PRM_Parm.h:59
bool isSendExtra(int vi) const
Definition: PRM_Instance.h:485
#define EV_NOERROR
Definition: EX_Error.h:18
void setUndoSavedFlag(bool f)
Definition: PRM_Instance.h:416
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
const PRM_Template * getTemplatePtr() const
Definition: PRM_Instance.h:539
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:672
void setSaveFlags(unsigned int f)
Definition: PRM_Instance.h:382
CH_ExprLanguage
const UT_StringHolder & getChannelToken(int i) const
Definition: PRM_Instance.h:534
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:471
const PRM_ChoiceList * getChoiceListPtr() const
Definition: PRM_Instance.h:536
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:428
PRM_KeySetType
GLdouble s
Definition: glad.h:3009
const char * getToken() const
Definition: PRM_Instance.h:522
int getVectorSize() const
Definition: PRM_Instance.h:528
unsigned getEnableState(int comp=-1) const
Definition: PRM_Instance.h:892
__hostdev__ void setValue(uint32_t offset, bool v)
Definition: NanoVDB.h:5750
const PRM_Value * inputNotifyValue() const
Definition: PRM_Instance.h:506
bool getSaveLabelFlag() const
Definition: PRM_Instance.h:432
bool hasAnySendExtraFlags() const
Definition: PRM_Instance.h:487
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:443
__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:611
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:510
CH_Channel * getChannel(int subindex) const
Definition: PRM_Instance.h:313
void clearAllDirtyFlags()
Definition: PRM_Instance.h:475
PRM_Template * getTemplatePtr()
Definition: PRM_Instance.h:540
int findSubIndex(const UT_StringRef &thechannelname, bool allow_alias) const
Definition: PRM_Instance.h:866
void setDirtyFlags(int vec_idx)
Definition: PRM_Instance.h:477
GLfloat f
Definition: glcorearb.h:1926
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
bool getDefaultsInitFlag() const
Definition: PRM_Instance.h:441
virtual bool isEditable(PRM_ParmList *thelist, fpreal time, int index) const
Definition: PRM_Instance.h:286
bool getBypassFlag() const
Definition: PRM_Instance.h:400
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:912
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:685
PRM_Template * getMultiParmTemplate()
Definition: PRM_Instance.h:520
UT_Function< void(DEP_MicroNode &, DEP_MicroNode &) > Visitor
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
fpreal getMultiSize() const
Definition: PRM_Instance.h:514
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
bool getUndoSavedFlag()
Definition: PRM_Instance.h:414
void setLockField(unsigned int locks)
Definition: PRM_Instance.h:670
void setActiveTakeFlag(int onoff)
Definition: PRM_Instance.h:389
PRM_ErrorCode
Definition: PRM_Error.h:21
const char * getLabel() const
Definition: PRM_Instance.h:524
long long int64
Definition: SYS_Types.h:116
void setBypassFlag(bool onoff)
Definition: PRM_Instance.h:402
GLuint const GLchar * name
Definition: glcorearb.h:786
bool getAlwaysTakeFlag() const
Definition: PRM_Instance.h:387
#define SYS_UINT32_MAX
Definition: SYS_Types.h:172
unsigned int getAutoScopeField() const
Definition: PRM_Instance.h:449
const PRM_Type & getType() const
Definition: PRM_Instance.h:508
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:468
GLdouble t
Definition: glad.h:2397
unsigned int getLockField() const
Definition: PRM_Instance.h:447
PRM_Callback getCallback() const
Definition: PRM_Instance.h:526
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:512
bool getSaveAutoScopeFlag() const
Definition: PRM_Instance.h:425
const PRM_Template * getMultiParmTemplate() const
Definition: PRM_Instance.h:518
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:530
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:558
GLuint index
Definition: glcorearb.h:786
bool areAllFlagsClean() const
Definition: PRM_Instance.h:473
PRM_Parm * getParm() const
Definition: PRM_Instance.h:562
int getValueState() const
Definition: PRM_Instance.h:274
void setExpressionState(int state)
Definition: PRM_Instance.h:267
bool getAutoTakeUndoSavedFlag()
Definition: PRM_Instance.h:419
fpreal getGlobalStartTime() const
Definition: PRM_Instance.h:305
void getChannelToken(UT_String &chname, int i) const
Definition: PRM_Instance.h:532
void setTimeDependentForEval(int vi, bool timedep) const
Definition: PRM_Instance.h:346
void setSendExtra(int vi)
Definition: PRM_Instance.h:489
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
unsigned int getAutoSelectField() const
Definition: PRM_Instance.h:653
bool hasMicroNodes() const
Return true if this parameter has micronodes, NOT thread-safe.
Definition: PRM_Instance.h:626
CH_Collection * getChannelGroupPtr() const
Definition: PRM_Instance.h:291
void setAutoTakeUndoSavedFlag(bool f)
Definition: PRM_Instance.h:421
#define PRM_API
Definition: PRM_API.h:10
unsigned int uint
Definition: SYS_Types.h:45
int getMultiStartOffset() const
Definition: PRM_Instance.h:516
void setAutoSelectField(unsigned int field)
Definition: PRM_Instance.h:678
state
Definition: core.h:2289
void setValueState(int state)
Definition: PRM_Instance.h:278
PRM_Value * inputNotifyValue()
Definition: PRM_Instance.h:505
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:385
fpreal getEvalTime(int thread) const
Definition: PRM_Instance.h:297
PRM_ParmList * getParmList() const
Definition: PRM_Instance.h:560