Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Public Member Functions | List of all members
shamrock::solvergraph::SolverGraph Class Reference

A graph container for managing solver nodes and edges with type-safe access. More...

#include <shamrock/include/shamrock/solvergraph/SolverGraph.hpp>

Public Member Functions

std::shared_ptr< INoderegister_node_ptr_base (const std::string &name, std::shared_ptr< INode > node)
 Register a node with the graph using a shared pointer.
 
std::shared_ptr< IEdgeregister_edge_ptr_base (const std::string &name, std::shared_ptr< IEdge > edge)
 Register an edge with the graph using a shared pointer.
 
std::shared_ptr< INode > & get_node_ptr_base (const std::string &name)
 Retrieve a node by name as a shared pointer to the base interface.
 
const std::shared_ptr< INode > & get_node_ptr_base (const std::string &name) const
 const variant
 
std::shared_ptr< IEdge > & get_edge_ptr_base (const std::string &name)
 Retrieve an edge by name as a shared pointer to the base interface.
 
const std::shared_ptr< IEdge > & get_edge_ptr_base (const std::string &name) const
 const variant
 
INodeget_node_ref_base (const std::string &name)
 Get a reference to a node by name through the base interface.
 
const INodeget_node_ref_base (const std::string &name) const
 const variant
 
IEdgeget_edge_ref_base (const std::string &name)
 Get a reference to an edge by name through the base interface.
 
const IEdgeget_edge_ref_base (const std::string &name) const
 const variant
 
template<class T >
std::shared_ptr< T > register_node (const std::string &name, T &&node)
 Register a node with automatic type deduction and shared pointer creation.
 
template<class T >
std::shared_ptr< T > register_edge (const std::string &name, T &&edge)
 Register an edge with automatic type deduction and shared pointer creation.
 
template<class T >
std::shared_ptr< T > get_node_ptr (const std::string &name)
 Get a typed shared pointer to a node by name.
 
template<class T >
std::shared_ptr< T > get_node_ptr (const std::string &name) const
 const variant
 
template<class T >
std::shared_ptr< T > get_edge_ptr (const std::string &name)
 Get a typed shared pointer to an edge by name.
 
template<class T >
std::shared_ptr< T > get_edge_ptr (const std::string &name) const
 const variant
 
template<class T >
T & get_node_ref (const std::string &name)
 Get a typed reference to a node by name.
 
template<class T >
const T & get_node_ref (const std::string &name) const
 const variant
 
template<class T >
T & get_edge_ref (const std::string &name)
 Get a typed reference to an edge by name.
 
template<class T >
const T & get_edge_ref (const std::string &name) const
 const variant
 

Detailed Description

A graph container for managing solver nodes and edges with type-safe access.

The SolverGraph class provides a centralized registry for solver graph components, allowing nodes and edges to be registered by name and retrieved with type safety. It supports both polymorphic access through base interfaces and templated access for specific derived types.

// Create a solver graph
// Register a node with automatic type deduction
MyNodeType node_instance;
graph.register_node("my_node", std::move(node_instance));
// Register an edge
MyEdgeType edge_instance;
graph.register_edge("my_edge", std::move(edge_instance));
// Retrieve typed references
auto& node_ref = graph.get_node_ref<MyNodeType>("my_node");
auto& edge_ref = graph.get_edge_ref<MyEdgeType>("my_edge");
// Or get shared pointers for polymorphic access
auto node_ptr = graph.get_node_ptr<MyNodeType>("my_node");
auto edge_ptr = graph.get_edge_ptr<MyEdgeType>("my_edge");
A graph container for managing solver nodes and edges with type-safe access.
T & get_edge_ref(const std::string &name)
Get a typed reference to an edge by name.
std::shared_ptr< T > get_edge_ptr(const std::string &name)
Get a typed shared pointer to an edge by name.
std::shared_ptr< T > register_edge(const std::string &name, T &&edge)
Register an edge with automatic type deduction and shared pointer creation.
std::shared_ptr< T > get_node_ptr(const std::string &name)
Get a typed shared pointer to a node by name.
std::shared_ptr< T > register_node(const std::string &name, T &&node)
Register a node with automatic type deduction and shared pointer creation.
T & get_node_ref(const std::string &name)
Get a typed reference to a node by name.

Definition at line 56 of file SolverGraph.hpp.

Member Function Documentation

◆ get_edge_ptr() [1/2]

template<class T >
std::shared_ptr< T > shamrock::solvergraph::SolverGraph::get_edge_ptr ( const std::string &  name)
inline

Get a typed shared pointer to an edge by name.

This method performs a dynamic cast to the requested type and returns a shared pointer. Throw an exception if the cast fails.

Template Parameters
TType of the edge to retrieve
Parameters
nameUnique identifier for the edge
Returns
Shared pointer to the typed edge, or throw an exception if cast fails
Exceptions
std::invalid_argumentif no edge with the given name exists or cast fails

Definition at line 276 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_edge_ptr() [2/2]

template<class T >
std::shared_ptr< T > shamrock::solvergraph::SolverGraph::get_edge_ptr ( const std::string &  name) const
inline

const variant

Definition at line 287 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_edge_ptr_base() [1/2]

std::shared_ptr< IEdge > & shamrock::solvergraph::SolverGraph::get_edge_ptr_base ( const std::string &  name)
inline

Retrieve an edge by name as a shared pointer to the base interface.

Parameters
nameUnique identifier for the edge
Returns
Reference to shared pointer to the edge
Exceptions
std::invalid_argumentif no edge with the given name exists

Definition at line 135 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_edge_ptr_base() [2/2]

const std::shared_ptr< IEdge > & shamrock::solvergraph::SolverGraph::get_edge_ptr_base ( const std::string &  name) const
inline

const variant

Definition at line 145 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_edge_ref() [1/2]

template<class T >
T & shamrock::solvergraph::SolverGraph::get_edge_ref ( const std::string &  name)
inline

Get a typed reference to an edge by name.

This method performs a dynamic cast and returns a reference to the typed edge. Throws an exception if the cast fails.

Template Parameters
TType of the edge to retrieve
Parameters
nameUnique identifier for the edge
Returns
Reference to the typed edge
Exceptions
std::invalid_argumentif no edge with the given name exists or cast fails

Definition at line 330 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_edge_ref() [2/2]

template<class T >
const T & shamrock::solvergraph::SolverGraph::get_edge_ref ( const std::string &  name) const
inline

const variant

Definition at line 336 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_edge_ref_base() [1/2]

IEdge & shamrock::solvergraph::SolverGraph::get_edge_ref_base ( const std::string &  name)
inline

Get a reference to an edge by name through the base interface.

Parameters
nameUnique identifier for the edge
Returns
Reference to the edge through the base interface
Exceptions
std::invalid_argumentif no edge with the given name exists

Definition at line 181 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_edge_ref_base() [2/2]

const IEdge & shamrock::solvergraph::SolverGraph::get_edge_ref_base ( const std::string &  name) const
inline

const variant

Definition at line 186 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_node_ptr() [1/2]

template<class T >
std::shared_ptr< T > shamrock::solvergraph::SolverGraph::get_node_ptr ( const std::string &  name)
inline

Get a typed shared pointer to a node by name.

This method performs a dynamic cast to the requested type and returns a shared pointer. Throw an exception if the cast fails.

Template Parameters
TType of the node to retrieve
Parameters
nameUnique identifier for the node
Returns
Shared pointer to the typed node, or throw an exception if cast fails
Exceptions
std::invalid_argumentif no node with the given name exists or cast fails

Definition at line 244 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_node_ptr() [2/2]

template<class T >
std::shared_ptr< T > shamrock::solvergraph::SolverGraph::get_node_ptr ( const std::string &  name) const
inline

const variant

Definition at line 255 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_node_ptr_base() [1/2]

std::shared_ptr< INode > & shamrock::solvergraph::SolverGraph::get_node_ptr_base ( const std::string &  name)
inline

Retrieve a node by name as a shared pointer to the base interface.

Parameters
nameUnique identifier for the node
Returns
Reference to shared pointer to the node
Exceptions
std::invalid_argumentif no node with the given name exists

Definition at line 109 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_node_ptr_base() [2/2]

const std::shared_ptr< INode > & shamrock::solvergraph::SolverGraph::get_node_ptr_base ( const std::string &  name) const
inline

const variant

Definition at line 119 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_node_ref() [1/2]

template<class T >
T & shamrock::solvergraph::SolverGraph::get_node_ref ( const std::string &  name)
inline

Get a typed reference to a node by name.

This method performs a dynamic cast and returns a reference to the typed node. Throws an exception if the cast fails.

Template Parameters
TType of the node to retrieve
Parameters
nameUnique identifier for the node
Returns
Reference to the typed node
Exceptions
std::invalid_argumentif no node with the given name exists or cast fails

Definition at line 308 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_node_ref() [2/2]

template<class T >
const T & shamrock::solvergraph::SolverGraph::get_node_ref ( const std::string &  name) const
inline

const variant

Definition at line 314 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_node_ref_base() [1/2]

INode & shamrock::solvergraph::SolverGraph::get_node_ref_base ( const std::string &  name)
inline

Get a reference to a node by name through the base interface.

Parameters
nameUnique identifier for the node
Returns
Reference to the node through the base interface
Exceptions
std::invalid_argumentif no node with the given name exists

Definition at line 165 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ get_node_ref_base() [2/2]

const INode & shamrock::solvergraph::SolverGraph::get_node_ref_base ( const std::string &  name) const
inline

const variant

Definition at line 170 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ register_edge()

template<class T >
std::shared_ptr< T > shamrock::solvergraph::SolverGraph::register_edge ( const std::string &  name,
T &&  edge 
)
inline

Register an edge with automatic type deduction and shared pointer creation.

This method creates a shared pointer from the provided edge instance and registers it with the graph. The edge type is automatically deduced from the template parameter.

Template Parameters
TType of the edge (must derive from IEdge)
Parameters
nameUnique identifier for the edge
edgeEdge instance to register (will be moved)
Exceptions
std::invalid_argumentif an edge with the same name already exists

Definition at line 226 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ register_edge_ptr_base()

std::shared_ptr< IEdge > shamrock::solvergraph::SolverGraph::register_edge_ptr_base ( const std::string &  name,
std::shared_ptr< IEdge edge 
)
inline

Register an edge with the graph using a shared pointer.

Parameters
nameUnique identifier for the edge
edgeShared pointer to the edge instance
Exceptions
std::invalid_argumentif an edge with the same name already exists

Definition at line 92 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ register_node()

template<class T >
std::shared_ptr< T > shamrock::solvergraph::SolverGraph::register_node ( const std::string &  name,
T &&  node 
)
inline

Register a node with automatic type deduction and shared pointer creation.

This method creates a shared pointer from the provided node instance and registers it with the graph. The node type is automatically deduced from the template parameter.

Template Parameters
TType of the node (must derive from INode)
Parameters
nameUnique identifier for the node
nodeNode instance to register (will be moved)
Exceptions
std::invalid_argumentif a node with the same name already exists

Definition at line 207 of file SolverGraph.hpp.

+ Here is the call graph for this function:

◆ register_node_ptr_base()

std::shared_ptr< INode > shamrock::solvergraph::SolverGraph::register_node_ptr_base ( const std::string &  name,
std::shared_ptr< INode node 
)
inline

Register a node with the graph using a shared pointer.

Parameters
nameUnique identifier for the node
nodeShared pointer to the node instance
Exceptions
std::invalid_argumentif a node with the same name already exists

Definition at line 75 of file SolverGraph.hpp.

+ Here is the call graph for this function:

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