13 #ifndef __PY_Callback_h__
14 #define __PY_Callback_h__
62 virtual
bool getDesktopOffice(const BM_View&
v,
int &desktop_id,
int &office_id) = 0;
63 virtual FUSE_Office *getOffice(const BM_View& v) = 0;
66 virtual
PY_PyObject *newSceneViewer(FUSE_Office &office,
bool convert_context_viewer=false) = 0;
85 PY_Callback(
void *python_callable_object,
bool new_ref =
false) noexcept
86 : PY_OpaqueObject(python_callable_object, new_ref)
87 , myExpressionCache(
nullptr)
93 : PY_OpaqueObject(callback)
94 , myExpressionCache(
nullptr)
103 : PY_OpaqueObject(std::forward<
PY_Callback>(callback))
104 , myExpressionCache(
nullptr)
110 std::forward<PY_Callback>(callback));
120 const char *kwargs_expression=NULL)
const;
126 const char *kwargs_expression=NULL)
const
129 call(result, args_expression, kwargs_expression);
135 const char *args_expression,
136 const char *kwargs_expression,
145 const char* args_expression,
146 const char* kwargs_expression,
147 const char* module_name,
149 PY_OpaqueObject& out_args,
150 PY_OpaqueObject& out_kwargs,
156 args_expression, kwargs_expression, module_name, out_args, out_kwargs, arg_handler);
163 desired_result_type);
169 const char* args_expression,
170 const char* kwargs_expression,
171 const char* module_name,
172 PY_OpaqueObject& out_args,
173 PY_OpaqueObject& out_kwargs,
179 args_expression, kwargs_expression, module_name, out_args, out_kwargs);
191 { myExpressionCache =
c; }
209 const char *args_expression,
210 const char *kwargs_expression,
211 const char *module_name,
212 PY_OpaqueObject& out_args,
213 PY_OpaqueObject& out_kwargs )
const;
215 PY_OpaqueObject evaluateExpression(
const char *expression,
PY_Result &
result)
const;
217 PY_OpaqueObject evaluateExpression(
218 const char *expression,
const char* module_name,
PY_Result &
result)
const;
virtual ~PY_CallbackHOM()
*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
PY_Callback & operator=(PY_Callback &&callback) noexcept
**But if you need a result
static void setHOM(PY_CallbackHOM *hom)
static PY_CallbackHOM * getHOM()
UT_StringMap< PY_CompiledCode * > myExpressionCache
PY_Result evaluateArgs(const char *args_expression, const char *kwargs_expression, const char *module_name, PY_OpaqueObject &out_args, PY_OpaqueObject &out_kwargs, ArgHandler arg_handler) const
PY_Callback(void *python_callable_object, bool new_ref=false) noexcept
PY_Callback(std::nullptr_t n) noexcept
PY_EvaluationContext myContext
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
std::function< T > UT_Function
PY_Callback & operator=(const PY_Callback &callback) noexcept
PY_OpaqueObject & operator=(const PY_OpaqueObject &opaque_object) noexcept
PY_Callback(const PY_Callback &callback) noexcept
PY_Result call(const char *args_expression, const char *kwargs_expression, const char *module_name, PY_Result::Type desired_result_type, PY_OpaqueObject &out_args, PY_OpaqueObject &out_kwargs, ArgHandler arg_handler) const
void setExpressionCache(PY_CallbackCompiledCodeCache *c)
**If you just want to fire and args
PY_Callback(PY_Callback &&callback) noexcept
UT_Function< void(PY_PyObject *args, PY_PyObject *kwargs)> ArgHandler
PY_Result call(const char *args_expression=NULL, const char *kwargs_expression=NULL) const
PY_PyObject * pyObject() const noexcept