HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_EvaluationContext Class Reference

#include <PDG_EvaluationContext.h>

+ Inheritance diagram for PDG_EvaluationContext:

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_WorkItemworkItem () const
 Returns the context's active work item. More...
 
bool isParent () const
 
const PDG_NodeactiveNode () 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_EvaluationContextgetExpressionContext ()
 Returns the shared Python context in which expressions evaluated. More...
 
static PDG_EvaluationContextgetContext ()
 Returns the thread-local PDG_EvaluationContext instance. More...
 
static PDG_EvaluationContextgetContext (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_WorkItemglobalWorkItem (bool sub_item)
 
static const UT_StringHolderglobalNodeName ()
 
static const UT_StringHolderglobalSchedulerName ()
 
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_WorkItemactiveWorkItem (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_NodelocalActiveNode (int thread)
 Returns the thread-local active node. More...
 
static PDG_AttributeEvaluatorcreateAttributeEvaluator (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_PyObjectlocalDict (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_NonCopyableoperator= (const UT_NonCopyable &)=delete
 

Detailed Description

Definition at line 49 of file PDG_EvaluationContext.h.

Member Typedef Documentation

Utility function type for converting a PDG_WorkItem* to a PY_PyObject.

Definition at line 160 of file PDG_EvaluationContext.h.

Member Enumeration Documentation

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.

Constructor & Destructor Documentation

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 ( )

Member Function Documentation

static bool PDG_EvaluationContext::activeIsParent ( int  thread)
static

Queries the thread local is-parent flag.

const PDG_Node* PDG_EvaluationContext::activeNode ( ) const

Returns the active node for the the context.

static const PDG_WorkItem* PDG_EvaluationContext::activeWorkItem ( int  thread)
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 void PDG_EvaluationContext::builtinFunctions ( UT_StringArray functions)
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 bool PDG_EvaluationContext::cookWorkItem ( int  thread,
const UT_StringHolder module,
PDG_WorkItem work_item,
UT_WorkBuffer errors 
)
static

Cooks work item with the specified job script module.

static PDG_AttributeEvaluator* PDG_EvaluationContext::createAttributeEvaluator ( int  thread,
const char *  name 
)
static

Gets an attribute evaluator.

static void PDG_EvaluationContext::dirtyAllAttribs ( )
static

Dirties all dependent attributes.

fpreal PDG_EvaluationContext::evalTime ( ) const

Returns the current evaluation time of the context.

static EvaluationResult PDG_EvaluationContext::evaluate ( int  thread,
const PY_CompiledCode expression,
fpreal result,
UT_WorkBuffer errors 
)
static

Primitive Python eval methods (loat, int, string)

static EvaluationResult PDG_EvaluationContext::evaluate ( int  thread,
const PY_CompiledCode expression,
exint result,
UT_WorkBuffer errors 
)
static
static EvaluationResult PDG_EvaluationContext::evaluate ( int  thread,
const PY_CompiledCode expression,
UT_StringHolder result,
UT_WorkBuffer errors 
)
static
static EvaluationResult PDG_EvaluationContext::evaluate ( int  thread,
const PY_CompiledCode expression,
void *&  result,
UT_WorkBuffer errors 
)
static

PyObject eval method.

static EvaluationResult PDG_EvaluationContext::evaluate ( int  thread,
const PY_CompiledCode expression,
UT_WorkBuffer errors 
)
static

Void/no-result eval method.

static EvaluationResult PDG_EvaluationContext::evaluateCodeString ( int  thread,
const UT_StringHolder raw_code,
void *&  result,
bool  multi,
UT_WorkBuffer errors 
)
static

Evaluates an abritrary string and returns the PyObject, rather than evaluating a compiled code instance.

static PDG_EvaluationContext* PDG_EvaluationContext::getContext ( )
static

Returns the thread-local PDG_EvaluationContext instance.

static PDG_EvaluationContext* PDG_EvaluationContext::getContext ( int  thread)
static

Returns the thread-local PDG_EvaluationContext instance for the specific thread

static PY_EvaluationContext& PDG_EvaluationContext::getExpressionContext ( )
static

Returns the shared Python context in which expressions evaluated.

static const UT_StringHolder& PDG_EvaluationContext::globalNodeName ( )
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 const UT_StringHolder& PDG_EvaluationContext::globalSchedulerName ( )
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 const PDG_WorkItem* PDG_EvaluationContext::globalWorkItem ( bool  sub_item)
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 bool PDG_EvaluationContext::hashPyObjectAttr ( SYS_HashType result,
const PDG_AttributePyObject attr,
UT_WorkBuffer errors 
)
static

Hashes a PyOvject attribute.

bool PDG_EvaluationContext::hasParameterError ( ) const

Returns the parameter evaluation state of the context.

bool PDG_EvaluationContext::isActive ( ) const
inline

Returns true if the context is actively doing PDG work.

Definition at line 431 of file PDG_EvaluationContext.h.

bool PDG_EvaluationContext::isCooking ( ) const
inline

Returns true if the context is in a cooking state.

Definition at line 420 of file PDG_EvaluationContext.h.

bool PDG_EvaluationContext::isGenerating ( ) const
inline

Returns true if the context is in a generating state.

Definition at line 415 of file PDG_EvaluationContext.h.

static bool PDG_EvaluationContext::isLocalActive ( int  thread)
static

Returns true if the thread local state indicates the thread is being used to do PDG work

static bool PDG_EvaluationContext::isLocalCookingPDG ( int  thread)
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 bool PDG_EvaluationContext::isLocalGenerating ( int  thread)
static

Returns true if the thread local state is generating.

bool PDG_EvaluationContext::isLocalize ( ) const
inline

Returns true if the context should force file paths to be localized.

Definition at line 435 of file PDG_EvaluationContext.h.

static bool PDG_EvaluationContext::isLocalRuntime ( int  thread)
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

bool PDG_EvaluationContext::isRuntime ( ) const
inline

Returns true if the context is in a runtime state.

Definition at line 424 of file PDG_EvaluationContext.h.

static bool PDG_EvaluationContext::isTimeDependent ( const UT_StringHolder name)
static

Returns true if the specified attribute is time dependent, else false.

static bool PDG_EvaluationContext::loadGlobalWorkItem ( UT_IStream is)
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 bool PDG_EvaluationContext::loadPyObjectAttr ( int  thread,
void *&  result,
const UT_StringHolder attr_data,
const UT_StringHolder module 
)
static

Loads a PyObject attribute to a string.

static const PDG_Node* PDG_EvaluationContext::localActiveNode ( int  thread)
static

Returns the thread-local active node.

static PY_PyObject* PDG_EvaluationContext::localDict ( int  thread)
static

Returns the local Python dictionary object.

static fpreal PDG_EvaluationContext::localEvalTime ( int  thread)
static

Returns the current evaluation time of the thread local context.

static State PDG_EvaluationContext::localState ( int  thread)
static

Returns the current state of the thread local evaluation context.

void PDG_EvaluationContext::recordAttribute ( const UT_StringHolder name)
inline

Records an attribute access with the active scope block, if one has been set

Definition at line 451 of file PDG_EvaluationContext.h.

static void PDG_EvaluationContext::resetDict ( int  thread)
static

Resets the thread-local context's local Python dictionary.

static bool PDG_EvaluationContext::saveGlobalWorkItem ( std::ostream &  os)
static

Saves all attributes and field from the global active work item to the specified output stream.

static bool PDG_EvaluationContext::savePyObjectAttr ( int  thread,
UT_StringHolder result,
const PDG_AttributePyObject attr,
const UT_StringHolder module 
)
static

Saves a PyObject attribute to a string.

static void PDG_EvaluationContext::setDict ( int  thread,
PY_PyObject locals 
)
static

Sets the Python evaluation dictionary directly.

static void PDG_EvaluationContext::setGlobalJobWorkItem ( PDG_WorkItem work_item,
const UT_StringHolder node_name,
const UT_StringHolder scheduler_name 
)
static

Sets the global active item for an out of process work item job.

static void PDG_EvaluationContext::setGlobalSubItemIndex ( int  index,
bool  dirty 
)
static

Sets the global batch subitem index. Used when constructing an active work item on the job side, to make attributes available.

static void PDG_EvaluationContext::setGlobalWorkItem ( const PDG_WorkItem work_item,
bool  dirty 
)
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 void PDG_EvaluationContext::setTimeDependentAttribs ( const UT_ArrayStringSet names,
bool  dirty 
)
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 void PDG_EvaluationContext::setUsePython ( bool  use_python)
static

Configures whether or not all PDG_EvaluationContext instance should use Python.

static void PDG_EvaluationContext::setWorkItemCaster ( const WorkItemCaster caster)
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 void PDG_EvaluationContext::updateDict ( int  thread,
const UT_StringHolder name,
fpreal  value 
)
static

Sets or updates primitive values in the Python dictionary.

static void PDG_EvaluationContext::updateDict ( int  thread,
const UT_StringHolder name,
int  value 
)
static
static void PDG_EvaluationContext::updateDict ( int  thread,
const UT_StringHolder name,
const UT_StringHolder value 
)
static
static void PDG_EvaluationContext::updateDict ( int  thread,
const UT_StringHolder name,
const PDG_WorkItem work_item 
)
static

Sets or updates a PDG work in the Python dictionary.

static void PDG_EvaluationContext::updateDict ( int  thread,
const UT_StringHolder name,
const PDG_Node node 
)
static

Sets or updates a PDG node in the Python dictionary.

static void PDG_EvaluationContext::updateDict ( int  thread,
const UT_StringHolder name,
const PDG_Graph graph 
)
static

Sets or update a PDG graph inthe Python dictionary.

static void PDG_EvaluationContext::updateParameterEvaluation ( int  thread,
bool  has_error 
)
static

Updates parameter error state.

static bool PDG_EvaluationContext::useTimeDependentAttribs ( )
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.


The documentation for this class was generated from the following file: