HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_MLExampleDecomposeCore.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 namespace SOP_MLExampleDecomposeCoreEnums
24 {
25  enum class ComponentType
26  {
27  INPUT = 0,
28  TARGET
29  };
30 
32  getToken(ComponentType enum_value)
33  {
34  using namespace UT::Literal;
35  switch (enum_value) {
36  case ComponentType::INPUT: return "input"_sh;
37  case ComponentType::TARGET: return "target"_sh;
38  default: UT_ASSERT(false); return ""_sh;
39  }
40  }
41 
42 }
43 
44 
46 {
47 public:
48  static int version() { return 1; }
49 
51  {
52  myComponentType = 0;
53  myKeepComponentPacked = false;
54 
55  }
56 
60  SOP_MLExampleDecomposeCoreParms &operator=(SOP_MLExampleDecomposeCoreParms &&) noexcept = default;
61 
63 
65  {
66  if (myComponentType != src.myComponentType) return false;
67  if (myKeepComponentPacked != src.myKeepComponentPacked) return false;
68 
69  return true;
70  }
72  {
73  return !operator==(src);
74  }
76 
77 
78 
79  void buildFromOp(const OP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
80  {
81  myComponentType = 0;
82  if (true)
83  graph->evalOpParm(myComponentType, nodeidx, "componenttype", time, 0);
84  myKeepComponentPacked = false;
85  if (true)
86  graph->evalOpParm(myKeepComponentPacked, nodeidx, "keepcomponentpacked", time, 0);
87 
88  }
89 
90 
91  void loadFromOpSubclass(const LoadParms &loadparms) override
92  {
93  buildFromOp(loadparms.graph(), loadparms.nodeIdx(), loadparms.context().getTime(), loadparms.depnode());
94  }
95 
96 
97  void copyFrom(const OP_NodeParms *src) override
98  {
99  *this = *((const SOP_MLExampleDecomposeCoreParms *)src);
100  }
101 
102  template <typename T>
103  void
104  doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
105  {
106  if (idx.size() < 1)
107  return;
108  UT_ASSERT(idx.size() == instance.size()+1);
109  if (idx.size() != instance.size()+1)
110  return;
111  switch (idx[0])
112  {
113  case 0:
114  coerceValue(value, myComponentType);
115  break;
116  case 1:
117  coerceValue(value, myKeepComponentPacked);
118  break;
119 
120  }
121  }
122 
123  bool isParmColorRamp(exint idx) const override
124  {
125  switch (idx)
126  {
127 
128  }
129  return false;
130  }
131 
132  void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
133  { doGetParmValue(idx, instance, value); }
134  void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
135  { doGetParmValue(idx, instance, value); }
136  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
137  { doGetParmValue(idx, instance, value); }
138  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
139  { doGetParmValue(idx, instance, value); }
140  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
141  { doGetParmValue(idx, instance, value); }
142  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
143  { doGetParmValue(idx, instance, value); }
144  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
145  { doGetParmValue(idx, instance, value); }
146  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
147  { doGetParmValue(idx, instance, value); }
148  void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
149  { doGetParmValue(idx, instance, value); }
150  void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr<UT_Ramp> &value) const override
151  { doGetParmValue(idx, instance, value); }
152  void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
153  { doGetParmValue(idx, instance, value); }
154 
155  template <typename T>
156  void
157  doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
158  {
159  if (idx.size() < 1)
160  return;
161  UT_ASSERT(idx.size() == instance.size()+1);
162  if (idx.size() != instance.size()+1)
163  return;
164  switch (idx[0])
165  {
166  case 0:
167  coerceValue(myComponentType, clampMinValue(0, clampMaxValue(1, value ) ));
168  break;
169  case 1:
170  coerceValue(myKeepComponentPacked, ( ( value ) ));
171  break;
172 
173  }
174  }
175 
176  void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
177  { doSetParmValue(idx, instance, value); }
178  void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
179  { doSetParmValue(idx, instance, value); }
180  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
181  { doSetParmValue(idx, instance, value); }
182  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
183  { doSetParmValue(idx, instance, value); }
184  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
185  { doSetParmValue(idx, instance, value); }
186  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
187  { doSetParmValue(idx, instance, value); }
188  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
189  { doSetParmValue(idx, instance, value); }
190  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
191  { doSetParmValue(idx, instance, value); }
192  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
193  { doSetParmValue(idx, instance, value); }
194  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr<UT_Ramp> &value) override
195  { doSetParmValue(idx, instance, value); }
196  void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
197  { doSetParmValue(idx, instance, value); }
198 
199  exint getNestNumParms(TempIndex idx) const override
200  {
201  if (idx.size() == 0)
202  return 2;
203  switch (idx[0])
204  {
205 
206  }
207  // Invalid
208  return 0;
209  }
210 
211  const char *getNestParmName(TempIndex fieldnum) const override
212  {
213  if (fieldnum.size() < 1)
214  return 0;
215  switch (fieldnum[0])
216  {
217  case 0:
218  return "componenttype";
219  case 1:
220  return "keepcomponentpacked";
221 
222  }
223  return 0;
224  }
225 
226  ParmType getNestParmType(TempIndex fieldnum) const override
227  {
228  if (fieldnum.size() < 1)
229  return PARM_UNSUPPORTED;
230  switch (fieldnum[0])
231  {
232  case 0:
233  return PARM_INTEGER;
234  case 1:
235  return PARM_INTEGER;
236 
237  }
238  return PARM_UNSUPPORTED;
239  }
240 
241  // Boiler plate to load individual types.
242  static void loadData(UT_IStream &is, int64 &v)
243  { is.bread(&v, 1); }
244  static void loadData(UT_IStream &is, bool &v)
245  { int64 iv; is.bread(&iv, 1); v = iv; }
246  static void loadData(UT_IStream &is, fpreal64 &v)
247  { is.bread<fpreal64>(&v, 1); }
248  static void loadData(UT_IStream &is, UT_Vector2D &v)
249  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
250  static void loadData(UT_IStream &is, UT_Vector3D &v)
251  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
252  is.bread<fpreal64>(&v.z(), 1); }
253  static void loadData(UT_IStream &is, UT_Vector4D &v)
254  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
255  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
256  static void loadData(UT_IStream &is, UT_Matrix2D &v)
257  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
258  static void loadData(UT_IStream &is, UT_Matrix3D &v)
259  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
260  static void loadData(UT_IStream &is, UT_Matrix4D &v)
261  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
262  static void loadData(UT_IStream &is, UT_Vector2I &v)
263  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
264  static void loadData(UT_IStream &is, UT_Vector3I &v)
265  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
266  is.bread<int64>(&v.z(), 1); }
267  static void loadData(UT_IStream &is, UT_Vector4I &v)
268  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
269  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
271  { is.bread(v); }
273  { UT_StringHolder rampdata;
274  loadData(is, rampdata);
275  if (rampdata.isstring())
276  {
277  v.reset(new UT_Ramp());
278  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
279  v->load(istr);
280  }
281  else v.reset();
282  }
285  loadData(is, data);
286  if (data.isstring())
287  {
288  // Find the data type.
289  const char *colon = UT_StringWrap(data).findChar(':');
290  if (colon)
291  {
292  int typelen = colon - data.buffer();
294  type.strncpy(data.buffer(), typelen);
295  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
296 
297  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
298  }
299  }
300  else v.reset();
301  }
302 
303  static void saveData(std::ostream &os, int64 v)
304  { UTwrite(os, &v); }
305  static void saveData(std::ostream &os, bool v)
306  { int64 iv = v; UTwrite(os, &iv); }
307  static void saveData(std::ostream &os, fpreal64 v)
308  { UTwrite<fpreal64>(os, &v); }
309  static void saveData(std::ostream &os, UT_Vector2D v)
310  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
311  static void saveData(std::ostream &os, UT_Vector3D v)
312  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
313  UTwrite<fpreal64>(os, &v.z()); }
314  static void saveData(std::ostream &os, UT_Vector4D v)
315  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
316  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
317  static void saveData(std::ostream &os, UT_Matrix2D v)
319  static void saveData(std::ostream &os, UT_Matrix3D v)
321  static void saveData(std::ostream &os, UT_Matrix4D v)
323  static void saveData(std::ostream &os, UT_StringHolder s)
324  { UT_StringWrap(s).saveBinary(os); }
325  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
327  UT_OStringStream ostr;
328  if (s) s->save(ostr);
329  result = ostr.str();
330  saveData(os, result);
331  }
332  static void saveData(std::ostream &os, PRM_DataItemHandle s)
334  UT_OStringStream ostr;
335  if (s)
336  {
337  ostr << s->getDataTypeToken();
338  ostr << ":";
339  s->saveBinary(ostr);
340  }
341  result = ostr.str();
342  saveData(os, result);
343  }
344 
345 
346  void save(std::ostream &os) const
347  {
348  int32 v = version();
349  UTwrite(os, &v);
350  saveData(os, myComponentType);
351  saveData(os, myKeepComponentPacked);
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, myComponentType);
365  loadData(is, myKeepComponentPacked);
366 
367  return true;
368  }
369 
370  ComponentType getComponentType() const { return ComponentType(myComponentType); }
371  void setComponentType(ComponentType val) { myComponentType = int64(val); }
373  {
374  SOP_Node *thissop = cookparms.getNode();
375  if (!thissop) return getComponentType();
376  int64 result;
377  OP_Utils::evalOpParm(result, thissop, "componenttype", cookparms.getCookTime(), 0);
378  return ComponentType(result);
379  }
380  bool getKeepComponentPacked() const { return myKeepComponentPacked; }
381  void setKeepComponentPacked(bool val) { myKeepComponentPacked = val; }
382  bool opKeepComponentPacked(const SOP_NodeVerb::CookParms &cookparms) const
383  {
384  SOP_Node *thissop = cookparms.getNode();
385  if (!thissop) return getKeepComponentPacked();
386  bool result;
387  OP_Utils::evalOpParm(result, thissop, "keepcomponentpacked", cookparms.getCookTime(), 0);
388  return result;
389  }
390 
391 private:
392  int64 myComponentType;
393  bool myKeepComponentPacked;
394 
395 };
static void loadData(UT_IStream &is, UT_Vector4D &v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
void loadFromOpSubclass(const LoadParms &loadparms) override
void doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
bool operator==(const SOP_MLExampleDecomposeCoreParms &src) const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
int int32
Definition: SYS_Types.h:39
SOP_Node * getNode() const
Definition: SOP_NodeVerb.h:347
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
static void saveData(std::ostream &os, bool v)
static void loadData(UT_IStream &is, UT_Matrix3D &v)
exint bread(int32 *buffer, exint asize=1)
GLboolean * data
Definition: glcorearb.h:131
void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
GT_API const UT_StringHolder time
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector4.h:493
const GLdouble * v
Definition: glcorearb.h:837
const char * getNestParmName(TempIndex fieldnum) const override
static void saveData(std::ostream &os, fpreal64 v)
fpreal getTime() const
Definition: OP_Context.h:62
void buildFromOp(const OP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
exint getNestNumParms(TempIndex idx) const override
static void loadData(UT_IStream &is, UT_Matrix4D &v)
const OP_Context & context() const
Definition: OP_NodeParms.h:97
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector3.h:667
int64 exint
Definition: SYS_Types.h:125
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
SYS_FORCE_INLINE const char * buffer() const
GLdouble s
Definition: glad.h:3009
void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
An output stream object that owns its own string buffer storage.
static void saveData(std::ostream &os, UT_Matrix3D v)
static void loadData(UT_IStream &is, UT_Vector4I &v)
static void loadData(UT_IStream &is, bool &v)
**But if you need a result
Definition: thread.h:613
static void saveData(std::ostream &os, UT_Vector4D v)
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.
void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector4.h:491
bool operator!=(const SOP_MLExampleDecomposeCoreParms &src) const
static void loadData(UT_IStream &is, int64 &v)
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
double fpreal64
Definition: SYS_Types.h:201
void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr< UT_Ramp > &value) const override
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector2.h:423
static void saveData(std::ostream &os, PRM_DataItemHandle s)
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
ComponentType opComponentType(const SOP_NodeVerb::CookParms &cookparms) const
void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
bool opKeepComponentPacked(const SOP_NodeVerb::CookParms &cookparms) const
exint length() const
SYS_FORCE_INLINE const char * buffer() const
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 setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr< UT_Ramp > &value) override
const OP_GraphProxy * graph() const
Definition: OP_NodeParms.h:94
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
static void saveData(std::ostream &os, UT_StringHolder s)
static void saveData(std::ostream &os, UT_Matrix4D v)
ParmType getNestParmType(TempIndex fieldnum) const override
long long int64
Definition: SYS_Types.h:116
void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
static void loadData(UT_IStream &is, UT_StringHolder &v)
static void loadData(UT_IStream &is, UT_Vector3D &v)
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_Matrix4D &value) const override
void saveBinary(std::ostream &os) const
Save string to binary stream.
Definition: UT_String.h:296
void copyFrom(const OP_NodeParms *src) override
GT_API const UT_StringHolder version
static void saveData(std::ostream &os, UT_Vector2D v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &v)
static void saveData(std::ostream &os, UT_Vector3D v)
void doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
fpreal64 fpreal
Definition: SYS_Types.h:277
DEP_MicroNode * depnode() const
Definition: OP_NodeParms.h:99
LeafData & operator=(const LeafData &)=delete
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
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
#define SOP_API
Definition: SOP_API.h:10
static void loadData(UT_IStream &is, UT_Vector3I &v)
static void saveData(std::ostream &os, int64 v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
static void loadData(UT_IStream &is, fpreal64 &v)
fpreal getCookTime() const
Definition: SOP_NodeVerb.h:361
static void saveData(std::ostream &os, UT_Matrix2D v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
const char * findChar(int c) const
Definition: UT_String.h:1395
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
SYS_FORCE_INLINE UT_StringHolder getToken(ComponentType enum_value)
Definition: core.h:1131
static void loadData(UT_IStream &is, PRM_DataItemHandle &v)
GLboolean r
Definition: glcorearb.h:1222
bool isParmColorRamp(exint idx) const override
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector3.h:665
type
Definition: core.h:1059
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: PRM_Parm.h:97
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector2.h:425
static void loadData(UT_IStream &is, UT_Vector2D &v)
SYS_FORCE_INLINE bool isstring() const
static void loadData(UT_IStream &is, UT_Vector2I &v)
SYS_FORCE_INLINE void strncpy(const char *src, exint maxlen)
GLenum src
Definition: glcorearb.h:1793
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector3.h:663