NEML2 2.0.0
Loading...
Searching...
No Matches
DependencyResolver< Node, ItemType > Class Template Reference

The DependencyResolver identifies and resolves the dependencies among a set of objects derived from DependencyDefinition. More...

Detailed Description

template<typename Node, typename ItemType>
class neml2::DependencyResolver< Node, ItemType >

The DependencyResolver identifies and resolves the dependencies among a set of objects derived from DependencyDefinition.

Template Parameters
NodeThe type of the node in the dependency graph, i.e. if this resolver is used to figure out dependencies among Models, this template parameter should be Model.
ItemTypeThe type of the consumed/provided items of each node

#include <DependencyResolver.h>

Classes

struct  Item
 

Public Member Functions

 DependencyResolver ()=default
 
void add_node (DependencyDefinition< ItemType > *)
 Add a node (defining consumed/provided items) in the dependency graph.
 
void add_additional_outbound_item (const ItemType &item)
 Add an additional outbound item that the dependency graph provides
 
void set_priority (DependencyDefinition< ItemType > *, size_t)
 Set a node's priority, useful for resolving cyclic dependency.
 
void resolve ()
 Resolve nodal dependency and find an evaluation order.
 
const std::vector< Node * > & resolution () const
 The resolved (nodal) evaluation order following which all consumed items of the current node.
 
const std::map< Item, std::set< Item > > & item_providers () const
 
const std::map< Item, std::set< Item > > & item_consumers () const
 
const std::map< Node *, std::set< Node * > > & node_providers () const
 
const std::map< Node *, std::set< Node * > > & node_consumers () const
 
const std::set< Node * > & end_nodes () const
 End nodes which are not consumed by anyone else.
 
const std::set< Item > & outbound_items () const
 The items provided by the overall dependency graph, i.e., the items that are not consumed by any node.
 
const std::set< Node * > & start_nodes () const
 Start nodes which do not consume anyone else.
 
const std::set< Item > & inbound_items () const
 The items consumed by the overall dependency graph, i.e., the items that are not provided by any node.
 
boolunique_item_provider ()
 
boolunique_item_consumer ()
 

Constructor & Destructor Documentation

◆ DependencyResolver()

DependencyResolver ( )
default

Member Function Documentation

◆ add_additional_outbound_item()

void add_additional_outbound_item ( const ItemType & item)

Add an additional outbound item that the dependency graph provides

◆ add_node()

void add_node ( DependencyDefinition< ItemType > * def)

Add a node (defining consumed/provided items) in the dependency graph.

◆ end_nodes()

const std::set< Node * > & end_nodes ( ) const
inline

End nodes which are not consumed by anyone else.

◆ inbound_items()

const std::set< Item > & inbound_items ( ) const
inline

The items consumed by the overall dependency graph, i.e., the items that are not provided by any node.

◆ item_consumers()

const std::map< Item, std::set< Item > > & item_consumers ( ) const
inline

The item-item consumer dictionary: key of the dictionary is the item of interest, and the value of the dictionary is the set of items that consume the item of interest.

◆ item_providers()

const std::map< Item, std::set< Item > > & item_providers ( ) const
inline

The item-item provider dictionary: key of the dictionary is the item of interest, and the value of the dictionary is the set of items that provide the item of interest.

◆ node_consumers()

const std::map< Node *, std::set< Node * > > & node_consumers ( ) const
inline

The node-node consumer dictionary: key of the dictionary is the node of interest, and the value of the dictionary is the set of nodes that consume the item of interest.

◆ node_providers()

const std::map< Node *, std::set< Node * > > & node_providers ( ) const
inline

The node-node provider dictionary: key of the dictionary is the node of interest, and the value of the dictionary is the set of nodes that provide the item of interest.

◆ outbound_items()

const std::set< Item > & outbound_items ( ) const
inline

The items provided by the overall dependency graph, i.e., the items that are not consumed by any node.

◆ resolution()

const std::vector< Node * > & resolution ( ) const
inline

The resolved (nodal) evaluation order following which all consumed items of the current node.

◆ resolve()

void resolve ( )

Resolve nodal dependency and find an evaluation order.

◆ set_priority()

void set_priority ( DependencyDefinition< ItemType > * def,
size_t priority )

Set a node's priority, useful for resolving cyclic dependency.

◆ start_nodes()

const std::set< Node * > & start_nodes ( ) const
inline

Start nodes which do not consume anyone else.

◆ unique_item_consumer()

bool & unique_item_consumer ( )
inline
Returns
a boolean flag controlling whether item consumer should be unique

◆ unique_item_provider()

bool & unique_item_provider ( )
inline
Returns
a boolean flag controlling whether item provider should be unique