HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_Rest.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 <SOP/SOP_GraphProxy.h>
8 
9 #include <OP/OP_Utils.h>
10 #include <PRM/PRM_Parm.h>
11 #include <UT/UT_IStream.h>
12 #include <UT/UT_NTStreamUtil.h>
13 #include <UT/UT_Ramp.h>
14 #include <UT/UT_SharedPtr.h>
15 #include <UT/UT_StringHolder.h>
16 #include <UT/UT_StringStream.h>
17 #include <UT/UT_VectorTypes.h>
18 #include <SYS/SYS_Types.h>
19 
20 using namespace UT::Literal;
21 
22 class DEP_MicroNode;
23 namespace SOP_RestEnums
24 {
25  enum class Nml
26  {
27  OFF = 0,
28  POLY,
29  ON
30  };
31  enum class Quadric
32  {
33  OFF = 0,
34  POLY,
35  ON
36  };
37 }
38 
39 
41 {
42 public:
43  static int version() { return 1; }
44 
46  {
47  myFile = ""_sh;
48  myNml = 0;
49  myQuadric = 0;
50 
51  }
52 
53  explicit SOP_RestParms(const SOP_RestParms &) = default;
54 
55  ~SOP_RestParms() override {}
56 
57  bool operator==(const SOP_RestParms &src) const
58  {
59  if (myFile != src.myFile) return false;
60  if (myNml != src.myNml) return false;
61  if (myQuadric != src.myQuadric) return false;
62 
63  return true;
64  }
65  bool operator!=(const SOP_RestParms &src) const
66  {
67  return !operator==(src);
68  }
71 
72 
73 
74  void buildFromOp(const SOP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
75  {
76  myFile = ""_sh;
77  if (true && ( (!((((graph->getInput(nodeidx,1)>=0)==1)))) ) )
78  graph->evalOpParm(myFile, nodeidx, "file", time, 0);
79  myNml = 0;
80  if (true)
81  graph->evalOpParm(myNml, nodeidx, "nml", time, 0);
82  myQuadric = 0;
83  if (true)
84  graph->evalOpParm(myQuadric, nodeidx, "quadric", time, 0);
85 
86  }
87 
88 
89  void loadFromOpSubclass(const LoadParms &loadparms) override
90  {
91  buildFromOp(loadparms.graph(), loadparms.nodeIdx(), loadparms.context().getTime(), loadparms.depnode());
92  }
93 
94 
95  void copyFrom(const SOP_NodeParms *src) override
96  {
97  *this = *((const SOP_RestParms *)src);
98  }
99 
100  template <typename T>
101  void
102  doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
103  {
104  if (idx.size() < 1)
105  return;
106  UT_ASSERT(idx.size() == instance.size()+1);
107  if (idx.size() != instance.size()+1)
108  return;
109  switch (idx[0])
110  {
111  case 0:
112  coerceValue(value, myFile);
113  break;
114  case 1:
115  coerceValue(value, myNml);
116  break;
117  case 2:
118  coerceValue(value, myQuadric);
119  break;
120 
121  }
122  }
123 
124  void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
125  { doGetParmValue(idx, instance, value); }
126  void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
127  { doGetParmValue(idx, instance, value); }
128  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
129  { doGetParmValue(idx, instance, value); }
130  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
131  { doGetParmValue(idx, instance, value); }
132  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
133  { doGetParmValue(idx, instance, value); }
134  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
135  { doGetParmValue(idx, instance, value); }
136  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
137  { doGetParmValue(idx, instance, value); }
138  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
139  { doGetParmValue(idx, instance, value); }
140  void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
141  { doGetParmValue(idx, instance, value); }
142  void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr<UT_Ramp> &value) const override
143  { doGetParmValue(idx, instance, value); }
144  void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
145  { doGetParmValue(idx, instance, value); }
146 
147  template <typename T>
148  void
149  doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
150  {
151  if (idx.size() < 1)
152  return;
153  UT_ASSERT(idx.size() == instance.size()+1);
154  if (idx.size() != instance.size()+1)
155  return;
156  switch (idx[0])
157  {
158  case 0:
159  coerceValue(myFile, value);
160  break;
161  case 1:
162  coerceValue(myNml, value);
163  break;
164  case 2:
165  coerceValue(myQuadric, value);
166  break;
167 
168  }
169  }
170 
171  void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
172  { doSetParmValue(idx, instance, value); }
173  void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
174  { doSetParmValue(idx, instance, value); }
175  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
176  { doSetParmValue(idx, instance, value); }
177  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
178  { doSetParmValue(idx, instance, value); }
179  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
180  { doSetParmValue(idx, instance, value); }
181  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
182  { doSetParmValue(idx, instance, value); }
183  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
184  { doSetParmValue(idx, instance, value); }
185  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
186  { doSetParmValue(idx, instance, value); }
187  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
188  { doSetParmValue(idx, instance, value); }
189  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr<UT_Ramp> &value) override
190  { doSetParmValue(idx, instance, value); }
191  void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
192  { doSetParmValue(idx, instance, value); }
193 
194  exint getNestNumParms(TempIndex idx) const override
195  {
196  if (idx.size() == 0)
197  return 3;
198  switch (idx[0])
199  {
200 
201  }
202  // Invalid
203  return 0;
204  }
205 
206  const char *getNestParmName(TempIndex fieldnum) const override
207  {
208  if (fieldnum.size() < 1)
209  return 0;
210  switch (fieldnum[0])
211  {
212  case 0:
213  return "file";
214  case 1:
215  return "nml";
216  case 2:
217  return "quadric";
218 
219  }
220  return 0;
221  }
222 
223  ParmType getNestParmType(TempIndex fieldnum) const override
224  {
225  if (fieldnum.size() < 1)
226  return PARM_UNSUPPORTED;
227  switch (fieldnum[0])
228  {
229  case 0:
230  return PARM_STRING;
231  case 1:
232  return PARM_INTEGER;
233  case 2:
234  return PARM_INTEGER;
235 
236  }
237  return PARM_UNSUPPORTED;
238  }
239 
240  // Boiler plate to load individual types.
241  static void loadData(UT_IStream &is, int64 &v)
242  { is.bread(&v, 1); }
243  static void loadData(UT_IStream &is, bool &v)
244  { int64 iv; is.bread(&iv, 1); v = iv; }
245  static void loadData(UT_IStream &is, fpreal64 &v)
246  { is.bread<fpreal64>(&v, 1); }
247  static void loadData(UT_IStream &is, UT_Vector2D &v)
248  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
249  static void loadData(UT_IStream &is, UT_Vector3D &v)
250  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
251  is.bread<fpreal64>(&v.z(), 1); }
252  static void loadData(UT_IStream &is, UT_Vector4D &v)
253  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
254  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
255  static void loadData(UT_IStream &is, UT_Matrix2D &v)
256  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
257  static void loadData(UT_IStream &is, UT_Matrix3D &v)
258  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
259  static void loadData(UT_IStream &is, UT_Matrix4D &v)
260  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
261  static void loadData(UT_IStream &is, UT_Vector2I &v)
262  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
263  static void loadData(UT_IStream &is, UT_Vector3I &v)
264  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
265  is.bread<int64>(&v.z(), 1); }
266  static void loadData(UT_IStream &is, UT_Vector4I &v)
267  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
268  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
270  { is.bread(v); }
272  { UT_StringHolder rampdata;
273  loadData(is, rampdata);
274  if (rampdata.isstring())
275  {
276  v.reset(new UT_Ramp());
277  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
278  v->load(istr);
279  }
280  else v.reset();
281  }
284  loadData(is, data);
285  if (data.isstring())
286  {
287  // Find the data type.
288  const char *colon = UT_StringWrap(data).findChar(':');
289  if (colon)
290  {
291  int typelen = colon - data.buffer();
293  type.strncpy(data.buffer(), typelen);
294  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
295 
296  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
297  }
298  }
299  else v.reset();
300  }
301 
302  static void saveData(std::ostream &os, int64 v)
303  { UTwrite(os, &v); }
304  static void saveData(std::ostream &os, bool v)
305  { int64 iv = v; UTwrite(os, &iv); }
306  static void saveData(std::ostream &os, fpreal64 v)
307  { UTwrite<fpreal64>(os, &v); }
308  static void saveData(std::ostream &os, UT_Vector2D v)
309  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
310  static void saveData(std::ostream &os, UT_Vector3D v)
311  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
312  UTwrite<fpreal64>(os, &v.z()); }
313  static void saveData(std::ostream &os, UT_Vector4D v)
314  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
315  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
316  static void saveData(std::ostream &os, UT_Matrix2D v)
318  static void saveData(std::ostream &os, UT_Matrix3D v)
320  static void saveData(std::ostream &os, UT_Matrix4D v)
322  static void saveData(std::ostream &os, UT_StringHolder s)
323  { UT_StringWrap(s).saveBinary(os); }
324  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
326  UT_OStringStream ostr;
327  if (s) s->save(ostr);
328  result = ostr.str();
329  saveData(os, result);
330  }
331  static void saveData(std::ostream &os, PRM_DataItemHandle s)
333  UT_OStringStream ostr;
334  if (s)
335  {
336  ostr << s->getDataTypeToken();
337  ostr << ":";
338  s->saveBinary(ostr);
339  }
340  result = ostr.str();
341  saveData(os, result);
342  }
343 
344 
345  void save(std::ostream &os) const
346  {
347  int32 v = version();
348  UTwrite(os, &v);
349  saveData(os, myFile);
350  saveData(os, myNml);
351  saveData(os, myQuadric);
352 
353  }
354 
355  bool load(UT_IStream &is)
356  {
357  int32 v;
358  is.bread(&v, 1);
359  if (version() != v)
360  {
361  // Fail incompatible versions
362  return false;
363  }
364  loadData(is, myFile);
365  loadData(is, myNml);
366  loadData(is, myQuadric);
367 
368  return true;
369  }
370 
371  const UT_StringHolder & getFile() const { return myFile; }
372  void setFile(const UT_StringHolder & val) { myFile = val; }
374  {
375  SOP_Node *thissop = cookparms.getNode();
376  if (!thissop) return getFile();
378  OP_Utils::evalOpParm(result, thissop, "file", cookparms.getCookTime(), 0);
379  return result;
380  }
381  Nml getNml() const { return Nml(myNml); }
382  void setNml(Nml val) { myNml = int64(val); }
383  Nml opNml(const SOP_NodeVerb::CookParms &cookparms) const
384  {
385  SOP_Node *thissop = cookparms.getNode();
386  if (!thissop) return getNml();
387  int64 result;
388  OP_Utils::evalOpParm(result, thissop, "nml", cookparms.getCookTime(), 0);
389  return Nml(result);
390  }
391  Quadric getQuadric() const { return Quadric(myQuadric); }
392  void setQuadric(Quadric val) { myQuadric = int64(val); }
393  Quadric opQuadric(const SOP_NodeVerb::CookParms &cookparms) const
394  {
395  SOP_Node *thissop = cookparms.getNode();
396  if (!thissop) return getQuadric();
397  int64 result;
398  OP_Utils::evalOpParm(result, thissop, "quadric", cookparms.getCookTime(), 0);
399  return Quadric(result);
400  }
401 
402 private:
403  UT_StringHolder myFile;
404  int64 myNml;
405  int64 myQuadric;
406 
407 };
GLdouble s
Definition: glew.h:1390
static void loadData(UT_IStream &is, UT_Matrix3D &v)
static void loadData(UT_IStream &is, UT_Matrix4D &v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
Quadric getQuadric() const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr< UT_Ramp > &value) override
void buildFromOp(const SOP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
exint nodeIdx() const
Definition: SOP_NodeVerb.h:114
GLenum src
Definition: glew.h:2410
int int32
Definition: SYS_Types.h:39
SOP_Node * getNode() const
Definition: SOP_NodeVerb.h:640
virtual NodeIdx getInput(NodeIdx idx, int input, bool markused=false) const =0
Nml getNml() const
exint bread(int32 *buffer, exint asize=1)
GT_API const UT_StringHolder time
fpreal getTime() const
Definition: OP_Context.h:60
GLuint const GLfloat * val
Definition: glew.h:2794
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
static void saveData(std::ostream &os, UT_Matrix3D v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr< UT_Ramp > &value) const override
int64 exint
Definition: SYS_Types.h:125
void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
static void loadData(UT_IStream &is, UT_StringHolder &v)
SYS_FORCE_INLINE const char * buffer() const
const SOP_GraphProxy * graph() const
Definition: SOP_NodeVerb.h:113
void setNml(Nml val)
An output stream object that owns its own string buffer storage.
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
const GLdouble * v
Definition: glew.h:1391
void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
static PRM_DataItemHandle parseBinary(const char *type, UT_IStream &is)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
const UT_WorkBuffer & str()
Returns a read-only reference to the underlying UT_WorkBuffer.
~SOP_RestParms() override
static void saveData(std::ostream &os, int64 v)
static void loadData(UT_IStream &is, fpreal64 &v)
Quadric opQuadric(const SOP_NodeVerb::CookParms &cookparms) const
const char * getNestParmName(TempIndex fieldnum) const override
static void loadData(UT_IStream &is, bool &v)
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
const UT_StringHolder & getFile() const
bool load(UT_IStream &is)
static void saveData(std::ostream &os, UT_Matrix2D v)
double fpreal64
Definition: SYS_Types.h:201
static void saveData(std::ostream &os, UT_StringHolder s)
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
static void loadData(UT_IStream &is, PRM_DataItemHandle &v)
SYS_FORCE_INLINE T & y()
Definition: UT_Vector3.h:513
bool operator==(const SOP_RestParms &src) const
exint length() const
void doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
SYS_FORCE_INLINE const char * buffer() const
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:28
static void loadData(UT_IStream &is, UT_Vector4D &v)
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
SYS_FORCE_INLINE T & z()
Definition: UT_Vector3.h:515
UT_StringHolder opFile(const SOP_NodeVerb::CookParms &cookparms) const
const GLfloat * c
Definition: glew.h:16296
void loadFromOpSubclass(const LoadParms &loadparms) override
static void saveData(std::ostream &os, PRM_DataItemHandle s)
long long int64
Definition: SYS_Types.h:116
void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
Nml opNml(const SOP_NodeVerb::CookParms &cookparms) const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
void saveBinary(std::ostream &os) const
Save string to binary stream.
Definition: UT_String.h:294
GT_API const UT_StringHolder version
DEP_MicroNode * depnode() const
Definition: SOP_NodeVerb.h:121
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
static void loadData(UT_IStream &is, int64 &v)
bool operator!=(const SOP_RestParms &src) const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
static void saveData(std::ostream &os, UT_Matrix4D v)
fpreal64 fpreal
Definition: SYS_Types.h:277
Utility class for containing a color ramp.
Definition: UT_Ramp.h:84
void copyFrom(const SOP_NodeParms *src) override
static void saveData(std::ostream &os, UT_Vector4D v)
GLdouble GLdouble GLdouble r
Definition: glew.h:1406
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
static void saveData(std::ostream &os, UT_Vector3D v)
#define SOP_API
Definition: SOP_API.h:10
exint getNestNumParms(TempIndex idx) const override
virtual void evalOpParm(int64 &v, NodeIdx node, const char *parmname, fpreal time, DEP_MicroNode *depnode) const =0
SYS_FORCE_INLINE T & x()
Definition: UT_Vector3.h:511
fpreal getCookTime() const
Definition: SOP_NodeVerb.h:654
void setFile(const UT_StringHolder &val)
GLuint64EXT * result
Definition: glew.h:14007
static void loadData(UT_IStream &is, UT_Vector2D &v)
static void loadData(UT_IStream &is, UT_Vector4I &v)
static void saveData(std::ostream &os, fpreal64 v)
const char * findChar(int c) const
Definition: UT_String.h:1367
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:135
void doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
static void loadData(UT_IStream &is, UT_Vector3I &v)
void setQuadric(Quadric val)
static int version()
static void loadData(UT_IStream &is, UT_Matrix2D &v)
void save(std::ostream &os) const
static void saveData(std::ostream &os, bool v)
GLsizei const GLfloat * value
Definition: glew.h:1849
static void saveData(std::ostream &os, UT_Vector2D v)
const OP_Context & context() const
Definition: SOP_NodeVerb.h:119
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: PRM_Parm.h:89
static void loadData(UT_IStream &is, UT_Vector3D &v)
SYS_FORCE_INLINE bool isstring() const
void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
SYS_FORCE_INLINE void strncpy(const char *src, exint maxlen)
type
Definition: core.h:528
ParmType getNestParmType(TempIndex fieldnum) const override
static void loadData(UT_IStream &is, UT_Vector2I &v)