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