HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UN_UniCategory.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: UN_UniCategory.h ( UN Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UN_UniCategory_h__
13 #define __UN_UniCategory_h__
14 
15 #include "UN_API.h"
16 #include "UN_NodeTypeRegistry.h"
17 #include "UN_ParmTypeRegistry.h"
18 #include "UN_PortTypeRegistry.h"
19 #include <UNI/UNI_Category.h>
20 #include <UT/UT_NonCopyable.h>
21 
22 
23 // ============================================================================
24 /// The category of nodes, node types, and port types that work together.
25 ///
26 /// It groups these concepts into one umbrella, isolating them from other
27 /// incompatible nodes and types. It allows presenting available node types
28 /// and determine connectability of node ports, avoiding type collisions, etc.
29 ///
31 {
32 public:
33  /// @{ Constructor and destructor
35  const UT_StringRef &label = UT_StringRef() );
36  ~UN_UniCategory() override;
38  /// @}
39 
40 
41  /// @{ Returns the node type registry for this category.
42  const UN_NodeTypeRegistry & nodeTypeRegistry() const
43  { return myNodeTypeRegistry; }
45  { return myNodeTypeRegistry; }
46  /// @}
47 
48  /// @{ Returns the node port type registry for this category.
50  { return myPortTypeRegistry; }
52  { return myPortTypeRegistry; }
53  /// @}
54 
55  /// @{ Returns the node parameter type registry for this category.
57  { return myParmTypeRegistry; }
59  { return myParmTypeRegistry; }
60  /// @}
61 
62  /// Sets the node type name of the generic subnet.
64  { mySubnetNodeTypeName = name; }
65 
66  /// @{ Required overrides from the base class.
67  UT_StringArray nodeTypeNames() const override;
68  bool isValidNodeType( const UT_StringRef &name ) const override;
69  bool isHiddenNodeType( const UT_StringRef &name ) const override;
70  UT_StringHolder nodeTypeLabel(const UT_StringRef &type_name ) const override;
71  UT_StringHolder nodeTypeIcon(const UT_StringRef &type_name) const override;
73  const UT_StringRef &type_name) const override;
74 
76  const UT_StringRef &type_name ) const override;
77  UT_StringHolder subnetNodeTypeName() const override;
79  const UT_StringRef &type_name) const override;
81  const UT_StringRef &type_name) const override;
82  ToolInfo nodeTypeToolInfo(
83  const UT_StringRef &type_name ) const override;
85  getNodeTypeEventNotifier() override;
86  /// @}
87 
88 private:
89  // TODO: FIXME:
90  // - do node types hold pointers to parm and port types? If so,
91  // they need to be created last and deleted first.
92  // Ie, the member ordering would matter.
93 
94  /// A set of all node parameter types known in this category.
95  UN_ParmTypeRegistry myParmTypeRegistry;
96 
97  /// A set of all port types known in this category.
98  UN_PortTypeRegistry myPortTypeRegistry;
99 
100  /// A set of all node types known in this category.
101  // If node types reference port and parm types, they need to be created
102  // last and destroyed first. Thus node type registry is the last member.
103  UN_NodeTypeRegistry myNodeTypeRegistry;
104 
105  /// The name of the node type used for generic subnets.
106  UT_StringHolder mySubnetNodeTypeName;
107 };
108 
109 
110 #endif
111 
const UN_PortTypeRegistry & portTypeRegistry() const
Returns the node port type registry for this category.
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
const UN_ParmTypeRegistry & parmTypeRegistry() const
Returns the node parameter type registry for this category.
UN_ParmTypeRegistry & parmTypeRegistry()
Returns the node parameter type registry for this category.
virtual ToolInfo nodeTypeToolInfo(const UT_StringRef &type_name) const =0
Returns information about a default shelf tool for the given node type.
virtual UT_StringArray nodeTypeNames() const =0
Returns the list of known node type names in this category.
virtual bool shouldGenerateToolForNodeType(const UT_StringRef &type_name) const =0
void setSubnetNodeTypeName(const UT_StringRef &name)
Sets the node type name of the generic subnet.
#define UN_API
Definition: UN_API.h:11
virtual bool isValidNodeType(const UT_StringRef &type_name) const =0
Returns true if the given node type name is valid in this category.
UN_NodeTypeRegistry & nodeTypeRegistry()
Returns the node type registry for this category.
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 bool isHiddenNodeType(const UT_StringRef &type_name) const =0
Returns true if the given node type is hidden from the Tab menu.
virtual UT_NotifierImpl< const UNI_NodeTypeEvent & > & getNodeTypeEventNotifier()=0
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
UN_PortTypeRegistry & portTypeRegistry()
Returns the node port type registry for this category.
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual UT_StringHolder nodeTypeIcon(const UT_StringRef &type_name) const =0
Returns the name of the icon for the given node type.
virtual UT_StringArray childCategoryNames(const UT_StringRef &type_name) const =0
virtual UT_StringHolder nodeTypeLabel(const UT_StringRef &type_name) const =0
Returns the label of the given node type for the display in UI.
virtual UT_StringHolder subnetNodeTypeName() const =0
virtual UT_Array< UNI_Signature > nodeTypeSignatures(const UT_StringRef &type_name) const =0
Returns the list of function signature names node type offers.
const UT_StringHolder & name() const
Definition: UNI_Category.h:46
virtual UT_StringArray nodeTypeNamesInPrecedenceOrder(const UT_StringRef &type_name) const =0