Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shamrock::solvergraph::NodeMapEdge< Tin, Tout > Class Template Reference

A node that maps an input edge into an output edge. More...

#include <shamsolvergraph/include/shamsolvergraph/node/NodeMapEdge.hpp>

Inheritance diagram for shamrock::solvergraph::NodeMapEdge< Tin, Tout >:
Collaboration diagram for shamrock::solvergraph::NodeMapEdge< Tin, Tout >:

Public Member Functions

 NodeMapEdge (std::function< void(const Tin &, Tout &)> map_edge)
 Construct a new NodeMapEdge object.
void set_edges (std::shared_ptr< Tin > in_edge, std::shared_ptr< Tout > out_edge)
 Set the edges of the node.
void _impl_evaluate_internal ()
 Evaluate the node.
virtual std::string _impl_get_label () const
 Get the label of the node.
virtual std::string _impl_get_tex () const
 Get the TeX representation of the node.
Public Member Functions inherited from shamrock::solvergraph::INode
 INode (const INode &)=delete
INode & operator= (const INode &)=delete
 would violate shared_from_this() & unique UUID
 INode (INode &&) noexcept=default
 would violate shared_from_this() & unique UUID
INode & operator= (INode &&) noexcept=default
 Move assignment - automatically delegates to base classes and members.
std::shared_ptr< INode > getptr_shared ()
 Get a shared pointer to this node.
std::weak_ptr< INode > getptr_weak ()
 Get a weak pointer to this node.
std::vector< std::shared_ptr< IEdge > > & get_ro_edges ()
 Get the read only edges.
std::vector< std::shared_ptr< IEdge > > & get_rw_edges ()
 Get the read write edges.
void __internal_set_ro_edges (std::vector< std::shared_ptr< IEdge > > new_ro_edges)
 Set the read only edges.
void __internal_set_rw_edges (std::vector< std::shared_ptr< IEdge > > new_rw_edges)
 Set the read write edges.
template<class Func>
void on_edge_ro_edges (Func &&f)
 Apply a function to the read only edges.
template<class Func>
void on_edge_rw_edges (Func &&f)
 Apply a function to the read write edges.
virtual ~INode ()
 Destructor (virtual) & reset the edges.
template<class T>
const T & get_ro_edge (int slot)
 Get a read only edge and cast it to the type T.
template<class T>
T & get_rw_edge (int slot)
 Get a read write edge and cast it to the type T.
template<class T>
std::optional< std::reference_wrapper< const T > > get_ro_edge_optional (int slot)
 Get a read only edge and cast it to the type T, return an optional.
template<class T>
std::optional< std::reference_wrapper< T > > get_rw_edge_optional (int slot)
 Get a read write edge and cast it to the type T, return an optional.
const IEdgeget_ro_edge_base (int slot)
 Get a reference to a read only edge.
const IEdgeget_ro_edge_base (int slot) const
IEdgeget_rw_edge_base (int slot)
 Get a reference to a read write edge and cast it to the type IEdge.
const IEdgeget_rw_edge_base (int slot) const
void evaluate ()
 Evaluate the node.
std::string get_dot_graph ()
 Get the dot graph of the node (Currently only an alias to get_dot_graph_partial).
std::string get_dot_graph_partial ()
 Get the dot graph of the subgraph corresponding to the node.
std::string get_dot_graph_node_start ()
 Get the id of the node start in the dot graph.
std::string get_dot_graph_node_end ()
 Get the id of the node end in the dot graph.
std::string get_tex ()
 Get the TeX of the node.
std::string get_tex_partial ()
 Get the TeX of the node partial.
std::string get_label () const
 Get the label of the node.
virtual std::string print_node_info () const
 print the node info
Public Member Functions inherited from shambase::WithUUID< INode, u64 >
u64 get_uuid () const
 Get the uuid of the class.
 WithUUID ()
 Constructor of the class.

Additional Inherited Members

Protected Member Functions inherited from shamrock::solvergraph::INode
virtual std::string _impl_get_dot_graph_partial () const
 get the dot graph of the node partial
virtual std::string _impl_get_dot_graph_node_start () const
 get the dot graph of the node start
virtual std::string _impl_get_dot_graph_node_end () const
 get the dot graph of the node end
Protected Attributes inherited from shambase::WithUUID< INode, u64 >
u64 uuid
 The unique identifier of the class.

Detailed Description

template<class Tin, class Tout>
class shamrock::solvergraph::NodeMapEdge< Tin, Tout >

A node that maps an input edge into an output edge.

This node executes a user-defined function that reads from a connected read-only edge and writes to a connected read-write edge. The function is applied during node evaluation.

Template Parameters
TinThe type of the input (read-only) edge
ToutThe type of the output (read-write) edge
// Example: Create a node that maps an input edge into an output edge
auto map_function = [](const MyInEdgeType &in_edge, MyOutEdgeType &out_edge) {
out_edge.set_value(in_edge.get_value() + 1);
};
auto map_node = std::make_shared<NodeMapEdge<MyInEdgeType, MyOutEdgeType>>(map_function);
map_node->set_edges(my_in_edge, my_out_edge);

Definition at line 45 of file NodeMapEdge.hpp.

Constructor & Destructor Documentation

◆ NodeMapEdge()

template<class Tin, class Tout>
shamrock::solvergraph::NodeMapEdge< Tin, Tout >::NodeMapEdge ( std::function< void(const Tin &, Tout &)> map_edge)
inline

Construct a new NodeMapEdge object.

Parameters
map_edgeThe function applied to (input, output) during evaluation

Definition at line 55 of file NodeMapEdge.hpp.

Member Function Documentation

◆ _impl_evaluate_internal()

template<class Tin, class Tout>
void shamrock::solvergraph::NodeMapEdge< Tin, Tout >::_impl_evaluate_internal ( )
inlinevirtual

Evaluate the node.

Applies the custom function to the connected read-only input edge and read-write output edge.

Implements shamrock::solvergraph::INode.

Definition at line 79 of file NodeMapEdge.hpp.

Here is the call graph for this function:

◆ _impl_get_label()

template<class Tin, class Tout>
virtual std::string shamrock::solvergraph::NodeMapEdge< Tin, Tout >::_impl_get_label ( ) const
inlinevirtual

Get the label of the node.

Returns
std::string The node label "MapEdge"

Implements shamrock::solvergraph::INode.

Definition at line 89 of file NodeMapEdge.hpp.

◆ _impl_get_tex()

template<class Tin, class Tout>
virtual std::string shamrock::solvergraph::NodeMapEdge< Tin, Tout >::_impl_get_tex ( ) const
inlinevirtual

Get the TeX representation of the node.

Returns
std::string A TeX string describing the node operation

Implements shamrock::solvergraph::INode.

Definition at line 96 of file NodeMapEdge.hpp.

Here is the call graph for this function:

◆ set_edges()

template<class Tin, class Tout>
void shamrock::solvergraph::NodeMapEdge< Tin, Tout >::set_edges ( std::shared_ptr< Tin > in_edge,
std::shared_ptr< Tout > out_edge )
inline

Set the edges of the node.

Configures the input edge as read-only and the output edge as read-write. The custom function reads from in_edge and writes to out_edge during evaluation.

Parameters
in_edgeThe edge read by the custom function
out_edgeThe edge written by the custom function

Definition at line 68 of file NodeMapEdge.hpp.

Here is the call graph for this function:

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