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

#include <PDGE_Dependency.h>

+ Inheritance diagram for PDGE_Dependency:

Public Types

enum  State : uint8 {
  eSucceeded = 0x00, eCanceled = 0x01, eFailed = 0x02, eReset = 0x04,
  eClear = 0x08
}
 
using Set = UT_ArraySet< PDGE_Dependency * >
 
using Array = UT_Array< PDGE_Dependency * >
 
using Map = UT_ArrayMap< PDGE_Dependency *, PDGE_Dependency * >
 
using OwnerArray = UT_Array< PDGE_DependencyOwner * >
 
using PartialPair = std::pair< PDGE_Dependency *, OwnerArray >
 
using Partial = UT_Array< PartialPair >
 

Public Member Functions

 PDGE_Dependency (const char *name, PDGE_DependencyOwner *owner)
 
virtual ~PDGE_Dependency ()
 Destroys this dependency object. More...
 
int64 getMemoryUsage (bool inclusive) const
 Returns the memory usage of this object. More...
 
bool addDependency (PDGE_Dependency *dependency, bool partial=false, PDGE_Dependency *propagate=nullptr, bool is_any=false)
 
bool hasDependencies () const
 Returns true if this object has any dependencies. More...
 
bool hasDependents () const
 Returns true if this object has any dependents. More...
 
bool hasDependency (PDGE_Dependency *dependency) const
 Returns true if this object has the specifed dependency. More...
 
bool isPartialSrc () const
 
bool isPartialDst () const
 
bool isResolved () const
 
bool isHeavy () const
 Returns true if this dependency has a heavy-weight evaluation routine. More...
 
uint8 state () const
 Returns the current state value of the dependency. More...
 
bool hasState (State state) const
 Returns true if the current state value is set. More...
 
void updateState (State state)
 ORs the state value into the current state. More...
 
PDGE_DependencyOwnerowner () const
 Returns the object that owns this dependency. More...
 
const Setdependencies () const
 Returns the set of all dependencies. More...
 
const Arraydependents () const
 Returns the array of all dependents. More...
 
UT_TBBSpinLockedgeLock () const
 Returns the edge lock for this dependency object. More...
 
void reset (int initial_count=0, bool is_heavy=false)
 
void unresolve ()
 
bool tryResolve (int count=1)
 
void increment (int count=1)
 
UT_StringHolder debugName (bool as_dot=false) const
 

Friends

class PDGE_Resolutions
 

Detailed Description

Base class for dependencies types. Stores a Set of dependencies and a vector of dependents. Dependencies are added using the addDependency method, which ensures that no duplicate entries are added and adds back references on the dependent this object.

A dependency relationship can optionally be marked as "partial" – by default the partial flag is false. A partial dependency means that the dependent/child is interested in partial resolution updates from the dependency/parent it is attached to. When one of the parent's dependencies is resolved, it passes on that information to all dependents/children that are interested in partial updates.

Once a dependency's resolution count reaches 0, it is marked as resolved and all dependents are inspected to see if they too have reached 0. A resolved dependency cannot be put back to the unresolved state unless it is reset. Resetting is not thread safe nor is it safe to do while a graph is being evalauated. It should only be done after an evaluation has completed.

If PDGE_DEBUG_ENABLE_NAMES is defined, this class also stores a string name for the dependency for debug output.

Definition at line 53 of file PDGE_Dependency.h.

Member Typedef Documentation

Definition at line 57 of file PDGE_Dependency.h.

Definition at line 62 of file PDGE_Dependency.h.

Definition at line 61 of file PDGE_Dependency.h.

Definition at line 56 of file PDGE_Dependency.h.

Member Enumeration Documentation

Dependency resolve state, passed back from the PDGE_DependencyOwner when doing a full or partial resolve. The state has no impact on the resolution of the dependency itself, but it propagate to dependents.

Enumerator
eSucceeded 

The dependency was successfully resolved.

eCanceled 

The dependency was resolved while evaluation was canceling.

eFailed 

The dependency encountered a failure during resolution.

eReset 

The dependency was reset during resolution and should not be marked as resolved. This can only be used with leaf nodes in the dependency graph.

eClear 

The state bits should be cleared before ORing the results from dependency resolutions

Definition at line 67 of file PDGE_Dependency.h.

Constructor & Destructor Documentation

PDGE_Dependency::PDGE_Dependency ( const char *  name,
PDGE_DependencyOwner owner 
)

Constructs a new dependency from a name and dependency owner. The name is only stored if PDGE_DEBUG_ENABLE_NAMES is enabled.

virtual PDGE_Dependency::~PDGE_Dependency ( )
virtual

Destroys this dependency object.

Member Function Documentation

bool PDGE_Dependency::addDependency ( PDGE_Dependency dependency,
bool  partial = false,
PDGE_Dependency propagate = nullptr,
bool  is_any = false 
)

Adds a dependency if it does not already exist. This method locks both this object and the dependency. Returns true if the dependency was added, else false.

UT_StringHolder PDGE_Dependency::debugName ( bool  as_dot = false) const

Returns the debug full name, which includes the name of this object and its owner. The as_dot argument indicates whether or not the name is going to be used for dot graph output.

const Set& PDGE_Dependency::dependencies ( ) const
inline

Returns the set of all dependencies.

Definition at line 164 of file PDGE_Dependency.h.

const Array& PDGE_Dependency::dependents ( ) const
inline

Returns the array of all dependents.

Definition at line 168 of file PDGE_Dependency.h.

UT_TBBSpinLock& PDGE_Dependency::edgeLock ( ) const
inline

Returns the edge lock for this dependency object.

Definition at line 172 of file PDGE_Dependency.h.

int64 PDGE_Dependency::getMemoryUsage ( bool  inclusive) const

Returns the memory usage of this object.

bool PDGE_Dependency::hasDependencies ( ) const
inline

Returns true if this object has any dependencies.

Definition at line 109 of file PDGE_Dependency.h.

bool PDGE_Dependency::hasDependency ( PDGE_Dependency dependency) const
inline

Returns true if this object has the specifed dependency.

Definition at line 117 of file PDGE_Dependency.h.

bool PDGE_Dependency::hasDependents ( ) const
inline

Returns true if this object has any dependents.

Definition at line 113 of file PDGE_Dependency.h.

bool PDGE_Dependency::hasState ( State  state) const
inline

Returns true if the current state value is set.

Definition at line 150 of file PDGE_Dependency.h.

void PDGE_Dependency::increment ( int  count = 1)

Increments the ref count on this dependency by one, for manual contorl over the ref count

bool PDGE_Dependency::isHeavy ( ) const
inline

Returns true if this dependency has a heavy-weight evaluation routine.

Definition at line 141 of file PDGE_Dependency.h.

bool PDGE_Dependency::isPartialDst ( ) const
inline

Returns true if this dependency is interested in receiving partial resolve calls, when one of its dependencies is partially resolved.

Definition at line 132 of file PDGE_Dependency.h.

bool PDGE_Dependency::isPartialSrc ( ) const
inline

Returns true if this dependency is a partial source, i.e. it emits partial resolve calls when one of its dependencies is resolved

Definition at line 127 of file PDGE_Dependency.h.

bool PDGE_Dependency::isResolved ( ) const
inline

Returns true if this dependency has been resolved. Resolves dependencies can only go back to being unresolved when calling reset().

Definition at line 137 of file PDGE_Dependency.h.

PDGE_DependencyOwner* PDGE_Dependency::owner ( ) const
inline

Returns the object that owns this dependency.

Definition at line 160 of file PDGE_Dependency.h.

void PDGE_Dependency::reset ( int  initial_count = 0,
bool  is_heavy = false 
)

Resets this dependecy object back to its default state. The initial count determines the starting value of the unresolved counter.

uint8 PDGE_Dependency::state ( ) const
inline

Returns the current state value of the dependency.

Definition at line 146 of file PDGE_Dependency.h.

bool PDGE_Dependency::tryResolve ( int  count = 1)
inline

Decrements the ref count on this dependency by one. Should be used when this dependency is reset with a non-0 initial count, for adding an N+1 dependency.

Definition at line 192 of file PDGE_Dependency.h.

void PDGE_Dependency::unresolve ( )

Unresolves a dependency and all of its dependents. This is different than a reset because its non-destructive, and propgates state to dependents. It is also threadsafe with other internal operations and will interrupt and clear any resolutions that are already in progress. It will not, however, be able to interrupt calls into the dependency owner that may be changing state on that object.

void PDGE_Dependency::updateState ( State  state)
inline

ORs the state value into the current state.

Definition at line 154 of file PDGE_Dependency.h.

Friends And Related Function Documentation

friend class PDGE_Resolutions
friend

Definition at line 205 of file PDGE_Dependency.h.


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