HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SOP_SwitchParms.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 
28  {
29  myInput = 0;
30 
31  }
32 
33  explicit SOP_SwitchParms(const SOP_SwitchParms &) = default;
34 
35  virtual ~SOP_SwitchParms() {}
36 
37  bool operator==(const SOP_SwitchParms &src) const
38  {
39  if (myInput != src.myInput) return false;
40 
41  return true;
42  }
43 
44 
45 
46  void buildFromOp(const OP_Node *node, fpreal time, DEP_MicroNode *depnode)
47  {
48  if (true)
49  OP_Utils::evalOpParm(myInput, node, "input", time, 0);
50  else myInput = 0;
51 
52  }
53 
54 
55  virtual void loadFromOpSubclass(const LoadParms &loadparms)
56  {
57  buildFromOp(loadparms.node(), loadparms.context().getTime(), loadparms.depnode());
58  }
59 
60 
61  virtual void copyFrom(const SOP_NodeParms *src)
62  {
63  *this = *((const SOP_SwitchParms *)src);
64  }
65 
66  template <typename T>
67  void
68  doGetParmValue(exint idx, T &value) const
69  {
70  switch (idx)
71  {
72  case 0:
73  coerceValue(value, myInput);
74  break;
75 
76  }
77  }
78 
79  void getParmValue(exint idx, exint &value) const
80  { doGetParmValue(idx, value); }
81  void getParmValue(exint idx, fpreal &value) const
82  { doGetParmValue(idx, value); }
83  void getParmValue(exint idx, UT_Vector2D &value) const
84  { doGetParmValue(idx, value); }
85  void getParmValue(exint idx, UT_Vector3D &value) const
86  { doGetParmValue(idx, value); }
87  void getParmValue(exint idx, UT_Vector4D &value) const
88  { doGetParmValue(idx, value); }
89  void getParmValue(exint idx, UT_Matrix2D &value) const
90  { doGetParmValue(idx, value); }
91  void getParmValue(exint idx, UT_Matrix3D &value) const
92  { doGetParmValue(idx, value); }
93  void getParmValue(exint idx, UT_Matrix4D &value) const
94  { doGetParmValue(idx, value); }
96  { doGetParmValue(idx, value); }
98  { doGetParmValue(idx, value); }
100  { doGetParmValue(idx, value); }
101 
102  template <typename T>
103  void
104  doSetParmValue(exint idx, const T &value)
105  {
106  switch (idx)
107  {
108  case 0:
109  coerceValue(myInput, value);
110  break;
111 
112  }
113  }
114 
115  void setParmValue(exint idx, const exint &value)
116  { doSetParmValue(idx, value); }
117  void setParmValue(exint idx, const fpreal &value)
118  { doSetParmValue(idx, value); }
119  void setParmValue(exint idx, const UT_Vector2D &value)
120  { doSetParmValue(idx, value); }
121  void setParmValue(exint idx, const UT_Vector3D &value)
122  { doSetParmValue(idx, value); }
123  void setParmValue(exint idx, const UT_Vector4D &value)
124  { doSetParmValue(idx, value); }
125  void setParmValue(exint idx, const UT_Matrix2D &value)
126  { doSetParmValue(idx, value); }
127  void setParmValue(exint idx, const UT_Matrix3D &value)
128  { doSetParmValue(idx, value); }
129  void setParmValue(exint idx, const UT_Matrix4D &value)
130  { doSetParmValue(idx, value); }
132  { doSetParmValue(idx, value); }
134  { doSetParmValue(idx, value); }
136  { doSetParmValue(idx, value); }
137 
138  virtual exint getNumParms() const
139  {
140  return 1;
141  }
142 
143  virtual const char *getParmName(exint fieldnum) const
144  {
145  switch (fieldnum)
146  {
147  case 0:
148  return "input";
149 
150  }
151  return 0;
152  }
153 
154  virtual ParmType getParmType(exint fieldnum) const
155  {
156  switch (fieldnum)
157  {
158  case 0:
159  return PARM_INTEGER;
160 
161  }
162  return PARM_UNSUPPORTED;
163  }
164 
165  // Boiler plate to load individual types.
166  static void loadData(UT_IStream &is, int64 &v)
167  { is.bread(&v, 1); }
168  static void loadData(UT_IStream &is, bool &v)
169  { int64 iv; is.bread(&iv, 1); v = iv; }
170  static void loadData(UT_IStream &is, fpreal64 &v)
171  { is.bread<fpreal64>(&v, 1); }
172  static void loadData(UT_IStream &is, UT_Vector2D &v)
173  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
174  static void loadData(UT_IStream &is, UT_Vector3D &v)
175  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
176  is.bread<fpreal64>(&v.z(), 1); }
177  static void loadData(UT_IStream &is, UT_Vector4D &v)
178  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
179  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
180  static void loadData(UT_IStream &is, UT_Matrix2D &v)
181  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
182  static void loadData(UT_IStream &is, UT_Matrix3D &v)
183  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
184  static void loadData(UT_IStream &is, UT_Matrix4D &v)
185  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
186  static void loadData(UT_IStream &is, UT_Vector2I &v)
187  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
188  static void loadData(UT_IStream &is, UT_Vector3I &v)
189  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
190  is.bread<int64>(&v.z(), 1); }
191  static void loadData(UT_IStream &is, UT_Vector4I &v)
192  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
193  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
195  { is.bread(v); }
197  { UT_StringHolder rampdata;
198  loadData(is, rampdata);
199  if (rampdata.isstring())
200  {
201  v.reset(new UT_Ramp());
202  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
203  v->load(istr);
204  }
205  else v.reset();
206  }
209  loadData(is, data);
210  if (data.isstring())
211  {
212  // Find the data type.
213  char *colon = UT_StringWrap(data).findChar(':');
214  if (colon)
215  {
216  int typelen = colon - data.buffer();
218  type.strncpy(data.buffer(), typelen);
219  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
220 
221  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
222  }
223  }
224  else v.reset();
225  }
226 
227  static void saveData(std::ostream &os, int64 v)
228  { UTwrite(os, &v); }
229  static void saveData(std::ostream &os, bool v)
230  { int64 iv = v; UTwrite(os, &iv); }
231  static void saveData(std::ostream &os, fpreal64 v)
232  { UTwrite<fpreal64>(os, &v); }
233  static void saveData(std::ostream &os, UT_Vector2D v)
234  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
235  static void saveData(std::ostream &os, UT_Vector3D v)
236  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
237  UTwrite<fpreal64>(os, &v.z()); }
238  static void saveData(std::ostream &os, UT_Vector4D v)
239  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
240  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
241  static void saveData(std::ostream &os, UT_Matrix2D v)
243  static void saveData(std::ostream &os, UT_Matrix3D v)
245  static void saveData(std::ostream &os, UT_Matrix4D v)
247  static void saveData(std::ostream &os, UT_StringHolder s)
248  { UT_StringWrap(s).saveBinary(os); }
249  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
250  { UT_StringHolder result;
251  UT_OStringStream ostr;
252  if (s) s->save(ostr);
253  result = ostr.str();
254  saveData(os, result);
255  }
256  static void saveData(std::ostream &os, PRM_DataItemHandle s)
257  { UT_StringHolder result;
258  UT_OStringStream ostr;
259  if (s)
260  {
261  ostr << s->getDataTypeToken();
262  ostr << ":";
263  s->saveBinary(ostr);
264  }
265  result = ostr.str();
266  saveData(os, result);
267  }
268 
269 
270  void save(std::ostream &os) const
271  {
272  int32 v = version();
273  UTwrite(os, &v);
274  saveData(os, myInput);
275 
276  }
277 
278  bool load(UT_IStream &is)
279  {
280  int32 v;
281  is.bread(&v, 1);
282  if (version() != v)
283  {
284  // Fail incompatible versions
285  return false;
286  }
287  loadData(is, myInput);
288 
289  return true;
290  }
291 
292  int64 getInput() const { return myInput; }
293  void setInput(int64 val) { myInput = val; }
294  int64 opInput(const SOP_NodeVerb::CookParms &cookparms) const
295  {
296  SOP_Node *thissop = cookparms.getNode();
297  if (!thissop) return getInput();
298  int64 result;
299  OP_Utils::evalOpParm(result, thissop, "input", cookparms.getCookTime(), 0);
300  return result;
301  }
302 
303 private:
304  int64 myInput;
305 
306 };
void getParmValue(exint idx, UT_Matrix2D &value) const
static void loadData(UT_IStream &is, UT_Vector3D &v)
static void loadData(UT_IStream &is, bool &v)
SOP_Node * getNode() const
Definition: SOP_NodeVerb.h:492
T & z(void)
Definition: UT_Vector4.h:372
void getParmValue(exint idx, UT_Matrix3D &value) const
static void saveData(std::ostream &os, UT_Matrix4D v)
static void loadData(UT_IStream &is, UT_StringHolder &v)
void setParmValue(exint idx, const UT_Matrix4D &value)
static void saveData(std::ostream &os, UT_StringHolder s)
static void saveData(std::ostream &os, UT_Matrix3D v)
static void saveData(std::ostream &os, UT_Vector3D v)
exint bread(int32 *buffer, exint asize=1)
fpreal getTime() const
Definition: OP_Context.h:34
const GLdouble * v
Definition: glcorearb.h:836
static void saveData(std::ostream &os, fpreal64 v)
T & x(void)
Definition: UT_Vector2.h:284
virtual const char * getParmName(exint fieldnum) const
An output stream object that owns its own string buffer storage.
void getParmValue(exint idx, UT_StringHolder &value) const
const UT_WorkBuffer & str() const
Returns a read-only reference to the underlying UT_WorkBuffer.
void setParmValue(exint idx, const PRM_DataItemHandle &value)
void setParmValue(exint idx, const UT_SharedPtr< UT_Ramp > &value)
SYS_FORCE_INLINE T & x(void)
Definition: UT_Vector3.h:581
static PRM_DataItemHandle parseBinary(const char *type, UT_IStream &is)
static void saveData(std::ostream &os, UT_Matrix2D v)
virtual void loadFromOpSubclass(const LoadParms &loadparms)
static void loadData(UT_IStream &is, UT_Matrix4D &v)
SYS_FORCE_INLINE T & z(void)
Definition: UT_Vector3.h:585
long long int64
Definition: SYS_Types.h:106
static void loadData(UT_IStream &is, UT_Vector2D &v)
void getParmValue(exint idx, fpreal &value) const
virtual void copyFrom(const SOP_NodeParms *src)
void setParmValue(exint idx, const fpreal &value)
static void loadData(UT_IStream &is, int64 &v)
exint length() const
virtual ParmType getParmType(exint fieldnum) const
char * findChar(int c) const
Find first occurrance of character. Returns NULL upon failure.
Definition: UT_String.h:550
void getParmValue(exint idx, exint &value) const
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
void buildFromOp(const OP_Node *node, fpreal time, DEP_MicroNode *depnode)
void save(std::ostream &os) const
bool load(UT_IStream &is)
static void saveData(std::ostream &os, bool v)
void getParmValue(exint idx, UT_SharedPtr< UT_Ramp > &value) const
static void saveData(std::ostream &os, int64 v)
void setParmValue(exint idx, const UT_Vector3D &value)
GLboolean * data
Definition: glcorearb.h:130
void setParmValue(exint idx, const UT_Vector4D &value)
void doGetParmValue(exint idx, T &value) const
int int32
Definition: SYS_Types.h:34
T & y(void)
Definition: UT_Vector4.h:370
void setParmValue(exint idx, const UT_Matrix2D &value)
static void loadData(UT_IStream &is, fpreal64 &v)
void saveBinary(std::ostream &os) const
Save string to binary stream.
Definition: UT_String.h:294
DEP_MicroNode * depnode() const
Definition: SOP_NodeVerb.h:111
void getParmValue(exint idx, UT_Matrix4D &value) const
virtual exint getNumParms() const
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &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_Vector4I &v)
static void saveData(std::ostream &os, UT_Vector2D v)
virtual short * getInput(int size)
int64 getInput() const
void getParmValue(exint idx, UT_Vector4D &value) const
void doSetParmValue(exint idx, const T &value)
static void loadData(UT_IStream &is, UT_Vector2I &v)
static void loadData(UT_IStream &is, UT_Vector4D &v)
Utility class for containing a color ramp.
Definition: UT_Ramp.h:84
static void loadData(UT_IStream &is, PRM_DataItemHandle &v)
void setParmValue(exint idx, const UT_StringHolder &value)
static void saveData(std::ostream &os, UT_Vector4D v)
GLuint GLfloat * val
Definition: glcorearb.h:1607
void setParmValue(exint idx, const UT_Vector2D &value)
void setParmValue(exint idx, const exint &value)
#define SOP_API
Definition: SOP_API.h:10
void getParmValue(exint idx, UT_Vector2D &value) const
static void saveData(std::ostream &os, PRM_DataItemHandle s)
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
static void loadData(UT_IStream &is, UT_Vector3I &v)
void setInput(int64 val)
GLboolean r
Definition: glcorearb.h:1221
static void loadData(UT_IStream &is, UT_Matrix3D &v)
T & w(void)
Definition: UT_Vector4.h:374
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
void getParmValue(exint idx, UT_Vector3D &value) const
void getParmValue(exint idx, PRM_DataItemHandle &value) const
const OP_Context & context() const
Definition: SOP_NodeVerb.h:109
void setParmValue(exint idx, const UT_Matrix3D &value)
bool operator==(const SOP_SwitchParms &src) const
SYS_FORCE_INLINE bool isstring() const
static void loadData(UT_IStream &is, UT_Matrix2D &v)
int64 opInput(const SOP_NodeVerb::CookParms &cookparms) const
GLenum src
Definition: glcorearb.h:1792