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

#include <PDG_GraphContext.h>

+ Inheritance diagram for PDG_GraphContext:

Classes

class  Observer
 

Public Types

using SchedulerMap = UT_StringMap< PDG_SchedulerPtr >
 
- Public Types inherited from PDG_EventEmitter
using Filter = UT_ValArray< PDG_EventType >
 
using FilterMap = UT_ArrayMap< PDG_EventHandler *, Filter >
 
using HandlerSet = UT_ArraySet< PDG_EventHandler * >
 
using HandlerArray = UT_Array< PDG_EventHandler * >
 
- 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
 
PDG_EventEmitter::FiltersupportedEventTypes () 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_Graphgraph ()
 The graph owned by this instance. More...
 
PDG_EventQueuegetEventQueue ()
 Returns the event queue associted with this context. More...
 
PDG_CheckpointManagercheckpointManager ()
 Returns the checkpoint manager associated with this instance. More...
 
const UT_StringHoldername () 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_CookStatecookState () const
 
bool cooking () const
 Returns true if the context is actively cooking. More...
 
bool canceling () const
 
PDG_SchedulerdefaultScheduler () 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_ScheduleraddScheduler (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_SchedulerschedulerForName (const UT_StringHolder &name) const
 
const SchedulerMapschedulers () 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_CommandChunkcurrentChunk () const
 Returns the current open command chunk. More...
 
PDG_CommandChunkopenChunk (UT_StringHolder description="")
 Opens a new command chunk with an option description string. More...
 
PDG_CommandChunkopenChunk (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_WorkItemdeserializeWorkItemFromJSON (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)
 
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 *eventQueue, 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 Filter &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 &evt) const
 Emit an event to all handlers. More...
 
void eventHandlers (HandlerArray &handlers) const
 
void setEventQueue (PDG_EventQueue *eventQueue)
 
void eventQueueDestroyed ()
 
- 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_EvaluationOptionsevaluationOptions () 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_GraphContextcontextByName (const UT_StringHolder &name)
 
static PDG_GraphContextcontextByID (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...
 

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::SetpropagateSet ()
 Returns the propagate set for this owner. More...
 
void addPropagate (PDGE_Dependency *dependency)
 Adds an entry to the propagate set. More...
 

Additional Inherited Members

- Protected Attributes inherited from PDG_EventEmitter
HandlerSet myHandlers
 
FilterMap myFilters
 
UT_TBBSpinLock myHandlersLock
 
bool myBeingDestroyedFlag = false
 

Detailed Description

Definition at line 59 of file PDG_GraphContext.h.

Member Typedef Documentation

Constructor & Destructor Documentation

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.

PDG_GraphContext::~PDG_GraphContext ( )
override

Member Function Documentation

static void PDG_GraphContext::addGraphContextObserver ( Observer observer)
static

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.

void PDG_GraphContext::addWorkItemPropagateDep ( const UT_StringHolder item_name,
const UT_StringHolder dep_name 
)
inline

Adds a propagate dependency between two work iems, given their names.

Definition at line 322 of file PDG_GraphContext.h.

void PDG_GraphContext::addWorkItemPropagateDepId ( PDG_WorkItemID  item_id,
PDG_WorkItemID  dep_id 
)
inline

Adds a propagate dependency between two work iems, given their IDs.

Definition at line 327 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.

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.

bool PDG_GraphContext::canceling ( ) const
inline

Returns true if the context is processing a cancel request from the user

Definition at line 162 of file PDG_GraphContext.h.

PDG_CheckpointManager* PDG_GraphContext::checkpointManager ( )
inline

Returns the checkpoint manager associated with this instance.

Definition at line 136 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 PDG_GraphContext* PDG_GraphContext::contextByID ( int  id)
static

Returns the context with the specified ID, or nullptr if no such context exists

static PDG_GraphContext* PDG_GraphContext::contextByName ( const UT_StringHolder name)
static

Returns the context with the specified name, or nullptr if no such context exists

static UT_IntArray PDG_GraphContext::contextIDs ( )
static

Returns the list of all registered context IDs.

static UT_StringArray PDG_GraphContext::contextNames ( )
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

bool PDG_GraphContext::cooking ( ) const
inline

Returns true if the context is actively cooking.

Definition at line 157 of file PDG_GraphContext.h.

const PDG_CookState& PDG_GraphContext::cookState ( ) const
inline

Returns the current cook state object, which stores various metadata relating to the active grap hook

Definition at line 153 of file PDG_GraphContext.h.

PDG_CommandChunk* PDG_GraphContext::currentChunk ( ) const

Returns the current open command chunk.

PDG_Scheduler* PDG_GraphContext::defaultScheduler ( ) const
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 169 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.

PDG_EventQueue* PDG_GraphContext::getEventQueue ( )
inline

Returns the event queue associted with this context.

Definition at line 132 of file PDG_GraphContext.h.

int64 PDG_GraphContext::getMemoryUsage ( bool  inclusive) const
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

PDG_Graph* PDG_GraphContext::graph ( )
inline

The graph owned by this instance.

Definition at line 128 of file PDG_GraphContext.h.

int PDG_GraphContext::id ( ) const
inline

Returns the id of the graph context.

Definition at line 144 of file PDG_GraphContext.h.

PDG_InProcessScheduler* PDG_GraphContext::inProcessScheduler ( ) const
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 179 of file PDG_GraphContext.h.

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

const UT_StringHolder& PDG_GraphContext::name ( void  ) const
inline

The unique name of the graph context.

Definition at line 140 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.

void PDG_GraphContext::postEvaluation ( PDGE_Evaluator::State  state,
bool  canceled 
)
overrideprotectedvirtual

Reimplemented from PDGE_Evaluator.

bool PDG_GraphContext::preEvaluation ( )
overrideprotectedvirtual

Reimplemented from PDGE_Evaluator.

bool PDG_GraphContext::recordCommand ( UT_UniquePtr< PDG_Command cmd,
UT_WorkBuffer errors 
)
bool PDG_GraphContext::redoIt ( UT_WorkBuffer errors)
static void PDG_GraphContext::removeGraphContextObserver ( Observer observer)
static
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)
template<typename Func >
static void PDG_GraphContext::safeGraphContextAccess ( const UT_StringHolder name,
const Func &  func 
)
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 358 of file PDG_GraphContext.h.

template<typename Func >
static void PDG_GraphContext::safeGraphContextAccess ( const Func &  func)
inlinestatic

Runs a function over all graph contexts with the context lock held.

Definition at line 371 of file PDG_GraphContext.h.

template<typename Func >
void PDG_GraphContext::safeSchedulerAccess ( const UT_StringHolder name,
const Func &  func 
)
inline

Runs a function with the scheduler lock held.

Definition at line 381 of file PDG_GraphContext.h.

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.

PDG_ServiceScheduler* PDG_GraphContext::serviceScheduler ( ) const
inline

Returns the service scheduler, which is used to process work items from nodes with service mode enabled.

Definition at line 174 of file PDG_GraphContext.h.

void PDG_GraphContext::setAppGraph ( PDG_ApplicationShim::Graph graph)
inline

Sets the application-specific graph object.

Definition at line 124 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.

PDG_EventEmitter::Filter& PDG_GraphContext::supportedEventTypes ( ) const
overridevirtual

Returns the list of supported event types.

Implements PDG_EventEmitter.

bool PDG_GraphContext::tickEvaluation ( )
overrideprotectedvirtual

Reimplemented from PDGE_Evaluator.

bool PDG_GraphContext::undoIt ( UT_WorkBuffer errors)

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