9 #ifndef __PDG_TYPE_REGISTRY_H__
10 #define __PDG_TYPE_REGISTRY_H__
33 (int)PDG_RegistrationType::eCount>
46 template <
typename ClassType,
typename... Args>
52 return registerSimpleType<PDG_WorkItemDataType, ClassType>(errors,
name,
53 std::forward<Args>(
args)...);
57 template <
typename ClassType,
typename... Args>
63 return registerSimpleType<PDG_NodeCallbackType, ClassType>(errors,
name,
64 std::forward<Args>(
args)...);
68 template <
typename ClassType,
typename... Args>
74 return registerSimpleType<PDG_SchedulerType, ClassType>(errors,
name,
75 std::forward<Args>(
args)...);
79 template <
typename ClassType,
typename... Args>
85 return registerSimpleType<PDG_DependencyType, ClassType>(errors,
name,
86 std::forward<Args>(
args)...);
90 template <
typename ClassType,
typename... Args>
96 return registerSimpleType<PDG_ServiceType, ClassType>(errors,
name,
97 std::forward<Args>(
args)...);
101 template <
typename ClassType>
107 return handleErrors(registerCustomDependency<ClassType>(
112 template <
typename ClassType>
116 bool compatible =
true,
117 bool make_default =
false)
120 auto data_type = handleErrors(registerCustomWorkItemData<ClassType>(
126 setDefaultWorkItemDataType(data_type);
128 if (compatible && myDefaultWorkItemDataType)
135 template <
typename ClassType>
143 return handleErrors(registerCustomScheduler<ClassType>(
144 errors, name, label, parm_category, node_category,
150 template <
typename ClassType>
159 return handleErrors(registerCustomScheduler<ClassType>(
160 errors, name, label, parm_category, node_category,
173 return handleErrors(registerCustomService<PDG_Service>(
180 template <
typename ClassType>
189 auto* new_type = registerCustomNodeCallback<ClassType>(
194 return handleErrors(new_type, errors);
199 template <
typename ClassType>
208 auto* new_type = registerCustomNodeCallback<ClassType>(
213 return handleErrors(new_type, errors);
218 template <
typename ClassType>
226 auto* new_type = registerCustomNodeCallback<ClassType>(
231 return handleErrors(new_type, errors);
251 {
return myDefaultWorkItemDataType; }
253 { myDefaultWorkItemDataType =
type; }
257 {
return myServiceSchedulerType; }
259 { myServiceSchedulerType =
type; }
263 {
return myInProcessSchedulerType; }
265 { myInProcessSchedulerType =
type; }
277 {
return &myCustomHandlers;}
281 {
return &myFileUtilities; }
296 void handleLogMessage(
302 template <
typename Type>
307 if (new_type || errors.
isEmpty())
PDG_DependencyType * registerDependency(const UT_StringHolder &name, const UT_StringHolder &label)
Utility method to register a custom C++-based external dependency.
GLuint GLsizei const GLchar * message
PDG_SchedulerType * inProcessSchedulerType() const
Gets/sets the in process scheduler type.
GLuint GLsizei const GLchar * label
PDG_NodeCallbackType * registerMapper(const UT_StringHolder &name, const UT_StringHolder &label, const UT_StringHolder &category, const PDG_NodeInterface &interface)
void setDefaultWorkItemDataType(PDG_WorkItemDataType *type)
#define SYS_VISIBILITY_EXPORT
PDG_SchedulerType * serviceSchedulerType() const
Gets/sets the service scheduler type.
SYS_FORCE_INLINE const char * buffer() const
PDG_FileUtils * fileUtils()
Returns the shared file utilities object.
PDGT_TypeErrorLevel
Error level typedef.
A regular node – default value.
PDG_WorkItemDataType * defaultWorkItemDataType() const
Gets/sets the default work item data type.
PDG_NodeCallbackType * registerPartitioner(const UT_StringHolder &name, const UT_StringHolder &label, const UT_StringHolder &category, const PDG_NodeInterface &interface, PDG_NodeSubtype sub=PDG_NodeSubtype::eRegular)
ImageBuf OIIO_API sub(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
PDG_SchedulerType * registerScheduler(const UT_StringHolder &name, const UT_StringHolder &label, const UT_StringHolder &parm_category, const UT_StringHolder &node_category, const PDG_NodeInterface &interface)
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.
void setServiceSchedulerType(PDG_SchedulerType *type)
SYS_FORCE_INLINE bool isEmpty() const
bool addParentType(BaseType *type, BaseType *parent, UT_WorkBuffer &errors)
Directly adds a parent type, if it's valid.
PDG_ServiceType * registerCustomService(UT_WorkBuffer &errors, const UT_StringHolder &name, Args &&...args)
Registers a function-based service type.
GLuint const GLchar * name
PDG_DependencyType * registerCustomDependency(UT_WorkBuffer &errors, const UT_StringHolder &name, Args &&...args)
Registers a function-based dependency type.
PDG_NodeCallbackType * registerProcessor(const UT_StringHolder &name, const UT_StringHolder &label, const UT_StringHolder &category, const PDG_NodeInterface &interface, PDG_NodeSubtype sub=PDG_NodeSubtype::eRegular)
PDG_NodeCallbackType * registerCustomNodeCallback(UT_WorkBuffer &errors, const UT_StringHolder &name, Args &&...args)
Registers a function-based node type.
PDG_CustomHandlers * customHandlers()
Returns the custom handlers table.
PDG_SchedulerType * registerCustomScheduler(UT_WorkBuffer &errors, const UT_StringHolder &name, Args &&...args)
Registers a function-based scheduler type.
PDG_SchedulerType * registerScheduler(const UT_StringHolder &name, const UT_StringHolder &label, const UT_StringHolder &parm_category, const UT_StringHolder &node_category)
Utility method to registers a C++-based scheduler node.
void setInProcessSchedulerType(PDG_SchedulerType *type)
const UT_StringHolder & localSchedulerTypeName() const
Returns the name of the local scheduler type.
**If you just want to fire and args
PDG_WorkItemDataType * registerCustomWorkItemData(UT_WorkBuffer &errors, const UT_StringHolder &name, Args &&...args)
Registers a function-based work item type.
PDG_NodeSubtype
Enumeration of node subtypes.
GLsizei GLenum GLenum * types
PDG_WorkItemDataType * registerWorkItemData(const UT_StringHolder &name, const UT_StringHolder &label, bool compatible=true, bool make_default=false)
Utility method to regiser a custom C++-based work item data.
PDG_ServiceType * registerService(const UT_StringHolder &name, const UT_StringHolder &label, const UT_StringHolder &commandline, bool internal)
SYS_VISIBILITY_EXPORT void registerPDGTypes(PDG_TypeRegistry *)
Errors are only logged if a type fails to load.