HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VOP_Bind.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: VOP Library (C++)
7  *
8  */
9 
10 #ifndef __VOP_Bind_h__
11 #define __VOP_Bind_h__
12 
13 #include "VOP_API.h"
14 #include "VOP_ParameterBase.h"
15 
17 
19 {
20 public:
21  static OP_Node *myConstructor(OP_Network *net,
22  const char *name,
23  OP_Operator *entry);
24  static PRM_Template *buildTemplates(const VOP_Language *language);
25 
26  void initializeNode() override;
27 
28  const VOP_Bind *castToBind() const override { return this; }
29  VOP_Bind *castToBind() override { return this; }
30 
31  // Get the parm block information that will go in the dialog script
32  // for our VOPNET.
34  UT_String &parmdecl,
35  const VOP_Language *language,
36  const VOP_CodeGenContext &context
37  ) override;
38 
40  const char *parmname,
41  const VOP_TypeInfo &type_info,
42  UT_String &str,
43  bool expand_string,
44  const VOP_Language *language=0
45  ) override;
46 
47  const char *inputLabel(unsigned idx) const override;
48 
49  void setPARMNAME(const UT_String &str) override;
50  void setPARMLABEL(const UT_String &str);
51  void setPARMTYPEINDEX(int type) override;
52  void setPARMSTORAGE(int type) override;
53  void setPARMSTRINGTYPE(const char *style);
54  void setPARMOPFILTER(const char *filter);
55 
56  void PARMNAME(UT_String &str) const override;
57  void PARMPREFIX(UT_String &str) const override;
58  void PARMPOSTFIX(UT_String &str) const override;
59  void PARMLABEL(UT_String &str) const override;
60  int PARMTYPEINDEX() const override;
61  void PARMTYPENAME(
62  UT_String &type_name) const override;
63 
64  bool isParmVisible() const override;
65  void copySettingsFrom(
66  VOP_ParmGenerator *pvop) override;
68  const PI_EditScriptedParm *parm
69  ) override;
70 
71  /// Bind VOP represents (and can be translated directly to)
72  /// the USD Primvar Reader shader primitive.
73  bool translatesDirectlyToUSD() const override
74  { return true; }
75 
76 protected:
77  VOP_Bind(OP_Network *parent, const char *name,
78  OP_Operator *entry);
79  ~VOP_Bind() override;
80 
81  bool updateParmsFlags() override;
82 
83  // Override cook method just so we can set our warnings properly.
84  bool USEASPARMDEFINER() const override;
85  bool USEOWNEXPORTCONTEXT() const override;
87  ) const override;
88  int UNIFORM() const override;
89  int USEBOUND() const override;
90  int EXPORTPARM() const override;
92  UT_StringArray &context_names
93  ) const override;
95  void MENUCHOICES(UT_String &str) const override;
96  void CALLBACKSTR(UT_String &str) const;
97  void HELPTEXTSTR(UT_String &str) const;
98  int INVISIBLE() const;
99  int JOINNEXT() const;
100  int SHOWLABEL() const;
101  int IRANGE(int index) const;
102  float FRANGE(int index) const;
103 
104  bool needsInput() override;
105 
106  // Build the code to be output when useBound() is true but the parameter
107  // is not actually bound:
108  void getUnboundCode(UT_String &codestr,
109  const VOP_CodeGenContext &context
110  ) override;
111 
113  UT_String &parm_decl,
114  const VOP_CodeGenContext &codegen_ctx,
115  const VOP_Language *language=NULL,
116  bool export_parms=false) override;
117 
118  // Determines based on the parm index if the PARMNAME may be changed
119  // when this parm is changed.
121  int pidx) const override;
122 
124  VOP_TypeInfo &type_info,
125  int idx) override;
127  unsigned idx,
128  VOP_VopTypeArray &voptypes) override;
129 
130 private:
131  bool allowMenu(int parmtype) const;
132 
133  // Store the index of the Bind Name and Parameter Type parameters.
134  static int theParmNameParmIndex;
135  static int theParmTypeParmIndex;
136 };
137 
138 #endif
Reprsents a language for which VOPs can generate source code.
Definition: VOP_Language.h:29
bool translatesDirectlyToUSD() const override
Definition: VOP_Bind.h:73
virtual bool needsInput()=0
virtual bool isParmVisible() const =0
virtual int UNIFORM() const =0
virtual void PARMNAME(UT_String &str) const =0
virtual void copySettingsFrom(VOP_ParmGenerator *pvop)
Copy settings from a source parameter generator.
virtual void getAllowedInputTypesSubclass(unsigned idx, VOP_VopTypeArray &voptypes)
virtual bool getParmConstantString(const char *parmname, const VOP_TypeInfo &type_info, UT_String &str, bool expand_string, const VOP_Language *l=0)
Get the constant code that encodes the value of the node parameter.
VOP_Bind * castToBind() override
Definition: VOP_Bind.h:29
const VOP_Bind * castToBind() const override
Definition: VOP_Bind.h:28
bool updateParmsFlags() override
virtual const char * inputLabel(unsigned idx) const
virtual void copyDefaultValuesFrom(const PI_EditScriptedParm *parm)
void initializeNode() override
virtual bool SHOULDHAVECORRESPONDINGCONNECTOR() const
virtual bool USEOWNEXPORTCONTEXT() const
virtual void getInputTypeInfoSubclass(VOP_TypeInfo &type_info, int idx)
virtual void PARMLABEL(UT_String &str) const =0
virtual void PARMPREFIX(UT_String &str) const
virtual void EXPORTSHADERCONTEXTS(UT_StringArray &context_names) const
virtual void setPARMTYPEINDEX(int type)
#define VOP_API
Definition: VOP_API.h:10
virtual int PARMTYPEINDEX() const =0
virtual void getParameterDeclaration(UT_String &parmdecl, const VOP_Language *language, const VOP_CodeGenContext &context)
The parameter variable declaration using the syntax of a given language.
constexpr std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size(){return subtype_count< typename std::tuple_element< I, T >::type >::value+tuple_type_size< T, I+1 >);}template< typename T > struct type_count< T, typename std::enable_if< is_tuple_like< T >::value >::type >{static constexpr int value{tuple_type_size< T, 0 >)};};template< typename T > struct subtype_count{static constexpr int value{is_mutable_container< T >::value?expected_max_vector_size:type_count< T >::value};};template< typename T, typename Enable=void > struct type_count_min{static const int value{0};};template< typename T >struct type_count_min< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_tuple_like< T >::value &&!is_wrapper< T >::value &&!is_complex< T >::value &&!std::is_void< T >::value >::type >{static constexpr int value{type_count< T >::value};};template< typename T > struct type_count_min< T, typename std::enable_if< is_complex< T >::value >::type >{static constexpr int value{1};};template< typename T >struct type_count_min< T, typename std::enable_if< is_wrapper< T >::value &&!is_complex< T >::value &&!is_tuple_like< T >::value >::type >{static constexpr int value{subtype_count_min< typename T::value_type >::value};};template< typename T, std::size_t I >constexpr typename std::enable_if< I==type_count_base< T >::value, int >::type tuple_type_size_min(){return 0;}template< typename T, std::size_t I > constexpr typename std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size_min(){return subtype_count_min< typename std::tuple_element< I, T >::type >::value+tuple_type_size_min< T, I+1 >);}template< typename T > struct type_count_min< T, typename std::enable_if< is_tuple_like< T >::value >::type >{static constexpr int value{tuple_type_size_min< T, 0 >)};};template< typename T > struct subtype_count_min{static constexpr int value{is_mutable_container< T >::value?((type_count< T >::value< expected_max_vector_size)?type_count< T >::value:0):type_count_min< T >::value};};template< typename T, typename Enable=void > struct expected_count{static const int value{0};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_wrapper< T >::value &&!std::is_void< T >::value >::type >{static constexpr int value{1};};template< typename T > struct expected_count< T, typename std::enable_if< is_mutable_container< T >::value >::type >{static constexpr int value{expected_max_vector_size};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&is_wrapper< T >::value >::type >{static constexpr int value{expected_count< typename T::value_type >::value};};enum class object_category:int{char_value=1, integral_value=2, unsigned_integral=4, enumeration=6, boolean_value=8, floating_point=10, number_constructible=12, double_constructible=14, integer_constructible=16, string_assignable=23, string_constructible=24, other=45, wrapper_value=50, complex_number=60, tuple_value=70, container_value=80,};template< typename T, typename Enable=void > struct classify_object{static constexpr object_category value{object_category::other};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, char >::value &&std::is_signed< T >::value &&!is_bool< T >::value &&!std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::integral_value};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&std::is_unsigned< T >::value &&!std::is_same< T, char >::value &&!is_bool< T >::value >::type >{static constexpr object_category value{object_category::unsigned_integral};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_same< T, char >::value &&!std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::char_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_bool< T >::value >::type >{static constexpr object_category value{object_category::boolean_value};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_floating_point< T >::value >::type >{static constexpr object_category value{object_category::floating_point};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&std::is_assignable< T &, std::string >::value >::type >{static constexpr object_category value{object_category::string_assignable};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&(type_count< T >::value==1)&&std::is_constructible< T, std::string >::value >::type >{static constexpr object_category value{object_category::string_constructible};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::enumeration};};template< typename T > struct classify_object< T, typename std::enable_if< is_complex< T >::value >::type >{static constexpr object_category value{object_category::complex_number};};template< typename T > struct uncommon_type{using type=typename std::conditional<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&!std::is_constructible< T, std::string >::value &&!is_complex< T >::value &&!is_mutable_container< T >::value &&!std::is_enum< T >::value, std::true_type, std::false_type >::type;static constexpr bool value=type::value;};template< typename T >struct classify_object< T, typename std::enable_if<(!is_mutable_container< T >::value &&is_wrapper< T >::value &&!is_tuple_like< T >::value &&uncommon_type< T >::value)>::type >{static constexpr object_category value{object_category::wrapper_value};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::number_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&!is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::integer_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::double_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< is_tuple_like< T >::value &&((type_count< T >::value >=2 &&!is_wrapper< T >::value)||(uncommon_type< T >::value &&!is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value)||(uncommon_type< T >::value &&type_count< T >::value >=2))>::type >{static constexpr object_category value{object_category::tuple_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_mutable_container< T >::value >::type >{static constexpr object_category value{object_category::container_value};};template< typename T, enable_if_t< classify_object< T >::value==object_category::char_value, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"CHAR";}template< typename T, enable_if_t< classify_object< T >::value==object_category::integral_value||classify_object< T >::value==object_category::integer_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"INT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::unsigned_integral, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"UINT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::floating_point||classify_object< T >::value==object_category::number_constructible||classify_object< T >::value==object_category::double_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"FLOAT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::enumeration, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"ENUM";}template< typename T, enable_if_t< classify_object< T >::value==object_category::boolean_value, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"BOOLEAN";}template< typename T, enable_if_t< classify_object< T >::value==object_category::complex_number, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"COMPLEX";}template< typename T, enable_if_t< classify_object< T >::value >=object_category::string_assignable &&classify_object< T >::value<=object_category::other, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"TEXT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::container_value||classify_object< T >::value==object_category::wrapper_value, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value==1, detail::enabler >=detail::dummy >inline std::string type_name(){return type_name< typename std::decay< typename std::tuple_element< 0, T >::type >::type >);}template< typename T, std::size_t I >inline typename std::enable_if< I==type_count_base< T >::value, std::string >::type tuple_name(){return std::string{};}template< typename T, std::size_t I >inline typename std::enable_if<(I< type_count_base< T >::value), std::string >::type tuple_name(){auto str=std::string{type_name< typename std::decay< typename std::tuple_element< I, T >::type >::type >)}+ ','+tuple_name< T, I+1 >);if(str.back()== ',') str.pop_back();return str;}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler > > std::string type_name()
Recursively generate the tuple type name.
Definition: CLI11.h:1729
virtual int USEBOUND() const
virtual void MENUCHOICES(UT_String &str) const
virtual void getUnboundCode(UT_String &codestr, const VOP_CodeGenContext &context)
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual void PARMPOSTFIX(UT_String &str) const
virtual bool USEASPARMDEFINER() const =0
virtual void setPARMSTORAGE(int type)
GLuint index
Definition: glcorearb.h:786
virtual void getParmDeclarationCode(UT_String &parm_decl, const VOP_CodeGenContext &codegen_ctx, const VOP_Language *language=NULL, bool export_parms=false)
virtual void PARMTYPENAME(UT_String &type_name) const
virtual void setPARMNAME(const UT_String &str)
type
Definition: core.h:1059
virtual bool getParmCanAffectParmName(int pidx) const =0
virtual int EXPORTPARM() const
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297