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  virtual ~PRM_Data();
51  virtual void adopt(PRM_Instance &thesrc);
52  virtual PRM_Instance *duplicateSelf(PRM_Parm *parm);
53 
54  virtual void setValueToDefault(fpreal time, int index,
55  PRM_AddKeyType add_key);
56  virtual void revertToDefault(int index);
57  virtual void revertToDefaults(bool clear_channels = true);
58  virtual void restoreFactoryDefault(int index);
59  virtual void overwriteDefault(fpreal time, int index);
60  virtual void overwriteDefaults(fpreal time);
61  virtual int isDefault(int index, enum PRM_DefaultType deftype,
62  bool basiccheck = true) const;
63  virtual void save(std::ostream &os, int binary, bool compiled) const;
64  virtual bool load(UT_IStream &is);
65 
66  virtual void saveUndoData(PRM_UndoDataHandle &data) const;
67  virtual bool loadUndoData(const PRM_UndoDataHandle &data);
68 
69  virtual void saveCommand(std::ostream &os, int values,
70  int index=-1) const;
71  virtual int loadCommand(int argc, const char *const argv[],
72  int index, bool values_only,
73  PRM_AddKeyType add_key,
74  PRM_KeySetType set_type);
75 
76  virtual void getValue(PRM_ParmList *thelist, fpreal thetime,
77  int32 &theintref, int theindex,
78  int thread) const;
79  virtual void getValue(PRM_ParmList *thelist, fpreal thetime,
80  int64 &theintref, int theindex,
81  int thread) const;
82  virtual void getValue(PRM_ParmList *thelist, fpreal thetime,
83  fpreal &thefloatref, int theindex,
84  int thread) const;
85  virtual void getValue(PRM_ParmList *thelist, fpreal thetime,
86  UT_String &thestrref, int theindex,
87  bool expand, int thread) const;
88  virtual void getValue(PRM_ParmList *thelist, fpreal thetime,
89  PRM_DataItemHandle &thedataref, int theindex,
90  int thread) const;
91  virtual void getValue(PRM_ParmList *thelist, fpreal time,
92  UT_JSONValueMap &themap, int index,
93  bool expand, int thread) const;
94 
95  // set value of a parameter
96  // setkey - determines how the value is set at keyframes. Whether the
97  // preference is used or always set as pending.
98  virtual void setValue(fpreal time,
99  const char *value,
100  CH_StringMeaning meaning,
101  bool kill_expr = false,
102  int index = 0,
105 
106  virtual void setValue(fpreal time,
107  fpreal value,
108  bool kill_expr = false,
109  int index = 0,
112 
113  virtual void setValue(fpreal time,
114  int32 value,
115  bool kill_expr = false,
116  int index = 0,
119 
120  virtual void setValue(fpreal time,
121  int64 value,
122  bool kill_expr = false,
123  int index = 0,
126 
127  virtual void setValue(fpreal time,
128  const PRM_DataItemHandle &value,
129  bool kill_expr = false,
130  const int index = 0,
133 
134  virtual void getExpressionStringForUI(fpreal thetime,
135  UT_String &thestrref,
136  int theindex,
137  int thread) const;
138  virtual void getExpression(fpreal thetime, UT_String &expr,
139  int theindex, bool allow_value,
140  int thread) const;
141  virtual void setExpression(fpreal time,
142  const char *expr,
143  CH_ExprLanguage language,
144  int index, bool evaluate = true,
145  bool rmchannel = false);
146  virtual void setDefaultChannelValue(CH_Channel *channelptr,
147  int theindex = 0);
148  virtual bool getMagicString(UT_TokenString &magic,
149  PRM_ParmList *list, int size,
150  fpreal t, bool add_if_default /*=true*/,
151  int thread);
152  //
153  // adds a keyframe if a change is pending
154  //
155  virtual void hardenChanges(fpreal thetime,
156  int theindex,
157  bool theforceflag,
158  const char *patt = 0,
159  CH_ChannelRefList *list = 0);
160 
161  virtual int64 getMemoryUsage(bool inclusive) const;
162 
163  bool setData(const PRM_DataItemHandle &b, fpreal time, int index);
164  PRM_DataItemHandle getData(fpreal time, int index) const;
165 
166 private:
167  void revertToDefaultWithoutRemovingChannel(
168  fpreal time, int index);
169 
170  /// @{
171  /// Helper methods for returning key-value dictionary (JSON map) values.
172  void expandJSONMap(
173  PRM_ParmList *thelist, fpreal time, int index,
174  int thread, const UT_JSONValueMap &src_map,
175  UT_JSONValueMap &expanded_map)
176  const;
177  bool expandJSONString(
178  CH_Manager *cman, CH_Collection *collection,
179  const PRM_ParmList *thelist, fpreal time,
180  int index, int thread, const char *str,
181  UT_String &expanded_str,
182  bool &is_time_dependent) const;
183  void copyJSONMap(
184  const UT_JSONValueMap &src_map,
185  UT_JSONValueMap &dest_map) const;
186 
187  mutable PRM_SpinLock myLock;
189 };
190 
191 #endif
virtual void setValueToDefault(fpreal time, int index, PRM_AddKeyType add_key)=0
PRM_AddKeyType
Definition: PRM_Parm.h:57
virtual void overwriteDefault(fpreal time, int index)=0
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
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:113
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
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
GLsizeiptr size
Definition: glcorearb.h:663
virtual bool getMagicString(UT_TokenString &magic, PRM_ParmList *list, int size, fpreal t, bool add_if_default, int thread)=0
long long int64
Definition: SYS_Types.h:107
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
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1601
GLboolean * data
Definition: glcorearb.h:130
int int32
Definition: SYS_Types.h:35
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
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
virtual bool loadUndoData(const PRM_UndoDataHandle &data)
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double fpreal
Definition: SYS_Types.h:270
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
virtual void revertToDefault(int index)=0
GLuint index
Definition: glcorearb.h:785
virtual int64 getMemoryUsage(bool inclusive) const
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:88
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