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

#include <PDG_Graph.h>

+ Inheritance diagram for PDG_Graph:

Public Types

using IdMap = UT_ConcurrentHashMap< PDG_WorkItemID, PDG_WorkItem * >
 Typedef for work item id -> work item. More...
 

Public Member Functions

 PDG_Graph (PDG_GraphContext *context)
 
 ~PDG_Graph () override
 
int64 getMemoryUsage (bool inclusive) const
 
void memoryInfo (PDG_MemoryInfo &memory_info, bool inclusive) const
 
UT_StringHolder attribOwnerName () const override
 Returns a descriptive name of the attribute owner. More...
 
bool isAttribFlagValid (PDG_AttributeFlag flag) const override
 Checks if the specified flag is valid for this owner. More...
 
bool areAttribFlagsValid (uint16 flags) const override
 Checks if the specified bit vector flags is valid for this owner. More...
 
void description (UT_WorkBuffer &buffer) const
 Returns a human-readable description of the nodes in the graph. More...
 
void serialize (UT_WorkBuffer &buffer) const
 
PDG_NodecreateNode (PDG_NodeCallbackType *type_object, const UT_StringHolder &node_name, const PDGT_ValueArgs &args, UT_WorkBuffer &errors, int id=-1)
 
void insertNode (PDG_NodePtr &node)
 Adds an existing node to the graph. More...
 
bool renameNode (const UT_StringHolder &old_name, const UT_StringHolder &new_name)
 
bool renameNodeById (int node_id, const UT_StringHolder &new_name)
 
PDG_NodePtr removeNode (const UT_StringHolder &node_name)
 Remove node/nodes from the graph. More...
 
PDG_NodePtr removeNodeById (int node_id)
 
void removeAllNodes ()
 
PDG_Nodenode (const UT_StringHolder &name) const
 Accessors for nodes in the graph. More...
 
PDG_NodenodeById (int id) const
 
int nodeCount () const
 
const PDG_NodePtrMapnodes () const
 
UT_StringHolder uniqueNodeName (const UT_StringHolder &name)
 
PDG_PortnodePort (const UT_StringHolder &node_name, const UT_StringHolder &port_name) const
 Looks up a port using the node.port_name syntax. More...
 
PDG_PortnodePort (const UT_StringHolder &full_name) const
 
PDG_DependencyPtr dependencyForKey (const UT_StringHolder &key) const
 Adds/ removes or queries external dependencies. More...
 
PDG_DependencyPtr addDependency (const UT_StringHolder &type, const UT_StringHolder &key, const PDGT_ValueArgs &args, UT_WorkBuffer &errors)
 
void addDependency (PDG_DependencyPtr dependency)
 
void removeDependency (PDG_DependencyPtr dependency)
 
PDG_GraphContextcontext () const
 Returns the graph contex that owns this graph. More...
 
void addWorkItem (PDG_WorkItem *work_item)
 Adds a work item to the work item id -> pointer map. More...
 
void removeWorkItem (PDG_WorkItem *work_item)
 Removes a work item from the graph. More...
 
PDG_WorkItemworkItemById (PDG_WorkItemID id) const
 Returns a work item for a given id. More...
 
void workItemsById (PDG_WorkItemArray &work_items, const UT_ValArray< PDG_WorkItemID > &ids, bool allow_null) const
 Returns a list of work items for a given list of ids. More...
 
PDG_WorkItemworkItemByName (const UT_StringHolder &name) const
 Returns a work item for a given name. More...
 
PDG_WorkItemID workItemIdFromName (const UT_StringHolder &name) const
 
IdMap workItemIdMap () const
 Returns the map of work item ids -> work item. More...
 
void dependencyGraph (PDG_WorkItemMap &dependencies, PDG_WorkItemMap &dependents, PDG_WorkItemArray &ready, bool expand, PDG_Scheduler *filter) const
 Returns a map of item->dependencies, item->dependents and ready items. More...
 
void dependencyGraph (PDG_WorkItemMap &graph, bool inverse, bool expand, PDG_Scheduler *filter) const
 
PDG_WorkItemDirty dirtyAll (bool remove_outputs, bool apply_dirty)
 
PDG_WorkItemDirty dirtyWorkItem (PDG_WorkItemID id, bool should_delete, bool remove_outputs, bool apply_dirty)
 
PDG_WorkItemDirty dirtyWorkItem (PDG_WorkItem *work_item, bool should_delete, bool remove_outputs, bool apply_dirty)
 
PDG_WorkItemDirty dirtyWorkItems (const PDG_WorkItemArray &work_items, PDG_Node *source_node, bool should_delete, bool remove_outputs, bool apply_dirty, bool emit_events)
 
PDG_AttributeCast numericData (fpreal &param, const PDG_AttributeEvaluator &evaluator) const
 Does a numeric data lookup, for use with the @ operator. More...
 
PDG_AttributeCast stringData (UT_WorkBuffer &buffer, const PDG_AttributeEvaluator &evaluator, const PDG_EvaluationContext *local_context) const
 Does a string data lookup, for use with the @ operator. More...
 
void bindGlobalAttribute (const UT_StringHolder &attrib_name, PDG_WorkItem *work_item)
 Binds a global attribute to a specific work item. More...
 
PDG_WorkItemboundAttributeWorkItem (const UT_StringHolder &attrib_name) const
 Returns the work iterm that an attribute is bound to. More...
 
int uniqueCacheId ()
 Returns a new unique cache id. More...
 
int uniqueNodeId ()
 Returns a new unique node id. More...
 
void bumpCacheId ()
 Increments the graph's cache id. More...
 
UT_RWLockserialCookLock ()
 
template<typename Func >
void safeNodeAccess (int id, const Func &f) const
 Runs a functor on the specified node with the node lock held. More...
 
template<typename Func >
void safeNodeMapAccess (const Func &f) const
 Runs a functor on the node map with the node lock held. More...
 
template<typename Func >
void safeWorkItemAccess (PDG_WorkItemID id, const Func &f) const
 
- Public Member Functions inherited from PDG_AttributeOwner
 PDG_AttributeOwner (bool has_runtime)
 
virtual ~PDG_AttributeOwner ()
 
PDG_AttributeMapattributes ()
 
const PDG_AttributeMapattributes () const
 
bool attribSaveJSON (std::ostream &os, bool binary) const
 
bool attribSaveJSON (const UT_StringHolder &file_path) const
 
bool attribLoadJSON (UT_IStream &istream, PDG_AttributeCollision strategy)
 
bool attribLoadJSON (const UT_StringHolder &file_path, PDG_AttributeCollision strategy)
 
bool hasAttributes () const
 
virtual UT_RWLockattribGlobalLock () const
 
virtual bool attribCanWrite (const PDG_EvaluationContext *context) const
 
virtual void attribUnlock () const
 
virtual void attribModify (PDG_AttributeType attrib_type, const UT_StringHolder &attrib_name) const
 
virtual void attribWarn (const UT_StringHolder &msg) const
 

Static Public Member Functions

static PDG_WorkItemworkItemByGlobalId (PDG_WorkItemID id)
 Returns a work item for a given id. Iterates through all active. More...
 
static void addUniqueId (PDG_WorkItemID id)
 
static PDG_WorkItemID uniqueWorkItemId ()
 Returns a new unique work item id. More...
 
static PDG_WorkItemID currentWorkItemId ()
 Returns the current maximum unique work item id. More...
 

Static Public Attributes

static constexpr int nodeIdBase = 1000000
 Nodes not created by TOPs will have id = nodeIdBase + counter. More...
 

Friends

class PDG_WorkItemDirty
 

Additional Inherited Members

- Protected Attributes inherited from PDG_AttributeOwner
PDG_AttributeMap myAttributes
 

Detailed Description

Definition at line 35 of file PDG_Graph.h.

Member Typedef Documentation

Typedef for work item id -> work item.

Definition at line 42 of file PDG_Graph.h.

Constructor & Destructor Documentation

PDG_Graph::PDG_Graph ( PDG_GraphContext context)
PDG_Graph::~PDG_Graph ( )
override

Member Function Documentation

PDG_DependencyPtr PDG_Graph::addDependency ( const UT_StringHolder type,
const UT_StringHolder key,
const PDGT_ValueArgs args,
UT_WorkBuffer errors 
)
void PDG_Graph::addDependency ( PDG_DependencyPtr  dependency)
static void PDG_Graph::addUniqueId ( PDG_WorkItemID  id)
static

Adjusts the unique id counter so the specified ID is included in the range of used values.

void PDG_Graph::addWorkItem ( PDG_WorkItem work_item)

Adds a work item to the work item id -> pointer map.

bool PDG_Graph::areAttribFlagsValid ( uint16  flags) const
overridevirtual

Checks if the specified bit vector flags is valid for this owner.

Reimplemented from PDG_AttributeOwner.

UT_StringHolder PDG_Graph::attribOwnerName ( ) const
overridevirtual

Returns a descriptive name of the attribute owner.

Reimplemented from PDG_AttributeOwner.

void PDG_Graph::bindGlobalAttribute ( const UT_StringHolder attrib_name,
PDG_WorkItem work_item 
)

Binds a global attribute to a specific work item.

PDG_WorkItem* PDG_Graph::boundAttributeWorkItem ( const UT_StringHolder attrib_name) const

Returns the work iterm that an attribute is bound to.

void PDG_Graph::bumpCacheId ( )

Increments the graph's cache id.

PDG_GraphContext* PDG_Graph::context ( ) const

Returns the graph contex that owns this graph.

PDG_Node* PDG_Graph::createNode ( PDG_NodeCallbackType type_object,
const UT_StringHolder node_name,
const PDGT_ValueArgs args,
UT_WorkBuffer errors,
int  id = -1 
)

Constructs a new PDG node with a given node callbakc type, name and extra args

static PDG_WorkItemID PDG_Graph::currentWorkItemId ( )
static

Returns the current maximum unique work item id.

PDG_DependencyPtr PDG_Graph::dependencyForKey ( const UT_StringHolder key) const

Adds/ removes or queries external dependencies.

void PDG_Graph::dependencyGraph ( PDG_WorkItemMap dependencies,
PDG_WorkItemMap dependents,
PDG_WorkItemArray ready,
bool  expand,
PDG_Scheduler filter 
) const

Returns a map of item->dependencies, item->dependents and ready items.

void PDG_Graph::dependencyGraph ( PDG_WorkItemMap graph,
bool  inverse,
bool  expand,
PDG_Scheduler filter 
) const

Returns a static dependency graph as a map of work item -> dependencies If "inverse" is true, returns the dependent map instead

void PDG_Graph::description ( UT_WorkBuffer buffer) const

Returns a human-readable description of the nodes in the graph.

PDG_WorkItemDirty PDG_Graph::dirtyAll ( bool  remove_outputs,
bool  apply_dirty 
)

Dirties all work items in the graph, faster than the standard dirty methods as it can simply blow away everything

PDG_WorkItemDirty PDG_Graph::dirtyWorkItem ( PDG_WorkItemID  id,
bool  should_delete,
bool  remove_outputs,
bool  apply_dirty 
)

Dirties a work item by id

Note that this method acquires the serial cook write lock, preventing any other code from accessing/generating static or dirtying work items

PDG_WorkItemDirty PDG_Graph::dirtyWorkItem ( PDG_WorkItem work_item,
bool  should_delete,
bool  remove_outputs,
bool  apply_dirty 
)

Dirties a work item by pointer

Note that this method acquires the serial cook write lock, preventing any other code from accessing/generating static or dirtying work items

PDG_WorkItemDirty PDG_Graph::dirtyWorkItems ( const PDG_WorkItemArray work_items,
PDG_Node source_node,
bool  should_delete,
bool  remove_outputs,
bool  apply_dirty,
bool  emit_events 
)

Dirities an array of work items

Note that this method acquires the serial cook write lock, preventing any other code from accessing/generating static or dirtying work items

int64 PDG_Graph::getMemoryUsage ( bool  inclusive) const

Returns the total memory usage of the graph, and all the nodes and work items in it

void PDG_Graph::insertNode ( PDG_NodePtr node)

Adds an existing node to the graph.

bool PDG_Graph::isAttribFlagValid ( PDG_AttributeFlag  flag) const
overridevirtual

Checks if the specified flag is valid for this owner.

Reimplemented from PDG_AttributeOwner.

void PDG_Graph::memoryInfo ( PDG_MemoryInfo memory_info,
bool  inclusive 
) const

Returns the total memory usage of the graph, and all the nodes and work items in it.

PDG_Node* PDG_Graph::node ( const UT_StringHolder name) const

Accessors for nodes in the graph.

PDG_Node* PDG_Graph::nodeById ( int  id) const
int PDG_Graph::nodeCount ( ) const
inline

Definition at line 105 of file PDG_Graph.h.

PDG_Port* PDG_Graph::nodePort ( const UT_StringHolder node_name,
const UT_StringHolder port_name 
) const

Looks up a port using the node.port_name syntax.

PDG_Port* PDG_Graph::nodePort ( const UT_StringHolder full_name) const
const PDG_NodePtrMap& PDG_Graph::nodes ( ) const
inline

Definition at line 107 of file PDG_Graph.h.

PDG_AttributeCast PDG_Graph::numericData ( fpreal param,
const PDG_AttributeEvaluator evaluator 
) const

Does a numeric data lookup, for use with the @ operator.

void PDG_Graph::removeAllNodes ( )
void PDG_Graph::removeDependency ( PDG_DependencyPtr  dependency)
PDG_NodePtr PDG_Graph::removeNode ( const UT_StringHolder node_name)

Remove node/nodes from the graph.

PDG_NodePtr PDG_Graph::removeNodeById ( int  node_id)
void PDG_Graph::removeWorkItem ( PDG_WorkItem work_item)

Removes a work item from the graph.

bool PDG_Graph::renameNode ( const UT_StringHolder old_name,
const UT_StringHolder new_name 
)

Renames a node given i's current/old node name. Does not update any external references to the node name

bool PDG_Graph::renameNodeById ( int  node_id,
const UT_StringHolder new_name 
)

Renames a node give its ID. Does not update any external references tot he node name

template<typename Func >
void PDG_Graph::safeNodeAccess ( int  id,
const Func &  f 
) const
inline

Runs a functor on the specified node with the node lock held.

Definition at line 257 of file PDG_Graph.h.

template<typename Func >
void PDG_Graph::safeNodeMapAccess ( const Func &  f) const
inline

Runs a functor on the node map with the node lock held.

Definition at line 267 of file PDG_Graph.h.

template<typename Func >
void PDG_Graph::safeWorkItemAccess ( PDG_WorkItemID  id,
const Func &  f 
) const
inline

Runs a functor on the specified work item with an ID map iterator held.

Definition at line 276 of file PDG_Graph.h.

UT_RWLock& PDG_Graph::serialCookLock ( )
inline

Returns the serial cook RW lock. This is only so that PDG_Node is able to use the lock to guard access to its static items, wrappers and done item lists.

Definition at line 252 of file PDG_Graph.h.

void PDG_Graph::serialize ( UT_WorkBuffer buffer) const

Serializes the nodes to Python, which can then be used to rebuild the graph at a later point

PDG_AttributeCast PDG_Graph::stringData ( UT_WorkBuffer buffer,
const PDG_AttributeEvaluator evaluator,
const PDG_EvaluationContext local_context 
) const

Does a string data lookup, for use with the @ operator.

int PDG_Graph::uniqueCacheId ( )

Returns a new unique cache id.

int PDG_Graph::uniqueNodeId ( )

Returns a new unique node id.

UT_StringHolder PDG_Graph::uniqueNodeName ( const UT_StringHolder name)

Returns a unqiue name for a node by adding a numeric suffix until a name is found that isn't already in use

static PDG_WorkItemID PDG_Graph::uniqueWorkItemId ( )
static

Returns a new unique work item id.

static PDG_WorkItem* PDG_Graph::workItemByGlobalId ( PDG_WorkItemID  id)
static

Returns a work item for a given id. Iterates through all active.

PDG_WorkItem* PDG_Graph::workItemById ( PDG_WorkItemID  id) const

Returns a work item for a given id.

PDG_WorkItem* PDG_Graph::workItemByName ( const UT_StringHolder name) const

Returns a work item for a given name.

PDG_WorkItemID PDG_Graph::workItemIdFromName ( const UT_StringHolder name) const

Returns a work item id from a name, assuming the name is using the node_id compatibility format

IdMap PDG_Graph::workItemIdMap ( ) const
inline

Returns the map of work item ids -> work item.

Definition at line 159 of file PDG_Graph.h.

void PDG_Graph::workItemsById ( PDG_WorkItemArray work_items,
const UT_ValArray< PDG_WorkItemID > &  ids,
bool  allow_null 
) const

Returns a list of work items for a given list of ids.

Friends And Related Function Documentation

friend class PDG_WorkItemDirty
friend

Definition at line 285 of file PDG_Graph.h.

Member Data Documentation

constexpr int PDG_Graph::nodeIdBase = 1000000
static

Nodes not created by TOPs will have id = nodeIdBase + counter.

Definition at line 39 of file PDG_Graph.h.


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