HDK
|
#include <PDG_EvaluationContext.h>
Classes | |
class | AttribRecordScope |
Scoped block that records PDG attribute evaluations. More... | |
class | ItemScope |
Scoped setter of local work item. More... | |
class | StateScope |
Scoped reset of the thread-local context cooking/generation state. More... | |
Public Types | |
enum | State { eStateNone, eStateStatic, eStateDynamic, eStateCooking, eStateDirtying } |
Evaluation context state. More... | |
enum | EvaluationResult { eResultSuccess, eResultFailure, eResultAbort } |
Enumeration of python script evaluation results. More... | |
using | WorkItemCaster = UT_Function< PY_PyObject *(const PDG_WorkItem *)> |
Utility function type for converting a PDG_WorkItem* to a PY_PyObject. More... | |
Public Member Functions | |
PDG_EvaluationContext () | |
~PDG_EvaluationContext () | |
const PDG_WorkItem * | workItem () const |
Returns the context's active work item. More... | |
bool | isParent () const |
const PDG_Node * | activeNode () const |
Returns the active node for the the context. More... | |
State | state () const |
Returns the state of the context. More... | |
bool | hasParameterError () const |
Returns the parameter evaluation state of the context. More... | |
fpreal | evalTime () const |
Returns the current evaluation time of the context. More... | |
bool | isGenerating () const |
Returns true if the context is in a generating state. More... | |
bool | isCooking () const |
Returns true if the context is in a cooking state. More... | |
bool | isRuntime () const |
Returns true if the context is in a runtime state. More... | |
bool | isActive () const |
Returns true if the context is actively doing PDG work. More... | |
bool | isLocalize () const |
Returns true if the context should force file paths to be localized. More... | |
bool | canDirty (const PDG_WorkItem *work_item) const |
bool | canDirty (const PDG_Node *node) const |
bool | canDirty () const |
General version of the above method that can be called without a node. More... | |
void | recordAttribute (const UT_StringHolder &name) |
Static Public Member Functions | |
static void | builtinFunctions (UT_StringArray &functions) |
Returns the built-in functions that are available in the the context. More... | |
static void | setWorkItemCaster (const WorkItemCaster &caster) |
static void | setUsePython (bool use_python) |
static PY_EvaluationContext & | getExpressionContext () |
Returns the shared Python context in which expressions evaluated. More... | |
static PDG_EvaluationContext * | getContext () |
Returns the thread-local PDG_EvaluationContext instance. More... | |
static PDG_EvaluationContext * | getContext (int thread) |
static void | setGlobalSubItemIndex (int index, bool dirty) |
static void | setGlobalWorkItem (const PDG_WorkItem *work_item, bool dirty) |
static void | setGlobalJobWorkItem (PDG_WorkItem *work_item, const UT_StringHolder &node_name, const UT_StringHolder &scheduler_name) |
Sets the global active item for an out of process work item job. More... | |
static void | setTimeDependentAttribs (const UT_ArrayStringSet &names, bool dirty) |
static void | dirtyAllAttribs () |
Dirties all dependent attributes. More... | |
static bool | saveGlobalWorkItem (std::ostream &os) |
static bool | loadGlobalWorkItem (UT_IStream &is) |
static const PDG_WorkItem * | globalWorkItem (bool sub_item) |
static const PDG_WorkItem * | globalJobWorkItem (bool sub_item) |
static const UT_StringHolder & | globalNodeName () |
static const UT_StringHolder & | globalSchedulerName () |
static bool | useTimeDependentAttribs () |
Returns true if PDG attribute evaluation is time dependent, else false. More... | |
static bool | isTimeDependent (const UT_StringHolder &name) |
Returns true if the specified attribute is time dependent, else false. More... | |
static const PDG_WorkItem * | activeWorkItem (int thread) |
static bool | activeIsParent (int thread) |
Queries the thread local is-parent flag. More... | |
static bool | isLocalGenerating (int thread) |
Returns true if the thread local state is generating. More... | |
static bool | isLocalRuntime (int thread) |
Returns true if the thread local state is runtime. More... | |
static bool | isLocalActive (int thread) |
static bool | isLocalCookingPDG (int thread) |
static State | localState (int thread) |
Returns the current state of the thread local evaluation context. More... | |
static fpreal | localEvalTime (int thread) |
Returns the current evaluation time of the thread local context. More... | |
static const PDG_Node * | localActiveNode (int thread) |
Returns the thread-local active node. More... | |
static PDG_AttributeEvaluator * | createAttributeEvaluator (int thread, const char *name) |
Gets an attribute evaluator. More... | |
static void | setDict (int thread, PY_PyObject *locals) |
Sets the Python evaluation dictionary directly. More... | |
static PY_PyObject * | localDict (int thread) |
Returns the local Python dictionary object. More... | |
static void | updateDict (int thread, const UT_StringHolder &name, fpreal value) |
Sets or updates primitive values in the Python dictionary. More... | |
static void | updateDict (int thread, const UT_StringHolder &name, int value) |
static void | updateDict (int thread, const UT_StringHolder &name, const UT_StringHolder &value) |
static void | updateDict (int thread, const UT_StringHolder &name, const PDG_WorkItem *work_item) |
Sets or updates a PDG work in the Python dictionary. More... | |
static void | updateDict (int thread, const UT_StringHolder &name, const PDG_Node *node) |
Sets or updates a PDG node in the Python dictionary. More... | |
static void | updateDict (int thread, const UT_StringHolder &name, const PDG_Graph *graph) |
Sets or update a PDG graph inthe Python dictionary. More... | |
static void | resetDict (int thread) |
Resets the thread-local context's local Python dictionary. More... | |
static EvaluationResult | evaluate (int thread, const PY_CompiledCode &expression, fpreal &result, UT_WorkBuffer &errors) |
Primitive Python eval methods (loat, int, string) More... | |
static EvaluationResult | evaluate (int thread, const PY_CompiledCode &expression, exint &result, UT_WorkBuffer &errors) |
static EvaluationResult | evaluate (int thread, const PY_CompiledCode &expression, UT_StringHolder &result, UT_WorkBuffer &errors) |
static EvaluationResult | evaluate (int thread, const PY_CompiledCode &expression, void *&result, UT_WorkBuffer &errors) |
PyObject eval method. More... | |
static EvaluationResult | evaluate (int thread, const PY_CompiledCode &expression, UT_WorkBuffer &errors) |
Void/no-result eval method. More... | |
static EvaluationResult | evaluateCodeString (int thread, const UT_StringHolder &raw_code, void *&result, bool multi, UT_WorkBuffer &errors) |
static bool | savePyObjectAttr (int thread, UT_StringHolder &result, const PDG_AttributePyObject *attr, const UT_StringHolder &module) |
Saves a PyObject attribute to a string. More... | |
static bool | loadPyObjectAttr (int thread, void *&result, const UT_StringHolder &attr_data, const UT_StringHolder &module) |
Loads a PyObject attribute to a string. More... | |
static bool | cookWorkItem (int thread, const UT_StringHolder &module, PDG_WorkItem *work_item, UT_WorkBuffer &errors) |
Cooks work item with the specified job script module. More... | |
static bool | hashPyObjectAttr (SYS_HashType &result, const PDG_AttributePyObject *attr, UT_WorkBuffer &errors) |
Hashes a PyOvject attribute. More... | |
static void | updateParameterEvaluation (int thread, bool has_error) |
Updates parameter error state. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from UT_NonCopyableNS::UT_NonCopyable | |
UT_NonCopyable ()=default | |
~UT_NonCopyable ()=default | |
UT_NonCopyable (const UT_NonCopyable &)=delete | |
UT_NonCopyable & | operator= (const UT_NonCopyable &)=delete |
Definition at line 49 of file PDG_EvaluationContext.h.
using PDG_EvaluationContext::WorkItemCaster = UT_Function<PY_PyObject*(const PDG_WorkItem*)> |
Utility function type for converting a PDG_WorkItem* to a PY_PyObject.
Definition at line 160 of file PDG_EvaluationContext.h.
Enumeration of python script evaluation results.
Enumerator | |
---|---|
eResultSuccess |
The script succeeded without any exceptions. |
eResultFailure |
The script encountered an error or exception. |
eResultAbort |
The script was aborted, e.g. with a sys.exit(..) call. |
Definition at line 63 of file PDG_EvaluationContext.h.
Evaluation context state.
Enumerator | |
---|---|
eStateNone | |
eStateStatic | |
eStateDynamic | |
eStateCooking | |
eStateDirtying |
Definition at line 53 of file PDG_EvaluationContext.h.
PDG_EvaluationContext::PDG_EvaluationContext | ( | ) |
Constructs a new context. Should not be called, only here because the thread local var needs it to be public instead of private.
PDG_EvaluationContext::~PDG_EvaluationContext | ( | ) |
|
static |
Queries the thread local is-parent flag.
const PDG_Node* PDG_EvaluationContext::activeNode | ( | ) | const |
Returns the active node for the the context.
|
static |
Queries the current active work item. If a PDG cook is in-progress, this will return the thread-local item. If there is no active cook, this will return whatever global work item was set
|
static |
Returns the built-in functions that are available in the the context.
bool PDG_EvaluationContext::canDirty | ( | const PDG_WorkItem * | work_item | ) | const |
Returns true if the specified work item can be dirtied in the current context
bool PDG_EvaluationContext::canDirty | ( | const PDG_Node * | node | ) | const |
Returns true if the specified node can be dirtied in the current context
bool PDG_EvaluationContext::canDirty | ( | ) | const |
General version of the above method that can be called without a node.
|
static |
Cooks work item with the specified job script module.
|
static |
Gets an attribute evaluator.
|
static |
Dirties all dependent attributes.
fpreal PDG_EvaluationContext::evalTime | ( | ) | const |
Returns the current evaluation time of the context.
|
static |
Primitive Python eval methods (loat, int, string)
|
static |
|
static |
|
static |
PyObject eval method.
|
static |
Void/no-result eval method.
|
static |
Evaluates an abritrary string and returns the PyObject, rather than evaluating a compiled code instance.
|
static |
Returns the thread-local PDG_EvaluationContext instance.
|
static |
Returns the thread-local PDG_EvaluationContext instance for the specific thread
|
static |
Returns the shared Python context in which expressions evaluated.
|
static |
Returns the global work item only if it's a work item loaded for an out of process job, or nullptr in other cases
|
static |
Queries the global node name. Used on the job side to determine the work item name, since the work item does not directly store a string name on its own.
|
static |
Queries the global scheduler name. Used on the job side to determine the submitting scheduler name, since the work item doesn't have direct access to the scheduler itself.
|
static |
Quries the global work item. This should not be used in most cases, except for when checking if the global item needs to be cleared
|
static |
Hashes a PyOvject attribute.
bool PDG_EvaluationContext::hasParameterError | ( | ) | const |
Returns the parameter evaluation state of the context.
|
inline |
Returns true if the context is actively doing PDG work.
Definition at line 435 of file PDG_EvaluationContext.h.
|
inline |
Returns true if the context is in a cooking state.
Definition at line 424 of file PDG_EvaluationContext.h.
|
inline |
Returns true if the context is in a generating state.
Definition at line 419 of file PDG_EvaluationContext.h.
|
static |
Returns true if the thread local state indicates the thread is being used to do PDG work
|
static |
Returns true if a PDG job is active, either in process or out of process, for the specified thread. Out of process jobs that load in a PDG work item are always considered to be active PDG jobs. Otherwise, this method falls back to ::isLocalActive.
|
static |
Returns true if the thread local state is generating.
|
inline |
Returns true if the context should force file paths to be localized.
Definition at line 439 of file PDG_EvaluationContext.h.
|
static |
Returns true if the thread local state is runtime.
bool PDG_EvaluationContext::isParent | ( | ) | const |
Returns true if the local work item is the parent item for the evaluation
|
inline |
Returns true if the context is in a runtime state.
Definition at line 428 of file PDG_EvaluationContext.h.
|
static |
Returns true if the specified attribute is time dependent, else false.
|
static |
Loads the data from the specified input stream into a free-standing work item, which is saved as the default global item until one is selected in the UI.
|
static |
Loads a PyObject attribute to a string.
Returns the thread-local active node.
|
static |
Returns the local Python dictionary object.
Returns the current evaluation time of the thread local context.
Returns the current state of the thread local evaluation context.
|
inline |
Records an attribute access with the active scope block, if one has been set
Definition at line 455 of file PDG_EvaluationContext.h.
Resets the thread-local context's local Python dictionary.
|
static |
Saves all attributes and field from the global active work item to the specified output stream.
|
static |
Saves a PyObject attribute to a string.
|
static |
Sets the Python evaluation dictionary directly.
|
static |
Sets the global active item for an out of process work item job.
Sets the global batch subitem index. Used when constructing an active work item on the job side, to make attributes available.
|
static |
Sets the global active work item. Used for setting an active item in the current houdini session for debugging, or as part of a houdini- based job on the farm.
|
static |
Adds the specified attributes to the global set of time dependent attribs, for out-of-process batch cooks that have different attribute values at each frame.
|
static |
Configures whether or not all PDG_EvaluationContext instance should use Python.
|
static |
Sets the work item caster function, which is used when setting a work item as a Python dictonary variable from C++. If the caster function is not installed, a slower code path that looks up the work item from the graph is used instead.
State PDG_EvaluationContext::state | ( | ) | const |
Returns the state of the context.
|
static |
Sets or updates primitive values in the Python dictionary.
|
static |
|
static |
|
static |
Sets or updates a PDG work in the Python dictionary.
|
static |
Sets or updates a PDG node in the Python dictionary.
|
static |
Sets or update a PDG graph inthe Python dictionary.
Updates parameter error state.
|
static |
Returns true if PDG attribute evaluation is time dependent, else false.
const PDG_WorkItem* PDG_EvaluationContext::workItem | ( | ) | const |
Returns the context's active work item.