HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PRM_Data.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_Data.h (Parameter Library)
7  *
8  * COMMENTS:
9  * PRM_Data contains the variable part of a Data
10  * parameter.
11  *
12  */
13 
14 #ifndef __PRM_Data__
15 #define __PRM_Data__
16 
17 #include "PRM_API.h"
18 #include "PRM_Default.h"
19 #include "PRM_Instance.h"
20 #include "PRM_KeySetType.h"
21 #include "PRM_Lock.h"
22 #include "PRM_Parm.h"
23 #include <CH/CH_ExprLanguage.h>
24 #include <CH/CH_Types.h>
25 #include <UT/UT_Array.h>
26 #include <SYS/SYS_Types.h>
27 
28 #include <iostream>
29 
30 
31 class PRM_ParmList;
32 class PRM_Template;
33 class CH_Channel;
34 class CH_Collection;
35 class CH_Manager;
36 class UT_IStream;
37 class UT_JSONValueMap;
38 class UT_String;
39 class UT_StringWrap;
40 class UT_TokenString;
41 
42 
44 {
45 public:
46  PRM_Data(PRM_Template *thetemplateptr,
47  PRM_Parm *parm);
48  PRM_Data(PRM_Data *thesrcptr,
49  PRM_Parm *parm);
50  ~PRM_Data() override;
51  void adopt(PRM_Instance &thesrc) override;
52  PRM_Instance *duplicateSelf(PRM_Parm *parm) override;
53 
55  PRM_AddKeyType add_key) override;
56  void revertToDefault(int index) override;
57  void revertToDefaults(bool clear_channels = true) override;
58  void restoreFactoryDefault(int index) override;
59  void overwriteDefault(fpreal time, int index) override;
60  void overwriteDefaults(fpreal time) override;
61  int isDefault(int index, enum PRM_DefaultType deftype,
62  bool basiccheck = true) const override;
63  void save(std::ostream &os, int binary,
64  bool compiled) const override;
65  bool load(UT_IStream &is) override;
66 
67  void saveUndoData(PRM_UndoDataHandle &data) const override;
68  bool loadUndoData(const PRM_UndoDataHandle &data) override;
69 
70  void saveCommand(std::ostream &os, int values,
71  int index=-1) const override;
72  int loadCommand(int argc, const char *const argv[],
73  int index, bool values_only,
74  PRM_AddKeyType add_key,
75  PRM_KeySetType set_type) override;
76 
77  void getValue(PRM_ParmList *thelist, fpreal thetime,
78  int32 &theintref, int theindex,
79  int thread) const override;
80  void getValue(PRM_ParmList *thelist, fpreal thetime,
81  int64 &theintref, int theindex,
82  int thread) const override;
83  void getValue(PRM_ParmList *thelist, fpreal thetime,
84  fpreal &thefloatref, int theindex,
85  int thread) const override;
86  void getValue(PRM_ParmList *thelist, fpreal thetime,
87  UT_String &thestrref, int theindex,
88  bool expand, int thread) const override;
89  void getValue(PRM_ParmList *thelist, fpreal thetime,
90  PRM_DataItemHandle &thedataref, int theindex,
91  int thread) const override;
92  void getValue(PRM_ParmList *thelist, fpreal time,
93  UT_JSONValueMap &themap, int index,
94  bool expand, int thread) const override;
95 
96  // set value of a parameter
97  // setkey - determines how the value is set at keyframes. Whether the
98  // preference is used or always set as pending.
99  void setValue(fpreal time,
100  const char *value,
101  CH_StringMeaning meaning,
102  bool kill_expr = false,
103  int index = 0,
106  ) override;
107 
108  void setValue(fpreal time,
109  fpreal value,
110  bool kill_expr = false,
111  int index = 0,
114  ) override;
115 
116  void setValue(fpreal time,
117  int32 value,
118  bool kill_expr = false,
119  int index = 0,
122  ) override;
123 
124  void setValue(fpreal time,
125  int64 value,
126  bool kill_expr = false,
127  int index = 0,
130  ) override;
131 
132  void setValue(fpreal time,
133  const PRM_DataItemHandle &value,
134  bool kill_expr = false,
135  const int index = 0,
138  ) override;
139 
140  void getExpressionStringForUI(fpreal thetime,
141  UT_String &thestrref,
142  int theindex,
143  int thread) const override;
144  void getExpression(fpreal thetime, UT_String &expr,
145  int theindex, bool allow_value,
146  int thread) const override;
147  void setExpression(fpreal time,
148  const char *expr,
149  CH_ExprLanguage language,
150  int index, bool evaluate = true,
151  bool rmchannel = false) override;
152  void setDefaultChannelValue(CH_Channel *channelptr,
153  int theindex = 0) override;
154  bool getMagicString(UT_TokenString &magic,
155  PRM_ParmList *list, int size,
156  fpreal t, bool add_if_default /*=true*/,
157  int thread) override;
158  //
159  // adds a keyframe if a change is pending
160  //
161  void hardenChanges(fpreal thetime,
162  int theindex,
163  bool theforceflag,
164  const char *patt = 0,
165  CH_ChannelRefList *list = 0) override;
166 
167  int64 getMemoryUsage(bool inclusive) const override;
168 
169  bool setData(const PRM_DataItemHandle &b, fpreal time, int index);
170  PRM_DataItemHandle getData(fpreal time, int index) const;
171 
172 private:
173  void revertToDefaultWithoutRemovingChannel(
174  fpreal time, int index);
175  bool isChannelToken(const UT_String &token, int vi) const;
176 
177  /// @{
178  /// Helper methods for returning key-value dictionary (JSON map) values.
179  void expandJSONMap(
180  PRM_ParmList *thelist, fpreal time, int index,
181  int thread, const UT_JSONValueMap &src_map,
182  UT_JSONValueMap &expanded_map)
183  const;
184  bool expandJSONString(
185  CH_Manager *cman, CH_Collection *collection,
186  const PRM_ParmList *thelist, fpreal time,
187  int index, int thread, const char *str,
188  UT_String &expanded_str,
189  bool &is_time_dependent) const;
190  void copyJSONMap(
191  const UT_JSONValueMap &src_map,
192  UT_JSONValueMap &dest_map) const;
193 
194  mutable PRM_SpinLock myLock;
196 };
197 
198 #endif
virtual void setValueToDefault(fpreal time, int index, PRM_AddKeyType add_key)=0
PRM_AddKeyType
Definition: PRM_Parm.h:58
virtual void overwriteDefault(fpreal time, int index)=0
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
int int32
Definition: SYS_Types.h:39
virtual void setDefaultChannelValue(CH_Channel *channelptr, int index=0)=0
CH_ExprLanguage
CH_StringMeaning
GT_API const UT_StringHolder time
UT_SharedPtr< PRM_UndoData > PRM_UndoDataHandle
Definition: PRM_Parm.h:128
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
virtual void getExpression(fpreal time, UT_String &value, int index, bool allow_value, int thread) const =0
PRM_DefaultType
Definition: PRM_Default.h:19
PRM_KeySetType
virtual void setExpression(fpreal time, const char *value, CH_ExprLanguage language, int index, bool evaluate=true, bool rmchannel=false)
virtual void saveUndoData(PRM_UndoDataHandle &data) const
virtual void getValue(PRM_ParmList *parm_list, fpreal time, int32 &value, int index, int thread) const =0
virtual PRM_Instance * duplicateSelf(PRM_Parm *node)=0
virtual bool getMagicString(UT_TokenString &magic, PRM_ParmList *list, int size, fpreal t, bool add_if_default, int thread)=0
tbb::spin_rw_mutex PRM_SpinLock
Definition: PRM_Lock.h:22
virtual void saveCommand(std::ostream &os, int values=0, int index=-1) const =0
virtual void overwriteDefaults(fpreal time)=0
long long int64
Definition: SYS_Types.h:116
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
virtual bool load(UT_IStream &is)=0
virtual void hardenChanges(fpreal time, int index, bool theforceflag, const char *patt=0, CH_ChannelRefList *list=0)=0
GLdouble t
Definition: glad.h:2397
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
virtual bool loadUndoData(const PRM_UndoDataHandle &data)
virtual int loadCommand(int argc, const char *const argv[], int index, bool values_only, PRM_AddKeyType add_key, PRM_KeySetType set_type)=0
virtual int isDefault(int index, enum PRM_DefaultType deftype, bool basiccheck=true) const
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
virtual void revertToDefault(int index)=0
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint index
Definition: glcorearb.h:786
virtual int64 getMemoryUsage(bool inclusive) const
Definition: core.h:1131
virtual void getExpressionStringForUI(fpreal time, UT_String &value, int index, int thread) const =0
virtual void revertToDefaults(bool clear_channels=true)=0
#define PRM_API
Definition: PRM_API.h:10
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: PRM_Parm.h:97
Definition: format.h:895
virtual void restoreFactoryDefault(int index)=0
virtual void adopt(PRM_Instance &thesrcinstance)
virtual void setValue(fpreal time, const char *value, CH_StringMeaning meaning, bool kill_expr=false, int index=0, PRM_AddKeyType add_key=PRM_AK_MARK_PENDING, PRM_KeySetType setkey=PRM_USE_PREFERENCES)
virtual void save(std::ostream &os, int binary, bool compiled) const =0