15 #ifndef __PI_ResourceManager_H__
16 #define __PI_ResourceManager_H__
41 class pi_OpHandleBinding;
42 class pi_OpSelectorBinding;
44 namespace PI_PythonState
50 namespace PI_PythonHandle
58 #define PI_NO_TEMPLATE_FOR_HANDLE -2
59 #define PI_INVALID_OP_PARM -3
60 #define PI_INVALID_PI_PARM -4
61 #define PI_BINDING_EXISTS -5
62 #define PI_INVALID_OP_FOR_PI -6
79 {
return (
this == &i); }
84 friend class pi_OpHandleBinding;
100 {
return myPIDescription; }
102 {
return myDefaultSettings; }
106 {
return myBindings; }
108 {
return (
this == &i); }
116 friend class pi_OpHandleBinding;
133 {
return myDescription; }
141 {
return myPrimMask; }
143 {
return myOpInput; }
145 {
return myOpInputReq; }
147 {
return myAllowDrag; }
149 {
return myAstSelAll; }
151 {
return myExtraInfo; }
153 {
return (
this == &i); }
167 friend class pi_OpSelectorBinding;
185 bool containsState(
const char *
name,
187 unsigned netmask)
const;
188 bool containsHandle(
const char *name)
const;
189 bool containsOpHandleLink(
const char *name)
const;
190 bool containsSelector(
const char *name)
const;
203 const char *network_type)
const;
209 const char *type)
const;
212 const char *type)
const;
215 void rebuildVolatileKeys();
223 getViewerStateRegisterStatus(
224 const char* state_name,
PI_ViewerType viewer_type,
const char* type)
const;
227 virtual void fireResourceEvent(
233 bool validStateTemplateName(
const char* name)
const;
239 virtual bool isRegisteredViewerState(
const char* name)
const;
242 virtual PI_PythonState::Template
const * viewerStateTemplate(
const char * state_name)
const;
243 virtual PI_PythonState::Template * viewerStateTemplate(
const char * state_name) ;
248 virtual bool hasDualStateSupport(
OP_OpTypeId op_typeid)
const;
252 virtual bool isRegisteredViewerHandle(
const char* name)
const;
254 virtual PI_PythonHandle::Template
const*
255 viewerHandleTemplate(
const char* handle_name)
const;
262 int unbind(
OP_Operator *op,
const char *pidescription,
265 const char *pidescription,
268 const char *default_settings);
272 const char *pidescription,
273 const char *default_settings);
274 int bindScriptOp(
OP_Operator *op,
const char *piname,
275 const char *pidescription,
278 const char *default_settings);
282 virtual bool bindOperatorToViewerState(
const char* state_name,
OP_Operator* op);
290 bool operatorStateMandatory(
const char* op_name,
const char* op_type)
const;
295 const char *seldescription);
335 int bindSelector(
OP_Operator *op,
const char *sname,
336 const char *seldescription,
337 const char *prompt,
const char *opparm,
338 int opinput,
int opinputreq,
339 const char *primmask,
int allowdrag,
340 const char *menu,
int astselall,
341 const char *extrainfo,
bool fromScriptOp);
352 void getChannelNameFromParmAndVec(
UT_String &chan,
356 int checkForPIName(
const char *pi_name,
357 const char *pi_parm )
const;
361 bool display_warning =
true)
const;
365 virtual void findVolatileKeys(
const char *volatile_hotkey_name,
369 virtual void updateViewports(
int id,
const char *opname,
370 bool open_only =
false)
const;
374 PI_PITemplate *getOpHandleLinkTemplate(
const char *pi_name)
const;
386 bool isPIEthereal(
const char *piname,
387 bool *isfloat = 0)
const;
394 void ensureStatesExistForAllOperators(
const char *net_type_name);
395 virtual void ensureStatesExistForAllOperators(
PI_NetworkType net_type);
398 static bool getViewerType(
const char *viewer_type_token,
405 static bool getNetworkType(
const char *network_type_name,
411 static PI_NetworkType getFirstNetworkType(
unsigned int network_mask);
414 const char *op_Parm_name,
415 int vec_idx,
int *parm_idx);
418 int writeBindingsFile(
const char *fname)
const;
423 bool okay_to_use_last_settings)
const;
425 virtual void removePISettingsFromTables(
OP_Operator &op_type);
430 void recordPISettings(
const char *pi_description,
433 const char *settings);
442 void registerOpHandleBindings();
446 char const* stateToCreate()
const;
450 void setPythonResourceSupport(
void* res_support);
451 void* getPythonResourceSupport();
454 static void startParmsCache();
455 static void stopParmsCache();
459 static void getParmsCacheBehaviour(
bool &set_keys,
461 bool &append_scope );
464 void saveStateToCreate(
char const*
state);
466 static int cacheParms();
469 static void setParmsCacheBehaviour(
bool set_keys,
bool do_scope,
473 {
return theHideLockedHandleParts; }
475 { theHideLockedHandleParts = hide; }
477 {
return theScopeChannelsOnKey; }
479 { theScopeChannelsOnKey = scope; }
481 {
return theAddScopedChannels; }
483 { theAddScopedChannels =
add; }
485 {
return theOpenChannelEditorOnScope; }
487 { theOpenChannelEditorOnScope = do_open; }
488 static void getChannelScopeCommandPrefix(
UT_String &str );
497 PI_OpPIKey(
const char *pi_name_in_setting_table,
const char *pi_type,
499 myPINameInSettingTable(pi_name_in_setting_table),
506 return myPINameInSettingTable == o.myPINameInSettingTable &&
514 SYShashCombine(hash, myOpId);
520 int opId()
const {
return myOpId; }
541 void installCommands();
542 void registerOpHandleLinks();
543 void registerCop2HandleLinks();
544 void registerOpHandleConstructors();
545 void registerSelectors();
546 void registerSelectorConstructors();
549 bool isValidPiParmName(
const UT_String &pi_name,
551 void loadHandle(CPP_Manager &cppman,
OP_Operator *op,
552 pi_OpHandleBinding *binding);
553 void loadSelector(CPP_Manager &cppman,
556 pi_OpSelectorBinding *binding);
557 void loadOperator(CPP_Manager &cppman,
559 void loadOperator(CPP_Manager &cppman,
562 pi_OpHandleBinding *hbinding,
563 pi_OpSelectorBinding *sbinding);
576 static OP_ERROR savePIResourceManagerCallback(std::ostream &os,
578 OP_ERROR saveSettings(std::ostream &os)
const;
581 OP_ERROR save(std::ostream &os)
const;
587 const char *description)
const;
590 const char *description);
606 char const* pi_name)
const;
628 void* myCurrentPythonSupport =
nullptr;
int operator==(const PI_BindingSelectorInfo &i) const
int operator==(const PI_BindingHandleInfo &i) const
const UT_String & getPrompt() const
UT_StringHolder piNameInSettingTable() const
const PI_OpHandleLinkMap & getOpHandleLinks() const
UT_Array< PI_SaveCallbackInfo > mySaveCallbacks
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
PI_HandleTemplateMap myHandles
static bool theOpenChannelEditorOnScope
const PI_SelectorTemplateMap & getSelectors() const
static UT_ValArray< OP_Node * > ourParmNodes
UT_StringArray myBuiltinOpHandleNames
UT_SymbolMap< pi_OpHandleBinding * > myOpHandleBindings
PI_API void PIcreateResourceManager(bool verbose=true)
static void setScopeChannelsOnKey(bool scope)
PI_OpHandleLinkMap myOpHandleLinks
bool getAstSelAll() const
static bool getAddScopedChannels()
SYS_HashType hash() const
PI_OpPIKey(const char *pi_name_in_setting_table, const char *pi_type, int op_id)
std::size_t SYS_HashType
Define the type for hash values.
PI_SettingList * mySettings
const PI_SettingList & getDefaultSettings() const
static void setOpenChannelEditorOnScope(bool do_open)
PI_API bool PIresourceManagerExists()
UT_StringHolder piType() const
void(* PI_SaveCallback)(void *data)
PI_SelectorTemplateMap mySelectors
const UT_String & getPIDescription() const
static bool theHideLockedHandleParts
bool operator==(const PI_OpPIKey &o) const
GLint GLint GLsizei GLint GLenum GLenum type
static bool theScopeChannelsOnKey
UT_SymbolMap< PI_NetworkType > myNetworkTypeTable
static UT_IntArray ourParmVecIndices
static bool ourScopeParmChannels
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.
const UT_String & getOpParm() const
bool getOpInputReq() const
size_t operator()(const PI_OpPIKey &pk) const
static bool getHideLockedHandleParts()
const UT_String & getPrimMask() const
std::pair< PI_SaveCallback, void * > PI_SaveCallbackInfo
static bool getOpenChannelEditorOnScope()
static void setAddScopedChannels(bool add)
const UT_String & getExtraInfo() const
GLuint const GLchar * name
SYS_DECLARE_LEGACY_TR(GU_Detail)
GLenum GLenum GLsizei void * table
static bool getScopeChannelsOnKey()
PI_API PI_ResourceManager * PIgetResourceManager()
static void setHideLockedHandleParts(bool hide)
GA_API const UT_StringHolder parms
static bool theAddScopedChannels
const UT_String & getPIName() const
__hostdev__ constexpr T pi()
Pi constant taken from Boost to match old behaviour.
const PI_HandleTemplateMap & getHandles() const
const PI_BindingParmArray & getBindings() const
const UT_String & getMenu() const
static bool ourSetKeyOnParms
UT_StringHolder myStateBeingCreated
UT_Map< PI_OpPIKey, OpPISettingInfo, PI_OpPIKey::Hasher > myPISettingsForOps
const UT_String & getDescription() const
UT_SymbolMap< pi_OpSelectorBinding * > myOpSelectorBindings
static UT_ValArray< PRM_Parm * > ourParms
ImageBuf OIIO_API add(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
int operator==(const PI_BindingParmInfo &i) const
bool getAllowDrag() const
static bool ourAppendToScope
const UT_String & getName() const
UT_StringMap< PI_SettingList * > myLastPISettings
const UT_String & getPIParm() const
const UT_String & getOpParm() const