HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_Stash.proto.h
Go to the documentation of this file.
1 /* Automagically Generated by generate_proto.py
2  * Do not Edit
3  */
4 #pragma once
5 
6 #include <SOP/SOP_API.h>
7 #include <SOP/SOP_NodeVerb.h>
8 #include <SOP/SOP_GraphProxy.h>
9 
10 #include <OP/OP_Utils.h>
11 #include <PRM/PRM_Parm.h>
12 #include <UT/UT_IStream.h>
13 #include <UT/UT_NTStreamUtil.h>
14 #include <UT/UT_Ramp.h>
15 #include <UT/UT_SharedPtr.h>
16 #include <UT/UT_StringHolder.h>
17 #include <UT/UT_StringStream.h>
18 #include <UT/UT_VectorTypes.h>
19 #include <UT/UT_EnvControl.h>
20 #include <SYS/SYS_Types.h>
21 
22 class DEP_MicroNode;
23 
25 {
26 public:
27  static int version() { return 1; }
28 
30  {
31  myStash = PRM_DataItemHandle(0);
32  myStashFile = ""_UTsh;
33  raw_myStashFile = ""_UTsh;
34 
35  }
36 
37  explicit SOP_StashParms(const SOP_StashParms &) = default;
38  SOP_StashParms &operator=(const SOP_StashParms &) = default;
39  SOP_StashParms(SOP_StashParms &&) noexcept = default;
40  SOP_StashParms &operator=(SOP_StashParms &&) noexcept = default;
41 
42  ~SOP_StashParms() override {}
43 
44  bool operator==(const SOP_StashParms &src) const
45  {
46  if (myStash != src.myStash)
47  { /* no == on PRM_DataItem */ return false; }
48  if (myStashFile != src.myStashFile) return false;
49  if (raw_myStashFile != src.raw_myStashFile) return false;
50 
51  return true;
52  }
53  bool operator!=(const SOP_StashParms &src) const
54  {
55  return !operator==(src);
56  }
57 
58 
59 
60  void buildFromOp(const OP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
61  {
62  myStash = PRM_DataItemHandle(0);
63  if (true)
64  graph->evalOpParm(myStash, nodeidx, "stash", time, 0);
65  myStashFile = ""_UTsh;
66  if (true)
67  graph->evalOpParm(myStashFile, nodeidx, "stashfile", time, 0);
68  raw_myStashFile = ""_UTsh;
69  if (true)
70  graph->evalOpParmRaw(raw_myStashFile, nodeidx, "stashfile", time, 0);
71 
72  }
73 
74 
75  void loadFromOpSubclass(const LoadParms &loadparms) override
76  {
77  buildFromOp(loadparms.graph(), loadparms.nodeIdx(), loadparms.context().getTime(), loadparms.depnode());
78  }
79 
80 
81  void copyFrom(const OP_NodeParms *src) override
82  {
83  *this = *((const SOP_StashParms *)src);
84  }
85 
86  template <typename T>
87  void
88  doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
89  {
90  if (idx.size() < 1)
91  return;
92  UT_ASSERT(idx.size() == instance.size()+1);
93  if (idx.size() != instance.size()+1)
94  return;
95  switch (idx[0])
96  {
97  case 0:
98  coerceValue(value, myStash);
99  break;
100  case 1:
101  coerceValue(value, myStashFile);
102  break;
103 
104  }
105  }
106 
107  bool isParmColorRamp(exint idx) const override
108  {
109  switch (idx)
110  {
111 
112  }
113  return false;
114  }
115 
116  void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
117  { doGetParmValue(idx, instance, value); }
118  void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
119  { doGetParmValue(idx, instance, value); }
120  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
121  { doGetParmValue(idx, instance, value); }
122  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
123  { doGetParmValue(idx, instance, value); }
124  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
125  { doGetParmValue(idx, instance, value); }
126  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
127  { doGetParmValue(idx, instance, value); }
128  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
129  { doGetParmValue(idx, instance, value); }
130  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
131  { doGetParmValue(idx, instance, value); }
132  void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
133  { doGetParmValue(idx, instance, value); }
134  void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr<UT_Ramp> &value) const override
135  { doGetParmValue(idx, instance, value); }
136  void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
137  { doGetParmValue(idx, instance, value); }
138 
139  template <typename T>
140  void
141  doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
142  {
143  if (idx.size() < 1)
144  return;
145  UT_ASSERT(idx.size() == instance.size()+1);
146  if (idx.size() != instance.size()+1)
147  return;
148  switch (idx[0])
149  {
150  case 0:
151  coerceValue(myStash, ( ( value ) ));
152  break;
153  case 1:
154  coerceValue(myStashFile, ( ( value ) ));
155  break;
156 
157  }
158  }
159 
160  void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
161  { doSetParmValue(idx, instance, value); }
162  void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
163  { doSetParmValue(idx, instance, value); }
164  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
165  { doSetParmValue(idx, instance, value); }
166  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
167  { doSetParmValue(idx, instance, value); }
168  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
169  { doSetParmValue(idx, instance, value); }
170  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
171  { doSetParmValue(idx, instance, value); }
172  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
173  { doSetParmValue(idx, instance, value); }
174  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
175  { doSetParmValue(idx, instance, value); }
176  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
177  { doSetParmValue(idx, instance, value); }
178  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr<UT_Ramp> &value) override
179  { doSetParmValue(idx, instance, value); }
180  void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
181  { doSetParmValue(idx, instance, value); }
182 
183  exint getNestNumParms(TempIndex idx) const override
184  {
185  if (idx.size() == 0)
186  return 2;
187  switch (idx[0])
188  {
189 
190  }
191  // Invalid
192  return 0;
193  }
194 
195  const char *getNestParmName(TempIndex fieldnum) const override
196  {
197  if (fieldnum.size() < 1)
198  return 0;
199  switch (fieldnum[0])
200  {
201  case 0:
202  return "stash";
203  case 1:
204  return "stashfile";
205 
206  }
207  return 0;
208  }
209 
210  ParmType getNestParmType(TempIndex fieldnum) const override
211  {
212  if (fieldnum.size() < 1)
213  return PARM_UNSUPPORTED;
214  switch (fieldnum[0])
215  {
216  case 0:
217  return PARM_DATA;
218  case 1:
219  return PARM_STRING;
220 
221  }
222  return PARM_UNSUPPORTED;
223  }
224 
225  // Boiler plate to load individual types.
226  static void loadData(UT_IStream &is, int64 &v)
227  { is.bread(&v, 1); }
228  static void loadData(UT_IStream &is, bool &v)
229  { int64 iv; is.bread(&iv, 1); v = iv; }
230  static void loadData(UT_IStream &is, fpreal64 &v)
231  { is.bread<fpreal64>(&v, 1); }
232  static void loadData(UT_IStream &is, UT_Vector2D &v)
233  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
234  static void loadData(UT_IStream &is, UT_Vector3D &v)
235  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
236  is.bread<fpreal64>(&v.z(), 1); }
237  static void loadData(UT_IStream &is, UT_Vector4D &v)
238  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
239  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
240  static void loadData(UT_IStream &is, UT_Matrix2D &v)
241  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
242  static void loadData(UT_IStream &is, UT_Matrix3D &v)
243  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
244  static void loadData(UT_IStream &is, UT_Matrix4D &v)
245  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
246  static void loadData(UT_IStream &is, UT_Vector2I &v)
247  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
248  static void loadData(UT_IStream &is, UT_Vector3I &v)
249  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
250  is.bread<int64>(&v.z(), 1); }
251  static void loadData(UT_IStream &is, UT_Vector4I &v)
252  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
253  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
255  { is.bread(v); }
257  { UT_StringHolder rampdata;
258  loadData(is, rampdata);
259  if (rampdata.isstring())
260  {
261  v.reset(new UT_Ramp());
262  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
263  v->load(istr);
264  }
265  else v.reset();
266  }
269  loadData(is, data);
270  if (data.isstring())
271  {
272  // Find the data type.
273  const char *colon = UT_StringWrap(data).findChar(':');
274  if (colon)
275  {
276  int typelen = colon - data.buffer();
278  type.strncpy(data.buffer(), typelen);
279  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
280 
281  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
282  }
283  }
284  else v.reset();
285  }
286 
287  static void saveData(std::ostream &os, int64 v)
288  { UTwrite(os, &v); }
289  static void saveData(std::ostream &os, bool v)
290  { int64 iv = v; UTwrite(os, &iv); }
291  static void saveData(std::ostream &os, fpreal64 v)
292  { UTwrite<fpreal64>(os, &v); }
293  static void saveData(std::ostream &os, UT_Vector2D v)
294  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
295  static void saveData(std::ostream &os, UT_Vector3D v)
296  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
297  UTwrite<fpreal64>(os, &v.z()); }
298  static void saveData(std::ostream &os, UT_Vector4D v)
299  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
300  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
301  static void saveData(std::ostream &os, UT_Matrix2D v)
303  static void saveData(std::ostream &os, UT_Matrix3D v)
305  static void saveData(std::ostream &os, UT_Matrix4D v)
307  static void saveData(std::ostream &os, UT_StringHolder s)
308  { UT_StringWrap(s).saveBinary(os); }
309  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
311  UT_OStringStream ostr;
312  if (s) s->save(ostr);
313  result = ostr.str();
314  saveData(os, result);
315  }
316  static void saveData(std::ostream &os, PRM_DataItemHandle s)
318  UT_OStringStream ostr;
319  if (s)
320  {
321  ostr << s->getDataTypeToken();
322  ostr << ":";
323  s->saveBinary(ostr);
324  }
325  result = ostr.str();
326  saveData(os, result);
327  }
328 
329 
330  void save(std::ostream &os) const
331  {
332  int32 v = version();
333  UTwrite(os, &v);
334  saveData(os, myStash);
335  saveData(os, myStashFile);
336  saveData(os, raw_myStashFile);
337 
338  }
339 
340  bool load(UT_IStream &is)
341  {
342  int32 v;
343  is.bread(&v, 1);
344  if (version() != v)
345  {
346  // Fail incompatible versions
347  return false;
348  }
349  loadData(is, myStash);
350  loadData(is, myStashFile);
351  loadData(is, raw_myStashFile);
352 
353  return true;
354  }
355 
356  PRM_DataItemHandle getStash() const { return myStash; }
357  void setStash(PRM_DataItemHandle val) { myStash = val; }
359  {
360  SOP_Node *thissop = cookparms.getNode();
361  if (!thissop) return getStash();
363  OP_Utils::evalOpParm(result, thissop, "stash", cookparms.getCookTime(), 0);
364  return result;
365  }
366  const UT_StringHolder & getStashFile() const { return myStashFile; }
367  void setStashFile(const UT_StringHolder & val) { myStashFile = val; }
369  {
370  SOP_Node *thissop = cookparms.getNode();
371  if (!thissop) return getStashFile();
373  OP_Utils::evalOpParm(result, thissop, "stashfile", cookparms.getCookTime(), 0);
374  return result;
375  }
376  const UT_StringHolder & raw_getStashFile() const { return raw_myStashFile; }
377  void raw_setStashFile(const UT_StringHolder & val) { raw_myStashFile = val; }
379  {
380  SOP_Node *thissop = cookparms.getNode();
381  if (!thissop) return raw_getStashFile();
383  OP_Utils::evalOpParmRaw(result, thissop, "stashfile", cookparms.getCookTime(), 0);
384  return result;
385  }
386 
387 private:
388  PRM_DataItemHandle myStash;
389  UT_StringHolder myStashFile;
390  UT_StringHolder raw_myStashFile;
391 
392 };
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
static void saveData(std::ostream &os, int64 v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
static void loadData(UT_IStream &is, UT_Vector4I &v)
static void loadData(UT_IStream &is, fpreal64 &v)
static void saveData(std::ostream &os, fpreal64 v)
static void saveData(std::ostream &os, UT_Matrix4D v)
int int32
Definition: SYS_Types.h:39
SOP_Node * getNode() const
Definition: SOP_NodeVerb.h:347
static void saveData(std::ostream &os, UT_Vector2D v)
static void loadData(UT_IStream &is, UT_Vector2I &v)
exint bread(int32 *buffer, exint asize=1)
GLboolean * data
Definition: glcorearb.h:131
GT_API const UT_StringHolder time
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector4.h:493
UT_StringHolder raw_opStashFile(const SOP_NodeVerb::CookParms &cookparms) const
const GLdouble * v
Definition: glcorearb.h:837
const char * getNestParmName(TempIndex fieldnum) const override
fpreal getTime() const
Definition: OP_Context.h:62
bool operator!=(const SOP_StashParms &src) const
PRM_DataItemHandle getStash() const
const OP_Context & context() const
Definition: OP_NodeParms.h:97
virtual void evalOpParmRaw(UT_StringHolder &v, NodeIdx node, const char *parmname, fpreal time, DEP_MicroNode *depnode) const =0
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector3.h:667
int64 exint
Definition: SYS_Types.h:125
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
SYS_FORCE_INLINE const char * buffer() const
GLdouble s
Definition: glad.h:3009
void setStashFile(const UT_StringHolder &val)
An output stream object that owns its own string buffer storage.
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
void loadFromOpSubclass(const LoadParms &loadparms) override
void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr< UT_Ramp > &value) override
static void saveData(std::ostream &os, UT_Vector4D v)
**But if you need a result
Definition: thread.h:613
static void loadData(UT_IStream &is, int64 &v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
exint nodeIdx() const
Definition: OP_NodeParms.h:95
static PRM_DataItemHandle parseBinary(const char *type, UT_IStream &is)
const UT_WorkBuffer & str()
Returns a read-only reference to the underlying UT_WorkBuffer.
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector4.h:491
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
const UT_StringHolder & raw_getStashFile() const
void buildFromOp(const OP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
void save(std::ostream &os) const
double fpreal64
Definition: SYS_Types.h:201
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector2.h:423
exint getNestNumParms(TempIndex idx) const override
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
static void loadData(UT_IStream &is, UT_Vector3D &v)
static void saveData(std::ostream &os, UT_Matrix3D v)
PRM_DataItemHandle opStash(const SOP_NodeVerb::CookParms &cookparms) const
bool operator==(const SOP_StashParms &src) const
static void saveData(std::ostream &os, bool v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
exint length() const
SYS_FORCE_INLINE const char * buffer() const
static void loadData(UT_IStream &is, PRM_DataItemHandle &v)
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector4.h:495
void raw_setStashFile(const UT_StringHolder &val)
void doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
const OP_GraphProxy * graph() const
Definition: OP_NodeParms.h:94
static void loadData(UT_IStream &is, UT_Vector2D &v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
static void saveData(std::ostream &os, PRM_DataItemHandle s)
bool isParmColorRamp(exint idx) const override
long long int64
Definition: SYS_Types.h:116
void copyFrom(const OP_NodeParms *src) override
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
static void saveData(std::ostream &os, UT_Vector3D v)
void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
static void loadData(UT_IStream &is, UT_Matrix2D &v)
virtual void evalOpParm(int64 &v, NodeIdx node, const char *parmname, fpreal time, DEP_MicroNode *depnode) const =0
void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr< UT_Ramp > &value) const override
void saveBinary(std::ostream &os) const
Save string to binary stream.
Definition: UT_String.h:296
GT_API const UT_StringHolder version
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
ParmType getNestParmType(TempIndex fieldnum) const override
void coerceValue(T &result, const S &src) const
Definition: OP_NodeParms.h:301
void setStash(PRM_DataItemHandle val)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
fpreal64 fpreal
Definition: SYS_Types.h:277
static void loadData(UT_IStream &is, UT_Vector4D &v)
DEP_MicroNode * depnode() const
Definition: OP_NodeParms.h:99
static void loadData(UT_IStream &is, bool &v)
Utility class for containing a color ramp.
Definition: UT_Ramp.h:92
constexpr SYS_FORCE_INLINE T & w() noexcept
Definition: UT_Vector4.h:497
GLuint GLfloat * val
Definition: glcorearb.h:1608
static void loadData(UT_IStream &is, UT_Vector3I &v)
#define SOP_API
Definition: SOP_API.h:10
static void loadData(UT_IStream &is, UT_Matrix4D &v)
static void loadData(UT_IStream &is, UT_StringHolder &v)
fpreal getCookTime() const
Definition: SOP_NodeVerb.h:361
const char * findChar(int c) const
Definition: UT_String.h:1395
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
Definition: core.h:1131
static int version()
GLboolean r
Definition: glcorearb.h:1222
void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
static void saveData(std::ostream &os, UT_StringHolder s)
void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector3.h:665
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &v)
static void loadData(UT_IStream &is, UT_Matrix3D &v)
UT_StringHolder opStashFile(const SOP_NodeVerb::CookParms &cookparms) const
void doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
type
Definition: core.h:1059
const UT_StringHolder & getStashFile() const
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: PRM_Parm.h:97
bool load(UT_IStream &is)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector2.h:425
SYS_FORCE_INLINE bool isstring() const
OP_NodeParms & operator=(const OP_NodeParms &)=default
SYS_FORCE_INLINE void strncpy(const char *src, exint maxlen)
static void saveData(std::ostream &os, UT_Matrix2D v)
GLenum src
Definition: glcorearb.h:1793
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector3.h:663