HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SOP_AttribCastParms.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_NodeVerb.h>
7 #include <OP/OP_Utils.h>
8 #include <PRM/PRM_Parm.h>
9 #include <UT/UT_IStream.h>
10 #include <UT/UT_NTStreamUtil.h>
11 #include <UT/UT_Ramp.h>
12 #include <UT/UT_SharedPtr.h>
13 #include <UT/UT_StringHolder.h>
14 #include <UT/UT_StringStream.h>
15 #include <UT/UT_VectorTypes.h>
16 #include <SYS/SYS_Types.h>
17 
18 using namespace UT::Literal;
19 
20 class DEP_MicroNode;
21 
23 {
24 public:
25  static int version() { return 1; }
26  struct Casts
27  {
31 
32 
34  {
35  _class = "point"_sh;
36  attribs = ""_sh;
37  precision = "fpreal32"_sh;
38 
39  }
40 
41  bool operator==(const Casts &src) const
42  {
43  if (_class != src._class) return false;
44  if (attribs != src.attribs) return false;
45  if (precision != src.precision) return false;
46 
47  return true;
48  }
49 
50  };
51 
53  {
55 
56  buf.strcat("[ ");
57  for (int i = 0; i < list.entries(); i++)
58  {
59  if (i)
60  buf.strcat(", ");
61  buf.strcat("( ");
62  buf.append("");
63  { UT_String tmp; tmp = UT_StringWrap(list(i)._class).makeQuotedString('"'); buf.strcat(tmp); }
64  buf.append(", ");
65  { UT_String tmp; tmp = UT_StringWrap(list(i).attribs).makeQuotedString('"'); buf.strcat(tmp); }
66  buf.append(", ");
67  { UT_String tmp; tmp = UT_StringWrap(list(i).precision).makeQuotedString('"'); buf.strcat(tmp); }
68 
69  buf.strcat(" )");
70  }
71  buf.strcat(" ]");
72 
73  UT_StringHolder result = buf;
74  return result;
75  }
76 
78  {
79 
80  }
81 
82  explicit SOP_AttribCastParms(const SOP_AttribCastParms &) = default;
83 
84  virtual ~SOP_AttribCastParms() {}
85 
86  bool operator==(const SOP_AttribCastParms &src) const
87  {
88  if (myCasts != src.myCasts) return false;
89 
90  return true;
91  }
92 
93 
94 
95  void buildFromOp(const OP_Node *node, fpreal time, DEP_MicroNode *depnode)
96  {
97  if (true)
98  {
99  int64 length;
100  OP_Utils::evalOpParm(length, node, "numcasts", time, 0);
101  myCasts.entries(length);
102  for (exint i = 0; i < length; i++)
103  {
104  int parmidx = i+1;
105  auto && _curentry = myCasts(i);
106  (void) _curentry;
107  if (true)
108  OP_Utils::evalOpParmInst(myCasts(i)._class, node, "class#", &parmidx, time, 0);
109  else myCasts(i)._class = "point"_sh;
110  if (true)
111  OP_Utils::evalOpParmInst(myCasts(i).attribs, node, "attribs#", &parmidx, time, 0);
112  else myCasts(i).attribs = ""_sh;
113  if (true)
114  OP_Utils::evalOpParmInst(myCasts(i).precision, node, "precision#", &parmidx, time, 0);
115  else myCasts(i).precision = "fpreal32"_sh;
116 
117  }
118  }
119  else
120  myCasts.clear();
121 
122  }
123 
124 
125  virtual void loadFromOpSubclass(const LoadParms &loadparms)
126  {
127  buildFromOp(loadparms.node(), loadparms.context().getTime(), loadparms.depnode());
128  }
129 
130 
131  virtual void copyFrom(const SOP_NodeParms *src)
132  {
133  *this = *((const SOP_AttribCastParms *)src);
134  }
135 
136  template <typename T>
137  void
138  doGetParmValue(exint idx, T &value) const
139  {
140  switch (idx)
141  {
142 
143  }
144  }
145 
146  void getParmValue(exint idx, exint &value) const
147  { doGetParmValue(idx, value); }
148  void getParmValue(exint idx, fpreal &value) const
149  { doGetParmValue(idx, value); }
151  { doGetParmValue(idx, value); }
153  { doGetParmValue(idx, value); }
155  { doGetParmValue(idx, value); }
157  { doGetParmValue(idx, value); }
159  { doGetParmValue(idx, value); }
161  { doGetParmValue(idx, value); }
163  { doGetParmValue(idx, value); }
165  { doGetParmValue(idx, value); }
167  { doGetParmValue(idx, value); }
168 
169  template <typename T>
170  void
171  doSetParmValue(exint idx, const T &value)
172  {
173  switch (idx)
174  {
175 
176  }
177  }
178 
179  void setParmValue(exint idx, const exint &value)
180  { doSetParmValue(idx, value); }
181  void setParmValue(exint idx, const fpreal &value)
182  { doSetParmValue(idx, value); }
183  void setParmValue(exint idx, const UT_Vector2D &value)
184  { doSetParmValue(idx, value); }
185  void setParmValue(exint idx, const UT_Vector3D &value)
186  { doSetParmValue(idx, value); }
187  void setParmValue(exint idx, const UT_Vector4D &value)
188  { doSetParmValue(idx, value); }
189  void setParmValue(exint idx, const UT_Matrix2D &value)
190  { doSetParmValue(idx, value); }
191  void setParmValue(exint idx, const UT_Matrix3D &value)
192  { doSetParmValue(idx, value); }
193  void setParmValue(exint idx, const UT_Matrix4D &value)
194  { doSetParmValue(idx, value); }
196  { doSetParmValue(idx, value); }
198  { doSetParmValue(idx, value); }
200  { doSetParmValue(idx, value); }
201 
202  virtual exint getNumParms() const
203  {
204  return 1;
205  }
206 
207  virtual const char *getParmName(exint fieldnum) const
208  {
209  switch (fieldnum)
210  {
211  case 0:
212  return "numcasts";
213 
214  }
215  return 0;
216  }
217 
218  virtual ParmType getParmType(exint fieldnum) const
219  {
220  switch (fieldnum)
221  {
222 
223  }
224  return PARM_UNSUPPORTED;
225  }
226 
227  // Boiler plate to load individual types.
228  static void loadData(UT_IStream &is, int64 &v)
229  { is.bread(&v, 1); }
230  static void loadData(UT_IStream &is, bool &v)
231  { int64 iv; is.bread(&iv, 1); v = iv; }
232  static void loadData(UT_IStream &is, fpreal64 &v)
233  { is.bread<fpreal64>(&v, 1); }
234  static void loadData(UT_IStream &is, UT_Vector2D &v)
235  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
236  static void loadData(UT_IStream &is, UT_Vector3D &v)
237  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
238  is.bread<fpreal64>(&v.z(), 1); }
239  static void loadData(UT_IStream &is, UT_Vector4D &v)
240  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
241  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
242  static void loadData(UT_IStream &is, UT_Matrix2D &v)
243  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
244  static void loadData(UT_IStream &is, UT_Matrix3D &v)
245  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
246  static void loadData(UT_IStream &is, UT_Matrix4D &v)
247  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
248  static void loadData(UT_IStream &is, UT_Vector2I &v)
249  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
250  static void loadData(UT_IStream &is, UT_Vector3I &v)
251  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
252  is.bread<int64>(&v.z(), 1); }
253  static void loadData(UT_IStream &is, UT_Vector4I &v)
254  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
255  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
257  { is.bread(v); }
259  { UT_StringHolder rampdata;
260  loadData(is, rampdata);
261  if (rampdata.isstring())
262  {
263  v.reset(new UT_Ramp());
264  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
265  v->load(istr);
266  }
267  else v.reset();
268  }
271  loadData(is, data);
272  if (data.isstring())
273  {
274  // Find the data type.
275  char *colon = UT_StringWrap(data).findChar(':');
276  if (colon)
277  {
278  int typelen = colon - data.buffer();
280  type.strncpy(data.buffer(), typelen);
281  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
282 
283  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
284  }
285  }
286  else v.reset();
287  }
288 
289  static void saveData(std::ostream &os, int64 v)
290  { UTwrite(os, &v); }
291  static void saveData(std::ostream &os, bool v)
292  { int64 iv = v; UTwrite(os, &iv); }
293  static void saveData(std::ostream &os, fpreal64 v)
294  { UTwrite<fpreal64>(os, &v); }
295  static void saveData(std::ostream &os, UT_Vector2D v)
296  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
297  static void saveData(std::ostream &os, UT_Vector3D v)
298  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
299  UTwrite<fpreal64>(os, &v.z()); }
300  static void saveData(std::ostream &os, UT_Vector4D v)
301  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
302  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
303  static void saveData(std::ostream &os, UT_Matrix2D v)
305  static void saveData(std::ostream &os, UT_Matrix3D v)
307  static void saveData(std::ostream &os, UT_Matrix4D v)
309  static void saveData(std::ostream &os, UT_StringHolder s)
310  { UT_StringWrap(s).saveBinary(os); }
311  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
312  { UT_StringHolder result;
313  UT_OStringStream ostr;
314  if (s) s->save(ostr);
315  result = ostr.str();
316  saveData(os, result);
317  }
318  static void saveData(std::ostream &os, PRM_DataItemHandle s)
319  { UT_StringHolder result;
320  UT_OStringStream ostr;
321  if (s)
322  {
323  ostr << s->getDataTypeToken();
324  ostr << ":";
325  s->saveBinary(ostr);
326  }
327  result = ostr.str();
328  saveData(os, result);
329  }
330 
331 
332  void save(std::ostream &os) const
333  {
334  int32 v = version();
335  UTwrite(os, &v);
336  {
337  int64 length = myCasts.entries();
338  UTwrite(os, &length);
339  for (exint i = 0; i < length; i++)
340  {
341  saveData(os, myCasts(i)._class);
342  saveData(os, myCasts(i).attribs);
343  saveData(os, myCasts(i).precision);
344 
345  }
346  }
347 
348  }
349 
350  bool load(UT_IStream &is)
351  {
352  int32 v;
353  is.bread(&v, 1);
354  if (version() != v)
355  {
356  // Fail incompatible versions
357  return false;
358  }
359  {
360  int64 length;
361  is.read(&length, 1);
362  myCasts.entries(length);
363  for (exint i = 0; i < length; i++)
364  {
365  loadData(is, myCasts(i)._class);
366  loadData(is, myCasts(i).attribs);
367  loadData(is, myCasts(i).precision);
368 
369  }
370  }
371 
372  return true;
373  }
374 
375  const UT_Array<Casts> &getCasts() const { return myCasts; }
376  void setCasts(const UT_Array<Casts> &val) { myCasts = val; }
377  exint opCasts(const SOP_NodeVerb::CookParms &cookparms) const
378  {
379  SOP_Node *thissop = cookparms.getNode();
380  if (!thissop) return getCasts().entries();
381  exint result;
382  OP_Utils::evalOpParm(result, thissop, "numcasts", cookparms.getCookTime(), 0);
383  return result;
384  }
386  {
387  SOP_Node *thissop = cookparms.getNode();
388  if (!thissop) return (myCasts(_idx)._class);
389  int _parmidx = _idx + 1;
390  UT_StringHolder result;
391  OP_Utils::evalOpParmInst(result, thissop, "class#", &_parmidx, cookparms.getCookTime(), 0);
392  return (result);
393  }
395  {
396  SOP_Node *thissop = cookparms.getNode();
397  if (!thissop) return (myCasts(_idx).attribs);
398  int _parmidx = _idx + 1;
399  UT_StringHolder result;
400  OP_Utils::evalOpParmInst(result, thissop, "attribs#", &_parmidx, cookparms.getCookTime(), 0);
401  return (result);
402  }
404  {
405  SOP_Node *thissop = cookparms.getNode();
406  if (!thissop) return (myCasts(_idx).precision);
407  int _parmidx = _idx + 1;
408  UT_StringHolder result;
409  OP_Utils::evalOpParmInst(result, thissop, "precision#", &_parmidx, cookparms.getCookTime(), 0);
410  return (result);
411  }
412 
413 
414 private:
415  UT_Array<Casts> myCasts;
416 
417 };
void getParmValue(exint idx, fpreal &value) const
static void loadData(UT_IStream &is, UT_Vector4D &v)
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &v)
static void saveData(std::ostream &os, fpreal64 v)
SOP_Node * getNode() const
Definition: SOP_NodeVerb.h:492
T & z(void)
Definition: UT_Vector4.h:372
UT_StringHolder createString(const UT_Array< Casts > &list) const
void setCasts(const UT_Array< Casts > &val)
exint bread(int32 *buffer, exint asize=1)
bool operator==(const SOP_AttribCastParms &src) const
fpreal getTime() const
Definition: OP_Context.h:34
const GLdouble * v
Definition: glcorearb.h:836
static void saveData(std::ostream &os, UT_Vector4D v)
static void loadData(UT_IStream &is, UT_Matrix4D &v)
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
UT_String makeQuotedString(char delimiter='\'', bool escape_nonprinting=false) const
void getParmValue(exint idx, PRM_DataItemHandle &value) const
T & x(void)
Definition: UT_Vector2.h:284
void getParmValue(exint idx, UT_Vector4D &value) const
An output stream object that owns its own string buffer storage.
void getParmValue(exint idx, UT_StringHolder &value) const
static void saveData(std::ostream &os, UT_Matrix4D v)
static void saveData(std::ostream &os, int64 v)
const UT_WorkBuffer & str() const
Returns a read-only reference to the underlying UT_WorkBuffer.
void getParmValue(exint idx, UT_Matrix3D &value) const
SYS_FORCE_INLINE T & x(void)
Definition: UT_Vector3.h:581
static PRM_DataItemHandle parseBinary(const char *type, UT_IStream &is)
void setParmValue(exint idx, const UT_Vector4D &value)
png_uint_32 i
Definition: png.h:2877
static void loadData(UT_IStream &is, PRM_DataItemHandle &v)
static void loadData(UT_IStream &is, int64 &v)
static void saveData(std::ostream &os, bool v)
static void loadData(UT_IStream &is, UT_Vector3I &v)
SYS_FORCE_INLINE T & z(void)
Definition: UT_Vector3.h:585
void setParmValue(exint idx, const UT_Matrix3D &value)
long long int64
Definition: SYS_Types.h:106
void doGetParmValue(exint idx, T &value) const
static void saveData(std::ostream &os, UT_Matrix2D v)
void save(std::ostream &os) const
void setParmValue(exint idx, const exint &value)
exint length() const
char * findChar(int c) const
Find first occurrance of character. Returns NULL upon failure.
Definition: UT_String.h:550
void append(char character)
SYS_FORCE_INLINE const char * buffer() const
int64 exint
Definition: SYS_Types.h:115
const OP_Node * node() const
Definition: SOP_NodeVerb.h:104
double fpreal64
Definition: SYS_Types.h:191
virtual ParmType getParmType(exint fieldnum) const
exint read(bool *array, exint sz=1)
Definition: UT_IStream.h:280
static void loadData(UT_IStream &is, UT_Matrix3D &v)
exint opCasts(const SOP_NodeVerb::CookParms &cookparms) const
static void loadData(UT_IStream &is, UT_Matrix2D &v)
virtual void loadFromOpSubclass(const LoadParms &loadparms)
static void saveData(std::ostream &os, UT_Matrix3D v)
static void loadData(UT_IStream &is, bool &v)
GLboolean * data
Definition: glcorearb.h:130
int int32
Definition: SYS_Types.h:34
T & y(void)
Definition: UT_Vector4.h:370
void getParmValue(exint idx, UT_Vector3D &value) const
void setParmValue(exint idx, const UT_Vector2D &value)
void saveBinary(std::ostream &os) const
Save string to binary stream.
Definition: UT_String.h:294
static void loadData(UT_IStream &is, UT_Vector2I &v)
DEP_MicroNode * depnode() const
Definition: SOP_NodeVerb.h:111
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2539
UT_StringHolder opCasts__class(const SOP_NodeVerb::CookParms &cookparms, exint _idx) const
GLenum GLint GLint * precision
Definition: glcorearb.h:1924
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:446
void getParmValue(exint idx, UT_Matrix2D &value) const
static void loadData(UT_IStream &is, UT_Vector2D &v)
SYS_FORCE_INLINE T & y(void)
Definition: UT_Vector3.h:583
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double fpreal
Definition: SYS_Types.h:269
void strncpy(const char *src, exint maxlen)
static void loadData(UT_IStream &is, UT_Vector3D &v)
void setParmValue(exint idx, const UT_Matrix4D &value)
virtual exint getNumParms() const
void setParmValue(exint idx, const UT_Matrix2D &value)
void doSetParmValue(exint idx, const T &value)
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
static void saveData(std::ostream &os, UT_Vector3D v)
Utility class for containing a color ramp.
Definition: UT_Ramp.h:84
void getParmValue(exint idx, UT_Matrix4D &value) const
void setParmValue(exint idx, const UT_StringHolder &value)
void setParmValue(exint idx, const fpreal &value)
GLuint GLfloat * val
Definition: glcorearb.h:1607
static void loadData(UT_IStream &is, UT_StringHolder &v)
#define SOP_API
Definition: SOP_API.h:10
virtual void copyFrom(const SOP_NodeParms *src)
static void saveData(std::ostream &os, UT_StringHolder s)
UT_StringHolder opCasts_precision(const SOP_NodeVerb::CookParms &cookparms, exint _idx) const
void getParmValue(exint idx, UT_Vector2D &value) const
const char * buffer() const
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
fpreal getCookTime() const
Definition: SOP_NodeVerb.h:499
T & x(void)
Definition: UT_Vector4.h:368
T & y(void)
Definition: UT_Vector2.h:286
GLboolean r
Definition: glcorearb.h:1221
void getParmValue(exint idx, exint &value) const
virtual const char * getParmName(exint fieldnum) const
void strcat(const char *src)
T & w(void)
Definition: UT_Vector4.h:374
UT_StringHolder opCasts_attribs(const SOP_NodeVerb::CookParms &cookparms, exint _idx) const
void setParmValue(exint idx, const UT_Vector3D &value)
const UT_Array< Casts > & getCasts() const
void setParmValue(exint idx, const PRM_DataItemHandle &value)
const OP_Context & context() const
Definition: SOP_NodeVerb.h:109
static void loadData(UT_IStream &is, fpreal64 &v)
static void saveData(std::ostream &os, UT_Vector2D v)
SYS_FORCE_INLINE bool isstring() const
void getParmValue(exint idx, UT_SharedPtr< UT_Ramp > &value) const
void buildFromOp(const OP_Node *node, fpreal time, DEP_MicroNode *depnode)
void setParmValue(exint idx, const UT_SharedPtr< UT_Ramp > &value)
static void saveData(std::ostream &os, PRM_DataItemHandle s)
static void loadData(UT_IStream &is, UT_Vector4I &v)
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:794
GLenum src
Definition: glcorearb.h:1792
bool operator==(const Casts &src) const