15 #ifndef __PI_ResourceManager_H__
16 #define __PI_ResourceManager_H__
41 class pi_OpHandleBinding;
42 class pi_OpSelectorBinding;
44 namespace PI_PythonState
49 namespace PI_PythonHandle
57 #define PI_NO_TEMPLATE_FOR_HANDLE -2
58 #define PI_INVALID_OP_PARM -3
59 #define PI_INVALID_PI_PARM -4
60 #define PI_BINDING_EXISTS -5
61 #define PI_INVALID_OP_FOR_PI -6
78 {
return (
this == &i); }
83 friend class pi_OpHandleBinding;
99 {
return myPIDescription; }
101 {
return myDefaultSettings; }
105 {
return myBindings; }
107 {
return (
this == &i); }
115 friend class pi_OpHandleBinding;
132 {
return myDescription; }
140 {
return myPrimMask; }
142 {
return myOpInput; }
144 {
return myOpInputReq; }
146 {
return myAllowDrag; }
148 {
return myAstSelAll; }
150 {
return myExtraInfo; }
152 {
return (
this == &i); }
166 friend class pi_OpSelectorBinding;
184 bool containsState(
const char *
name,
186 unsigned netmask)
const;
187 bool containsHandle(
const char *name)
const;
188 bool containsOpHandleLink(
const char *name)
const;
189 bool containsSelector(
const char *name)
const;
202 const char *network_type)
const;
208 const char *type)
const;
211 const char *type)
const;
214 void rebuildVolatileKeys();
219 getViewerStateRegisterStatus(
220 const char* state_name,
PI_ViewerType viewer_type,
const char* type)
const;
223 virtual void fireResourceEvent(
229 bool validStateTemplateName(
const char* name)
const;
235 virtual bool isRegisteredViewerState(
const char* name)
const;
238 virtual PI_PythonState::Template
const * viewerStateTemplate(
const char * state_name)
const;
239 virtual PI_PythonState::Template * viewerStateTemplate(
const char * state_name) ;
246 virtual bool isRegisteredViewerHandle(
const char* name)
const;
248 virtual PI_PythonHandle::Template
const*
249 viewerHandleTemplate(
const char* handle_name)
const;
256 int unbind(
OP_Operator *op,
const char *pidescription,
259 const char *pidescription,
262 const char *default_settings);
266 const char *pidescription,
267 const char *default_settings);
268 int bindScriptOp(
OP_Operator *op,
const char *piname,
269 const char *pidescription,
272 const char *default_settings);
276 virtual bool bindOperatorToViewerState(
const char* state_name,
OP_Operator* op);
284 bool operatorStateMandatory(
const char* op_name,
const char* op_type)
const;
289 const char *seldescription);
329 int bindSelector(
OP_Operator *op,
const char *sname,
330 const char *seldescription,
331 const char *prompt,
const char *opparm,
332 int opinput,
int opinputreq,
333 const char *primmask,
int allowdrag,
334 const char *menu,
int astselall,
335 const char *extrainfo,
bool fromScriptOp);
346 void getChannelNameFromParmAndVec(
UT_String &chan,
350 int checkForPIName(
const char *pi_name,
351 const char *pi_parm )
const;
355 bool display_warning =
true)
const;
359 virtual void findVolatileKeys(
const char *volatile_hotkey_name,
363 virtual void updateViewports(
int id,
const char *opname,
364 bool open_only =
false)
const;
368 PI_PITemplate *getOpHandleLinkTemplate(
const char *pi_name)
const;
380 bool isPIEthereal(
const char *piname,
381 bool *isfloat = 0)
const;
388 void ensureStatesExistForAllOperators(
const char *net_type_name);
389 virtual void ensureStatesExistForAllOperators(
PI_NetworkType net_type);
392 static bool getViewerType(
const char *viewer_type_token,
399 static bool getNetworkType(
const char *network_type_name,
405 static PI_NetworkType getFirstNetworkType(
unsigned int network_mask);
408 const char *op_Parm_name,
409 int vec_idx,
int *parm_idx);
412 int writeBindingsFile(
const char *fname)
const;
417 bool okay_to_use_last_settings)
const;
419 virtual void removePISettingsFromTables(
OP_Operator &op_type);
424 void recordPISettings(
const char *pi_description,
427 const char *settings);
436 void registerOpHandleBindings();
440 char const* stateToCreate()
const;
444 void setPythonResourceSupport(
void* res_support);
445 void* getPythonResourceSupport();
448 static void startParmsCache();
449 static void stopParmsCache();
453 static void getParmsCacheBehaviour(
bool &set_keys,
455 bool &append_scope );
458 void saveStateToCreate(
char const* state);
460 static int cacheParms();
463 static void setParmsCacheBehaviour(
bool set_keys,
bool do_scope,
467 {
return theHideLockedHandleParts; }
469 { theHideLockedHandleParts = hide; }
471 {
return theScopeChannelsOnKey; }
473 { theScopeChannelsOnKey = scope; }
475 {
return theAddScopedChannels; }
477 { theAddScopedChannels =
add; }
479 {
return theOpenChannelEditorOnScope; }
481 { theOpenChannelEditorOnScope = do_open; }
482 static void getChannelScopeCommandPrefix(
UT_String &str );
491 PI_OpPIKey(
const char *pi_name_in_setting_table,
const char *pi_type,
493 myPINameInSettingTable(pi_name_in_setting_table),
500 return myPINameInSettingTable == o.myPINameInSettingTable &&
508 SYShashCombine(hash, myOpId);
514 int opId()
const {
return myOpId; }
535 void installCommands();
536 void registerOpHandleLinks();
537 void registerCop2HandleLinks();
538 void registerOpHandleConstructors();
539 void registerSelectors();
540 void registerSelectorConstructors();
543 bool isValidPiParmName(
const UT_String &pi_name,
545 void loadHandle(CPP_Manager &cppman,
OP_Operator *op,
546 pi_OpHandleBinding *binding);
547 void loadSelector(CPP_Manager &cppman,
550 pi_OpSelectorBinding *binding);
551 void loadOperator(CPP_Manager &cppman,
553 void loadOperator(CPP_Manager &cppman,
556 pi_OpHandleBinding *hbinding,
557 pi_OpSelectorBinding *sbinding);
570 static OP_ERROR savePIResourceManagerCallback(std::ostream &os,
572 OP_ERROR saveSettings(std::ostream &os)
const;
575 OP_ERROR save(std::ostream &os)
const;
581 const char *description)
const;
584 const char *description);
600 char const* pi_name)
const;
622 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
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)
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