HDK
|
#include <PDG_Graph.h>
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_Node * | createNode (PDG_NodeCallbackType *type_object, const UT_StringHolder &node_name, const PDGT_ValueArgs &args, UT_WorkBuffer &errors, PDG_NodeID 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 (PDG_NodeID 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 (PDG_NodeID node_id) |
void | removeAllNodes () |
PDG_Node * | node (const UT_StringHolder &name) const |
Accessors for nodes in the graph. More... | |
PDG_Node * | nodeById (PDG_NodeID id) const |
int | nodeCount () const |
const PDG_NodePtrMap & | nodes () const |
UT_StringHolder | uniqueNodeName (const UT_StringHolder &name) |
PDG_Port * | nodePort (const UT_StringHolder &node_name, const UT_StringHolder &port_name) const |
Looks up a port using the node.port_name syntax. More... | |
PDG_Port * | nodePort (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_GraphContext * | context () 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_WorkItem * | workItemById (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_WorkItem * | workItemByName (const UT_StringHolder &name) const |
Returns a work item for a given name. More... | |
PDG_WorkItemID | workItemIdFromName (const UT_StringHolder &name) const |
void | workItemIds (PDG_WorkItemIDArray &ids) const |
Returns an array of work item IDs currently in the graph. More... | |
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) const |
PDG_WorkItemDirty | dirtyWorkItem (PDG_WorkItemID id, bool should_delete, bool remove_outputs, bool apply_dirty) const |
PDG_WorkItemDirty | dirtyWorkItem (PDG_WorkItem *work_item, bool should_delete, bool remove_outputs, bool apply_dirty) const |
PDG_WorkItemDirty | dirtyWorkItems (const PDG_WorkItemArray &work_items, PDG_Node *source_node, bool should_delete, bool remove_outputs, bool apply_dirty, bool emit_events) const |
void | dirtyWorkItems (const PDG_WorkItemArray &work_items, PDG_WorkItemDirty *dirty_state) const |
PDG_AttributeCast | numericData (fpreal ¶m, 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_WorkItem * | boundAttributeWorkItem (const UT_StringHolder &attrib_name) const |
Returns the work iterm that an attribute is bound to. More... | |
PDG_CacheID | uniqueCacheId () |
Returns a new unique cache id. More... | |
PDG_NodeID | uniqueNodeId () |
Returns a new unique node id. More... | |
void | bumpCacheId () |
Increments the graph's cache id. More... | |
UT_RWLock & | serialCookLock () |
template<typename Func > | |
void | safeNodeAccess (PDG_NodeID 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_AttributeMap & | attributes () |
const PDG_AttributeMap & | attributes () 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_RWLock * | attribGlobalLock () const |
virtual bool | attribCanWrite (const PDG_EvaluationContext *context) const |
virtual void | attribUnlock (bool modified) 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_WorkItem * | workItemByGlobalId (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 PDG_NodeID | 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 |
Definition at line 39 of file PDG_Graph.h.
Typedef for work item id -> work item.
Definition at line 46 of file PDG_Graph.h.
PDG_Graph::PDG_Graph | ( | PDG_GraphContext * | context | ) |
|
override |
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 |
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.
|
overridevirtual |
Checks if the specified bit vector flags is valid for this owner.
Reimplemented from PDG_AttributeOwner.
|
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, | ||
PDG_NodeID | id = -1 |
||
) |
Constructs a new PDG node with a given node callbakc type, name and extra args
|
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 | ||
) | const |
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 | ||
) | const |
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 | ||
) | const |
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 | ||
) | const |
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
void PDG_Graph::dirtyWorkItems | ( | const PDG_WorkItemArray & | work_items, |
PDG_WorkItemDirty * | dirty_state | ||
) | const |
Dirities an array of work items, using the existing dirty state object.
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.
|
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 | ( | PDG_NodeID | id | ) | const |
|
inline |
Definition at line 109 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 |
|
inline |
Definition at line 111 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 | ( | PDG_NodeID | 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 | ( | PDG_NodeID | node_id, |
const UT_StringHolder & | new_name | ||
) |
Renames a node give its ID. Does not update any external references tot he node name
|
inline |
Runs a functor on the specified node with the node lock held.
Definition at line 278 of file PDG_Graph.h.
|
inline |
Runs a functor on the node map with the node lock held.
Definition at line 288 of file PDG_Graph.h.
|
inline |
Runs a functor on the specified work item with an ID map iterator held.
Definition at line 297 of file PDG_Graph.h.
|
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 273 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.
PDG_CacheID PDG_Graph::uniqueCacheId | ( | ) |
Returns a new unique cache id.
PDG_NodeID 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 |
Returns a new unique work item 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
|
inline |
Returns the map of work item ids -> work item.
Definition at line 166 of file PDG_Graph.h.
void PDG_Graph::workItemIds | ( | PDG_WorkItemIDArray & | ids | ) | const |
Returns an array of work item IDs currently in the graph.
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.
|
friend |
Definition at line 306 of file PDG_Graph.h.
|
static |
Nodes not created by TOPs will have id = nodeIdBase + counter.
Definition at line 43 of file PDG_Graph.h.