HDK
|
#include <PDG_GraphContext.h>
Classes | |
class | Observer |
Public Types | |
using | SchedulerMap = UT_StringMap< PDG_SchedulerPtr > |
Public Types inherited from PDGE_Evaluator | |
enum | State { eUninitialized, eEvaluating, eCanceling, eCompleted, eInvalid } |
The state of the evaluator object. More... | |
Public Types inherited from PDGE_DependencyOwner | |
using | Array = UT_Array< PDGE_DependencyOwner * > |
using | Set = UT_ArraySet< PDGE_DependencyOwner * > |
Public Member Functions | |
PDG_GraphContext (const char *name="context", int id=-1) | |
~PDG_GraphContext () override | |
const PDG_EventFilter & | supportedEventTypes () const override |
Returns the list of supported event types. More... | |
int64 | getMemoryUsage (bool inclusive) const override |
void | memoryInfo (PDG_MemoryInfo &memory_info, bool inclusive) const |
void | setAppGraph (PDG_ApplicationShim::Graph *graph) |
Sets the application-specific graph object. More... | |
PDG_Graph * | graph () |
The graph owned by this instance. More... | |
PDG_EventQueue * | getEventQueue () |
Returns the event queue associted with this context. More... | |
PDG_CheckpointManager * | checkpointManager () |
Returns the checkpoint manager associated with this instance. More... | |
const UT_StringHolder & | name () const |
The unique name of the graph context. More... | |
int | id () const |
Returns the id of the graph context. More... | |
bool | defaultWorkItemLabel (UT_StringHolder &label) const |
Returns the default work item label. More... | |
const PDG_CookState & | cookState () const |
bool | cooking () const |
Returns true if the context is actively cooking. More... | |
bool | canceling () const |
PDG_Scheduler * | defaultScheduler () const |
PDG_ServiceScheduler * | serviceScheduler () const |
PDG_InProcessScheduler * | inProcessScheduler () const |
void | addScheduler (const UT_StringHolder &name, PDG_SchedulerPtr scheduler) |
Adds a new scheduler instance to the graph context. More... | |
PDG_Scheduler * | addScheduler (const UT_StringHolder &preferred_name, PDG_SchedulerType *scheduler_type, UT_WorkBuffer &errors) |
bool | removeScheduler (const UT_StringHolder &name) |
void | setDefaultScheduler (PDG_Scheduler *scheduler) |
Sets the specified scheduler as the new default. More... | |
PDG_Scheduler * | schedulerForName (const UT_StringHolder &name) const |
const SchedulerMap & | schedulers () const |
PDGT_ValueArgs | getSharedServerInfo (const UT_StringHolder &sharedserver_name) |
void | cleanTempDirectory (const UT_StringHolder &scheduler_name) |
Cleans the temporary file directory for the specified scheduler. More... | |
void | cancelCook () |
Cancel the cook if it's running and block until it's finished canceling. More... | |
void | pauseCook () |
bool | cook (const PDG_CookOptions &options, UT_WorkBuffer &errors) |
PDG_CommandChunk * | currentChunk () const |
Returns the current open command chunk. More... | |
PDG_CommandChunk * | openChunk (UT_StringHolder description="") |
Opens a new command chunk with an option description string. More... | |
PDG_CommandChunk * | openChunk (bool delayed, const UT_StringHolder &description) |
Opens a new delayed command chunk. More... | |
bool | commitChunk (UT_WorkBuffer &errors) |
Record, undo and redo commands. More... | |
bool | rollbackChunk (UT_WorkBuffer &errors) |
bool | undoIt (UT_WorkBuffer &errors) |
bool | redoIt (UT_WorkBuffer &errors) |
bool | recordCommand (UT_UniquePtr< PDG_Command > cmd, UT_WorkBuffer &errors) |
int | stateCount () const |
Returns the number of entries in the command manager. More... | |
int | chunkDepth () const |
Returns the number of entries in the current command chunk. More... | |
void | commandDescriptions (UT_WorkBuffer &buffer) const |
Dumps the current command manager contents to the input buffer. More... | |
void | serializeGraph (UT_WorkBuffer &buffer) |
Serializes the node graph to a buffer. More... | |
void | serializeGraph (const UT_StringHolder &file_name, UT_StringHolder extras="") |
void | serializeWorkItems (UT_WorkBuffer &buffer) |
Serializes the work item graph to a buffer. More... | |
void | serializeWorkItems (const UT_StringHolder &file_name, UT_StringHolder extras="") |
void | serialize (UT_WorkBuffer &buffer) |
Serializes both the work item and node graph. More... | |
void | serialize (const UT_StringHolder &file_name, UT_StringHolder extras="") |
UT_StringHolder | serializeWorkItemToJSON (PDG_WorkItem *work_item, bool pretty_print) const |
Serializes the specified work item to JSON. More... | |
PDG_WorkItem * | deserializeWorkItemFromJSON (const UT_StringHolder &buffer, UT_WorkBuffer &errors) |
Loads a work item from JSON. More... | |
bool | deserializeCheckpoint (const UT_StringHolder &file_path, UT_WorkBuffer &errors) |
Loads a work item checkpoint file. More... | |
void | beginDeserialization () |
void | addWorkItem (const PDG_WorkItemSerialization &serialization) |
Deserializes a work item from a serialization struct. More... | |
void | addWorkItemDependency (const UT_StringHolder &item_name, const UT_StringHolder &dep_name, bool required, bool user_defined) |
Adds a dependency between two work items, given their names. More... | |
void | addWorkItemDependencyId (PDG_WorkItemID item_id, PDG_WorkItemID dep_id, bool required, bool user_defined) |
Adds a dependency between two work items, given their IDs. More... | |
void | addWorkItemPropagateDep (const UT_StringHolder &item_name, const UT_StringHolder &dep_name) |
Adds a propagate dependency between two work iems, given their names. More... | |
void | addWorkItemPropagateDepId (PDG_WorkItemID item_id, PDG_WorkItemID dep_id) |
Adds a propagate dependency between two work iems, given their IDs. More... | |
void | addWorkItemResults (const UT_StringHolder &item_name, const UT_StringArray &results, const UT_StringArray &tags, const UT_Array< int64 > &hash_codes, const UT_Array< bool > &is_expected, const UT_Array< bool > &is_owned) |
Adds work item output files onto the specified work item, by name. More... | |
void | addWorkItemResultsId (PDG_WorkItemID item_id, const UT_StringArray &results, const UT_StringArray &tags, const UT_Array< int64 > &hash_codes, const UT_Array< bool > &is_expected, const UT_Array< bool > &is_owned) |
Adds work item output files onto the specified work item, by id. More... | |
void | commitWorkItem (const UT_StringHolder &item_name) |
Commits a partially deserialized work item to the PDG graph. More... | |
void | commitWorkItemId (PDG_WorkItemID item_id) |
bool | asJSON (UT_JSONWriter &writer, bool skip_defaults) const |
Writes the nodes and schedulers in the graph to JSON. More... | |
bool | saveJSON (UT_WorkBuffer &buffer, bool pretty_print, bool skip_defaults) const |
bool | saveJSON (std::ostream &os, bool binary, bool skip_defaults) const |
bool | saveJSON (const UT_StringHolder &file_path, bool pretty_print, bool skip_defaults) const |
bool | fromJSON (const UT_JSONValue &value, UT_WorkBuffer &errors) |
Creates a graph from JSON. More... | |
bool | loadJSON (const UT_StringHolder &file_path, UT_WorkBuffer &errors) |
template<typename Func > | |
void | safeSchedulerAccess (const UT_StringHolder &name, const Func &func) |
Runs a function with the scheduler lock held. More... | |
Public Member Functions inherited from PDG_EventEmitter | |
PDG_EventEmitter (PDG_EventQueue *event_queue, bool block_destruction) | |
virtual | ~PDG_EventEmitter () |
int64 | getMemoryUsage (bool inclusive) const |
Returns memory usage for this event emitter instance. More... | |
bool | addEventHandler (PDG_EventHandler *handler) |
Adds an event handlers that listens for all types of events. More... | |
bool | addEventHandler (PDG_EventHandler *handler, PDG_EventType event) |
Adds an event handlers that listens for a specific event. More... | |
bool | addEventHandler (PDG_EventHandler *handler, const PDG_EventFilter &filter) |
void | removeEventHandler (PDG_EventHandler *handler) |
Removes an event handler from this emitter. More... | |
void | removeAllEventHandlers (bool user_handler_only=false) |
void | emitEvent (const PDG_Event &event, bool immediate=false) const |
Emit an event to all handlers. More... | |
void | eventHandlers (PDG_EventHandlerArray &handlers) const |
void | setEventQueue (PDG_EventQueue *event_queue) |
void | clearEventQueue () |
bool | shouldEmit (const PDG_Event &event) const |
Public Member Functions inherited from PDGE_Evaluator | |
PDGE_Evaluator () | |
~PDGE_Evaluator () noexceptoverride | |
int64 | getMemoryUsage (bool inclusive) const override |
Returns the memory usage of this object. More... | |
State | evaluationState () const |
const PDGE_EvaluationOptions & | evaluationOptions () const |
Returns the evaluation options used for the current cook. More... | |
void | evaluate (const PDGE_EvaluationOptions &options) |
void | cancelEvaluator () |
void | resetEvaluator () |
void | invalidateEvaluator () |
void | addRootDependency (PDGE_Dependency *dependency) |
bool | hasRootDependency (PDGE_Dependency *root) const |
Returns true if this evaluator depends on the specified dependency. More... | |
void | queueInitial (PDGE_Dependency *dependency) |
void | queueResolve (PDGE_Resolutions &resolutions) |
void | resolve (const PDGE_Resolutions &resolutions) |
void | partial (PDGE_Resolutions &resolutions) |
UT_StringHolder | debugName () const override |
Returns the debug name for this evaluator object. More... | |
PDGE_Dependency::State | evalResolve (PDGE_Resolutions &resolutions, const PDGE_Evaluator &evaluator, PDGE_Dependency *dependency) override |
template<typename WrappedFunction , typename... Args> | |
void | runFunctor (Args &&...args) |
Public Member Functions inherited from PDGE_DependencyOwner | |
PDGE_DependencyOwner () | |
Constructs a new dependency owner, which must have a string name. More... | |
virtual | ~PDGE_DependencyOwner () |
virtual void | resetOwner () |
Resets the owner. More... | |
virtual UT_StringHolder | debugGroup () const |
Static Public Member Functions | |
static PDG_GraphContext * | contextByName (const UT_StringHolder &name) |
static PDG_GraphContext * | contextByID (int id) |
static UT_StringArray | contextNames () |
Returns the list of all registered context names. More... | |
static UT_IntArray | contextIDs () |
Returns the list of all registered context IDs. More... | |
static void | addGraphContextObserver (Observer *observer) |
static void | removeGraphContextObserver (Observer *observer) |
template<typename Func > | |
static void | safeGraphContextAccess (const UT_StringHolder &name, const Func &func) |
template<typename Func > | |
static void | safeGraphContextAccess (const Func &func) |
Runs a function over all graph contexts with the context lock held. More... | |
Static Public Member Functions inherited from PDGE_DependencyOwner | |
template<typename T > | |
static void | cast (UT_Array< T > &out, const Array &in) |
Converts an owner array to an array of the specified type. More... | |
template<typename T > | |
static void | cast (Array &out, const UT_Array< T > &in) |
Converts an array of the specified type to an owner array. More... | |
Static Public Attributes | |
static const UT_StringHolder | theNodesKey |
The JSON key for nodes, when writing the graph to JSON. More... | |
static const UT_StringHolder | theSchedulersKey |
The JSON key for schedulers, when writing the graph to JSON. More... | |
Protected Member Functions | |
bool | preEvaluation () override |
bool | tickEvaluation () override |
void | postEvaluation (PDGE_Evaluator::State state, bool canceled) override |
Protected Member Functions inherited from PDGE_Evaluator | |
bool | preEvaluate () |
void | postEvaluate () |
Protected Member Functions inherited from PDGE_DependencyOwner | |
virtual int | evalUnresolve (PDGE_Dependency::Array &, PDGE_Dependency *) |
virtual PDGE_Dependency::State | evalPartial (PDGE_Resolutions &, const PDGE_Evaluator &, PDGE_Dependency *, const Array &) |
const PDGE_Dependency::Set & | propagateSet () |
Returns the propagate set for this owner. More... | |
void | addPropagate (PDGE_Dependency *dependency) |
Adds an entry to the propagate set. More... | |
Definition at line 61 of file PDG_GraphContext.h.
Definition at line 64 of file PDG_GraphContext.h.
PDG_GraphContext::PDG_GraphContext | ( | const char * | name = "context" , |
int | id = -1 |
||
) |
Constructs a new context with the specified name and id. It is up to the caller to supply a unique id, which is typically set to an application-specific value such as the unique ID of a TOP_Network.
|
override |
Adds and removes a global observer, which is notified each time a graph context is created
void PDG_GraphContext::addScheduler | ( | const UT_StringHolder & | name, |
PDG_SchedulerPtr | scheduler | ||
) |
Adds a new scheduler instance to the graph context.
PDG_Scheduler* PDG_GraphContext::addScheduler | ( | const UT_StringHolder & | preferred_name, |
PDG_SchedulerType * | scheduler_type, | ||
UT_WorkBuffer & | errors | ||
) |
Adds a new scheduler constructed from the specified type instance, and with the desired named. This method ensures that the name is unique.
void PDG_GraphContext::addWorkItem | ( | const PDG_WorkItemSerialization & | serialization | ) |
Deserializes a work item from a serialization struct.
void PDG_GraphContext::addWorkItemDependency | ( | const UT_StringHolder & | item_name, |
const UT_StringHolder & | dep_name, | ||
bool | required, | ||
bool | user_defined | ||
) |
Adds a dependency between two work items, given their names.
void PDG_GraphContext::addWorkItemDependencyId | ( | PDG_WorkItemID | item_id, |
PDG_WorkItemID | dep_id, | ||
bool | required, | ||
bool | user_defined | ||
) |
Adds a dependency between two work items, given their IDs.
|
inline |
Adds a propagate dependency between two work iems, given their names.
Definition at line 330 of file PDG_GraphContext.h.
|
inline |
Adds a propagate dependency between two work iems, given their IDs.
Definition at line 335 of file PDG_GraphContext.h.
void PDG_GraphContext::addWorkItemResults | ( | const UT_StringHolder & | item_name, |
const UT_StringArray & | results, | ||
const UT_StringArray & | tags, | ||
const UT_Array< int64 > & | hash_codes, | ||
const UT_Array< bool > & | is_expected, | ||
const UT_Array< bool > & | is_owned | ||
) |
Adds work item output files onto the specified work item, by name.
void PDG_GraphContext::addWorkItemResultsId | ( | PDG_WorkItemID | item_id, |
const UT_StringArray & | results, | ||
const UT_StringArray & | tags, | ||
const UT_Array< int64 > & | hash_codes, | ||
const UT_Array< bool > & | is_expected, | ||
const UT_Array< bool > & | is_owned | ||
) |
Adds work item output files onto the specified work item, by id.
bool PDG_GraphContext::asJSON | ( | UT_JSONWriter & | writer, |
bool | skip_defaults | ||
) | const |
Writes the nodes and schedulers in the graph to JSON.
void PDG_GraphContext::beginDeserialization | ( | ) |
Begins deserializing a work item graph, part of the Python serialization API
void PDG_GraphContext::cancelCook | ( | ) |
Cancel the cook if it's running and block until it's finished canceling.
|
inline |
Returns true if the context is processing a cancel request from the user
Definition at line 170 of file PDG_GraphContext.h.
|
inline |
Returns the checkpoint manager associated with this instance.
Definition at line 144 of file PDG_GraphContext.h.
int PDG_GraphContext::chunkDepth | ( | ) | const |
Returns the number of entries in the current command chunk.
void PDG_GraphContext::cleanTempDirectory | ( | const UT_StringHolder & | scheduler_name | ) |
Cleans the temporary file directory for the specified scheduler.
void PDG_GraphContext::commandDescriptions | ( | UT_WorkBuffer & | buffer | ) | const |
Dumps the current command manager contents to the input buffer.
bool PDG_GraphContext::commitChunk | ( | UT_WorkBuffer & | errors | ) |
Record, undo and redo commands.
void PDG_GraphContext::commitWorkItem | ( | const UT_StringHolder & | item_name | ) |
Commits a partially deserialized work item to the PDG graph.
void PDG_GraphContext::commitWorkItemId | ( | PDG_WorkItemID | item_id | ) |
|
static |
Returns the context with the specified ID, or nullptr if no such context exists
|
static |
Returns the context with the specified name, or nullptr if no such context exists
|
static |
Returns the list of all registered context IDs.
|
static |
Returns the list of all registered context names.
bool PDG_GraphContext::cook | ( | const PDG_CookOptions & | options, |
UT_WorkBuffer & | errors | ||
) |
Cooks the graph with the specified options. Returns false if there was a probably starting the cook
|
inline |
Returns true if the context is actively cooking.
Definition at line 165 of file PDG_GraphContext.h.
|
inline |
Returns the current cook state object, which stores various metadata relating to the active grap hook
Definition at line 161 of file PDG_GraphContext.h.
PDG_CommandChunk* PDG_GraphContext::currentChunk | ( | ) | const |
Returns the current open command chunk.
|
inline |
Returns the current default scheduler, or nullptr if no schedulers exist. The first scheduled created is automatically set as the default.
Definition at line 177 of file PDG_GraphContext.h.
bool PDG_GraphContext::defaultWorkItemLabel | ( | UT_StringHolder & | label | ) | const |
Returns the default work item label.
bool PDG_GraphContext::deserializeCheckpoint | ( | const UT_StringHolder & | file_path, |
UT_WorkBuffer & | errors | ||
) |
Loads a work item checkpoint file.
PDG_WorkItem* PDG_GraphContext::deserializeWorkItemFromJSON | ( | const UT_StringHolder & | buffer, |
UT_WorkBuffer & | errors | ||
) |
Loads a work item from JSON.
bool PDG_GraphContext::fromJSON | ( | const UT_JSONValue & | value, |
UT_WorkBuffer & | errors | ||
) |
Creates a graph from JSON.
|
inline |
Returns the event queue associted with this context.
Definition at line 140 of file PDG_GraphContext.h.
|
overridevirtual |
Returns total memory usage of the graph and schedulers contained in this context
Reimplemented from PDGE_DependencyOwner.
PDGT_ValueArgs PDG_GraphContext::getSharedServerInfo | ( | const UT_StringHolder & | sharedserver_name | ) |
Returns shared server info by searching for it across all active schedulers
|
inline |
The graph owned by this instance.
Definition at line 136 of file PDG_GraphContext.h.
|
inline |
Returns the id of the graph context.
Definition at line 152 of file PDG_GraphContext.h.
|
inline |
Returns the default in process scheduler, which is used to process in process items that need to run on the main thread
Definition at line 187 of file PDG_GraphContext.h.
bool PDG_GraphContext::loadJSON | ( | const UT_StringHolder & | file_path, |
UT_WorkBuffer & | errors | ||
) |
void PDG_GraphContext::memoryInfo | ( | PDG_MemoryInfo & | memory_info, |
bool | inclusive | ||
) | const |
Returns a fined grained breakdown of memory used by the nodes and work items in the graph context
|
inline |
The unique name of the graph context.
Definition at line 148 of file PDG_GraphContext.h.
PDG_CommandChunk* PDG_GraphContext::openChunk | ( | UT_StringHolder | description = "" | ) |
Opens a new command chunk with an option description string.
PDG_CommandChunk* PDG_GraphContext::openChunk | ( | bool | delayed, |
const UT_StringHolder & | description | ||
) |
Opens a new delayed command chunk.
void PDG_GraphContext::pauseCook | ( | ) |
Similar to cancel, except work items that are in-progress are not killed, and results can be collected later.
|
overrideprotectedvirtual |
Reimplemented from PDGE_Evaluator.
|
overrideprotectedvirtual |
Reimplemented from PDGE_Evaluator.
bool PDG_GraphContext::recordCommand | ( | UT_UniquePtr< PDG_Command > | cmd, |
UT_WorkBuffer & | errors | ||
) |
bool PDG_GraphContext::redoIt | ( | UT_WorkBuffer & | errors | ) |
bool PDG_GraphContext::removeScheduler | ( | const UT_StringHolder & | name | ) |
Removes the scheduler with the specified name, and returns true if it was found/removed.
bool PDG_GraphContext::rollbackChunk | ( | UT_WorkBuffer & | errors | ) |
|
inlinestatic |
Runs a function with the context lock held, for a specific graph context. If a context with the name does not exist, the function is not called.
Definition at line 392 of file PDG_GraphContext.h.
|
inlinestatic |
Runs a function over all graph contexts with the context lock held.
Definition at line 405 of file PDG_GraphContext.h.
|
inline |
Runs a function with the scheduler lock held.
Definition at line 415 of file PDG_GraphContext.h.
bool PDG_GraphContext::saveJSON | ( | UT_WorkBuffer & | buffer, |
bool | pretty_print, | ||
bool | skip_defaults | ||
) | const |
bool PDG_GraphContext::saveJSON | ( | std::ostream & | os, |
bool | binary, | ||
bool | skip_defaults | ||
) | const |
bool PDG_GraphContext::saveJSON | ( | const UT_StringHolder & | file_path, |
bool | pretty_print, | ||
bool | skip_defaults | ||
) | const |
PDG_Scheduler* PDG_GraphContext::schedulerForName | ( | const UT_StringHolder & | name | ) | const |
Returns the scheduler with the specified name, or nullptr if no such scheduler exists.
const SchedulerMap& PDG_GraphContext::schedulers | ( | ) | const |
Returns the map of scheduler name -> scheduler pointer that exist in the graph context
void PDG_GraphContext::serialize | ( | UT_WorkBuffer & | buffer | ) |
Serializes both the work item and node graph.
void PDG_GraphContext::serialize | ( | const UT_StringHolder & | file_name, |
UT_StringHolder | extras = "" |
||
) |
void PDG_GraphContext::serializeGraph | ( | UT_WorkBuffer & | buffer | ) |
Serializes the node graph to a buffer.
void PDG_GraphContext::serializeGraph | ( | const UT_StringHolder & | file_name, |
UT_StringHolder | extras = "" |
||
) |
void PDG_GraphContext::serializeWorkItems | ( | UT_WorkBuffer & | buffer | ) |
Serializes the work item graph to a buffer.
void PDG_GraphContext::serializeWorkItems | ( | const UT_StringHolder & | file_name, |
UT_StringHolder | extras = "" |
||
) |
UT_StringHolder PDG_GraphContext::serializeWorkItemToJSON | ( | PDG_WorkItem * | work_item, |
bool | pretty_print | ||
) | const |
Serializes the specified work item to JSON.
|
inline |
Returns the service scheduler, which is used to process work items from nodes with service mode enabled.
Definition at line 182 of file PDG_GraphContext.h.
|
inline |
Sets the application-specific graph object.
Definition at line 132 of file PDG_GraphContext.h.
void PDG_GraphContext::setDefaultScheduler | ( | PDG_Scheduler * | scheduler | ) |
Sets the specified scheduler as the new default.
int PDG_GraphContext::stateCount | ( | ) | const |
Returns the number of entries in the command manager.
|
overridevirtual |
Returns the list of supported event types.
Implements PDG_EventEmitter.
|
overrideprotectedvirtual |
Reimplemented from PDGE_Evaluator.
bool PDG_GraphContext::undoIt | ( | UT_WorkBuffer & | errors | ) |
|
static |
The JSON key for nodes, when writing the graph to JSON.
Definition at line 84 of file PDG_GraphContext.h.
|
static |
The JSON key for schedulers, when writing the graph to JSON.
Definition at line 87 of file PDG_GraphContext.h.