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 using namespace UT::Literal;
23 
24 class DEP_MicroNode;
25 
27 {
28 public:
29  static int version() { return 1; }
30 
32  {
33  myStash = PRM_DataItemHandle(0);
34  myStashFile = ""_sh;
35  raw_myStashFile = ""_sh;
36 
37  }
38 
39  explicit SOP_StashParms(const SOP_StashParms &) = default;
40 
41  ~SOP_StashParms() override {}
42 
43  bool operator==(const SOP_StashParms &src) const
44  {
45  if (myStash != src.myStash)
46  { /* no == on PRM_DataItem */ return false; }
47  if (myStashFile != src.myStashFile) return false;
48  if (raw_myStashFile != src.raw_myStashFile) return false;
49 
50  return true;
51  }
52  bool operator!=(const SOP_StashParms &src) const
53  {
54  return !operator==(src);
55  }
56 
57 
58 
59  void buildFromOp(const SOP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
60  {
61  myStash = PRM_DataItemHandle(0);
62  if (true)
63  graph->evalOpParm(myStash, nodeidx, "stash", time, 0);
64  myStashFile = ""_sh;
65  if (true)
66  graph->evalOpParm(myStashFile, nodeidx, "stashfile", time, 0);
67  raw_myStashFile = ""_sh;
68  if (true)
69  graph->evalOpParmRaw(raw_myStashFile, nodeidx, "stashfile", time, 0);
70 
71  }
72 
73 
74  void loadFromOpSubclass(const LoadParms &loadparms) override
75  {
76  buildFromOp(loadparms.graph(), loadparms.nodeIdx(), loadparms.context().getTime(), loadparms.depnode());
77  }
78 
79 
80  void copyFrom(const SOP_NodeParms *src) override
81  {
82  *this = *((const SOP_StashParms *)src);
83  }
84 
85  template <typename T>
86  void
87  doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
88  {
89  if (idx.size() < 1)
90  return;
91  UT_ASSERT(idx.size() == instance.size()+1);
92  if (idx.size() != instance.size()+1)
93  return;
94  switch (idx[0])
95  {
96  case 0:
97  coerceValue(value, myStash);
98  break;
99  case 1:
100  coerceValue(value, myStashFile);
101  break;
102 
103  }
104  }
105 
106  void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
107  { doGetParmValue(idx, instance, value); }
108  void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
109  { doGetParmValue(idx, instance, value); }
110  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
111  { doGetParmValue(idx, instance, value); }
112  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
113  { doGetParmValue(idx, instance, value); }
114  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
115  { doGetParmValue(idx, instance, value); }
116  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
117  { doGetParmValue(idx, instance, value); }
118  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
119  { doGetParmValue(idx, instance, value); }
120  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
121  { doGetParmValue(idx, instance, value); }
122  void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
123  { doGetParmValue(idx, instance, value); }
124  void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr<UT_Ramp> &value) const override
125  { doGetParmValue(idx, instance, value); }
126  void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
127  { doGetParmValue(idx, instance, value); }
128 
129  template <typename T>
130  void
131  doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
132  {
133  if (idx.size() < 1)
134  return;
135  UT_ASSERT(idx.size() == instance.size()+1);
136  if (idx.size() != instance.size()+1)
137  return;
138  switch (idx[0])
139  {
140  case 0:
141  coerceValue(myStash, ( ( value ) ));
142  break;
143  case 1:
144  coerceValue(myStashFile, ( ( value ) ));
145  break;
146 
147  }
148  }
149 
150  void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
151  { doSetParmValue(idx, instance, value); }
152  void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
153  { doSetParmValue(idx, instance, value); }
154  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
155  { doSetParmValue(idx, instance, value); }
156  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
157  { doSetParmValue(idx, instance, value); }
158  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
159  { doSetParmValue(idx, instance, value); }
160  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
161  { doSetParmValue(idx, instance, value); }
162  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
163  { doSetParmValue(idx, instance, value); }
164  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
165  { doSetParmValue(idx, instance, value); }
166  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
167  { doSetParmValue(idx, instance, value); }
168  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr<UT_Ramp> &value) override
169  { doSetParmValue(idx, instance, value); }
170  void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
171  { doSetParmValue(idx, instance, value); }
172 
173  exint getNestNumParms(TempIndex idx) const override
174  {
175  if (idx.size() == 0)
176  return 2;
177  switch (idx[0])
178  {
179 
180  }
181  // Invalid
182  return 0;
183  }
184 
185  const char *getNestParmName(TempIndex fieldnum) const override
186  {
187  if (fieldnum.size() < 1)
188  return 0;
189  switch (fieldnum[0])
190  {
191  case 0:
192  return "stash";
193  case 1:
194  return "stashfile";
195 
196  }
197  return 0;
198  }
199 
200  ParmType getNestParmType(TempIndex fieldnum) const override
201  {
202  if (fieldnum.size() < 1)
203  return PARM_UNSUPPORTED;
204  switch (fieldnum[0])
205  {
206  case 0:
207  return PARM_DATA;
208  case 1:
209  return PARM_STRING;
210 
211  }
212  return PARM_UNSUPPORTED;
213  }
214 
215  // Boiler plate to load individual types.
216  static void loadData(UT_IStream &is, int64 &v)
217  { is.bread(&v, 1); }
218  static void loadData(UT_IStream &is, bool &v)
219  { int64 iv; is.bread(&iv, 1); v = iv; }
220  static void loadData(UT_IStream &is, fpreal64 &v)
221  { is.bread<fpreal64>(&v, 1); }
222  static void loadData(UT_IStream &is, UT_Vector2D &v)
223  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
224  static void loadData(UT_IStream &is, UT_Vector3D &v)
225  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
226  is.bread<fpreal64>(&v.z(), 1); }
227  static void loadData(UT_IStream &is, UT_Vector4D &v)
228  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
229  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
230  static void loadData(UT_IStream &is, UT_Matrix2D &v)
231  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
232  static void loadData(UT_IStream &is, UT_Matrix3D &v)
233  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
234  static void loadData(UT_IStream &is, UT_Matrix4D &v)
235  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
236  static void loadData(UT_IStream &is, UT_Vector2I &v)
237  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
238  static void loadData(UT_IStream &is, UT_Vector3I &v)
239  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
240  is.bread<int64>(&v.z(), 1); }
241  static void loadData(UT_IStream &is, UT_Vector4I &v)
242  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
243  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
245  { is.bread(v); }
247  { UT_StringHolder rampdata;
248  loadData(is, rampdata);
249  if (rampdata.isstring())
250  {
251  v.reset(new UT_Ramp());
252  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
253  v->load(istr);
254  }
255  else v.reset();
256  }
259  loadData(is, data);
260  if (data.isstring())
261  {
262  // Find the data type.
263  const char *colon = UT_StringWrap(data).findChar(':');
264  if (colon)
265  {
266  int typelen = colon - data.buffer();
268  type.strncpy(data.buffer(), typelen);
269  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
270 
271  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
272  }
273  }
274  else v.reset();
275  }
276 
277  static void saveData(std::ostream &os, int64 v)
278  { UTwrite(os, &v); }
279  static void saveData(std::ostream &os, bool v)
280  { int64 iv = v; UTwrite(os, &iv); }
281  static void saveData(std::ostream &os, fpreal64 v)
282  { UTwrite<fpreal64>(os, &v); }
283  static void saveData(std::ostream &os, UT_Vector2D v)
284  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
285  static void saveData(std::ostream &os, UT_Vector3D v)
286  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
287  UTwrite<fpreal64>(os, &v.z()); }
288  static void saveData(std::ostream &os, UT_Vector4D v)
289  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
290  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
291  static void saveData(std::ostream &os, UT_Matrix2D v)
293  static void saveData(std::ostream &os, UT_Matrix3D v)
295  static void saveData(std::ostream &os, UT_Matrix4D v)
297  static void saveData(std::ostream &os, UT_StringHolder s)
298  { UT_StringWrap(s).saveBinary(os); }
299  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
301  UT_OStringStream ostr;
302  if (s) s->save(ostr);
303  result = ostr.str();
304  saveData(os, result);
305  }
306  static void saveData(std::ostream &os, PRM_DataItemHandle s)
308  UT_OStringStream ostr;
309  if (s)
310  {
311  ostr << s->getDataTypeToken();
312  ostr << ":";
313  s->saveBinary(ostr);
314  }
315  result = ostr.str();
316  saveData(os, result);
317  }
318 
319 
320  void save(std::ostream &os) const
321  {
322  int32 v = version();
323  UTwrite(os, &v);
324  saveData(os, myStash);
325  saveData(os, myStashFile);
326  saveData(os, raw_myStashFile);
327 
328  }
329 
330  bool load(UT_IStream &is)
331  {
332  int32 v;
333  is.bread(&v, 1);
334  if (version() != v)
335  {
336  // Fail incompatible versions
337  return false;
338  }
339  loadData(is, myStash);
340  loadData(is, myStashFile);
341  loadData(is, raw_myStashFile);
342 
343  return true;
344  }
345 
346  PRM_DataItemHandle getStash() const { return myStash; }
347  void setStash(PRM_DataItemHandle val) { myStash = val; }
349  {
350  SOP_Node *thissop = cookparms.getNode();
351  if (!thissop) return getStash();
353  OP_Utils::evalOpParm(result, thissop, "stash", cookparms.getCookTime(), 0);
354  return result;
355  }
356  const UT_StringHolder & getStashFile() const { return myStashFile; }
357  void setStashFile(const UT_StringHolder & val) { myStashFile = val; }
359  {
360  SOP_Node *thissop = cookparms.getNode();
361  if (!thissop) return getStashFile();
363  OP_Utils::evalOpParm(result, thissop, "stashfile", cookparms.getCookTime(), 0);
364  return result;
365  }
366  const UT_StringHolder & raw_getStashFile() const { return raw_myStashFile; }
367  void raw_setStashFile(const UT_StringHolder & val) { raw_myStashFile = val; }
369  {
370  SOP_Node *thissop = cookparms.getNode();
371  if (!thissop) return raw_getStashFile();
373  OP_Utils::evalOpParmRaw(result, thissop, "stashfile", cookparms.getCookTime(), 0);
374  return result;
375  }
376 
377 private:
378  PRM_DataItemHandle myStash;
379  UT_StringHolder myStashFile;
380  UT_StringHolder raw_myStashFile;
381 
382 };
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)
exint nodeIdx() const
Definition: SOP_NodeVerb.h:102
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:734
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)
GT_API const UT_StringHolder time
UT_StringHolder raw_opStashFile(const SOP_NodeVerb::CookParms &cookparms) const
const char * getNestParmName(TempIndex fieldnum) const override
fpreal getTime() const
Definition: OP_Context.h:59
bool operator!=(const SOP_StashParms &src) const
PRM_DataItemHandle getStash() const
const GLfloat * c
Definition: glew.h:16631
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector3.h:656
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
const SOP_GraphProxy * graph() const
Definition: SOP_NodeVerb.h:101
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)
static void loadData(UT_IStream &is, int64 &v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
GLenum src
Definition: glcorearb.h:1793
static PRM_DataItemHandle parseBinary(const char *type, UT_IStream &is)
const UT_WorkBuffer & str()
Returns a read-only reference to the underlying UT_WorkBuffer.
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
const UT_StringHolder & raw_getStashFile() const
void save(std::ostream &os) const
double fpreal64
Definition: SYS_Types.h:201
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)
void copyFrom(const SOP_NodeParms *src) override
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
virtual void evalOpParmRaw(UT_StringHolder &v, NodeIdx node, const char *parmname, fpreal time, DEP_MicroNode *depnode) const =0
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
void raw_setStashFile(const UT_StringHolder &val)
void doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
const GLdouble * v
Definition: glcorearb.h:837
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)
long long int64
Definition: SYS_Types.h:116
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)
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:287
void buildFromOp(const SOP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
GT_API const UT_StringHolder version
DEP_MicroNode * depnode() const
Definition: SOP_NodeVerb.h:109
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
GLboolean * data
Definition: glcorearb.h:131
void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
GLuint GLfloat * val
Definition: glcorearb.h:1608
ParmType getNestParmType(TempIndex fieldnum) const override
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)
static void loadData(UT_IStream &is, bool &v)
Utility class for containing a color ramp.
Definition: UT_Ramp.h:84
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)
virtual void evalOpParm(int64 &v, NodeIdx node, const char *parmname, fpreal time, DEP_MicroNode *depnode) const =0
static void loadData(UT_IStream &is, UT_StringHolder &v)
fpreal getCookTime() const
Definition: SOP_NodeVerb.h:748
const char * findChar(int c) const
Definition: UT_String.h:1372
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:153
Definition: core.h:1131
static int version()
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
type
Definition: core.h:1059
GLboolean r
Definition: glcorearb.h:1222
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector3.h:654
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)
GLdouble s
Definition: glew.h:1395
const OP_Context & context() const
Definition: SOP_NodeVerb.h:107
const UT_StringHolder & getStashFile() const
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: PRM_Parm.h:89
~SOP_StashParms() override
bool load(UT_IStream &is)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
SYS_FORCE_INLINE bool isstring() const
SYS_FORCE_INLINE void strncpy(const char *src, exint maxlen)
static void saveData(std::ostream &os, UT_Matrix2D v)
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector3.h:652