Skip to content

Commit

Permalink
[examples][dataflow] explicitly transfer ownership when adding a node…
Browse files Browse the repository at this point in the history
… to the graph
  • Loading branch information
MathiasPaulin committed Jan 31, 2023
1 parent 421018c commit a4d7d7a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
12 changes: 6 additions & 6 deletions examples/DataflowExamples/FunctionalsGraph/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ int main( int argc, char* argv[] ) {
//! [Creating Nodes]

//! [Adding Nodes to the graph]
g.addNode( sourceNode );
g.addNode( mapSource );
g.addNode( transformNode );
g.addNode( reduceNode );
g.addNode( sinkNode );
g.addNode( scalarSinkNode );
g.addNode( std::unique_ptr<Node>( sourceNode ) );
g.addNode( std::unique_ptr<Node>( mapSource ) );
g.addNode( std::unique_ptr<Node>( transformNode ) );
g.addNode( std::unique_ptr<Node>( reduceNode ) );
g.addNode( std::unique_ptr<Node>( sinkNode ) );
g.addNode( std::unique_ptr<Node>( scalarSinkNode ) );
//! [Adding Nodes to the graph]

//! [Creating links between Nodes]
Expand Down
6 changes: 3 additions & 3 deletions examples/DataflowExamples/GraphSerialization/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ int main( int argc, char* argv[] ) {
//! [Creating Nodes]

//! [Adding Nodes to the graph]
g.addNode( sourceNode );
g.addNode( filterNode );
g.addNode( sinkNode );
g.addNode( std::unique_ptr<Node>( sourceNode ) );
g.addNode( std::unique_ptr<Node>( filterNode ) );
g.addNode( std::unique_ptr<Node>( sinkNode ) );
//! [Adding Nodes to the graph]

//! [Creating links between Nodes]
Expand Down
21 changes: 13 additions & 8 deletions examples/DataflowExamples/HelloGraph/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ int main( int argc, char* argv[] ) {
//! [Creating an empty graph]

//! [Creating Nodes]
auto sourceNode = new Sources::SingleDataSourceNode<RaVector>( "Source" );
auto predicateNode = new Sources::ScalarUnaryPredicateSource( "Selector" );
auto filterNode = new Functionals::FilterNode<RaVector>( "Filter" );
auto sinkNode = new Sinks::SinkNode<RaVector>( "Sink" );
auto addedSourceNode = std::make_unique<Sources::SingleDataSourceNode<RaVector>>( "Source" );
auto addedPredicateNode = std::make_unique<Sources::ScalarUnaryPredicateSource>( "Selector" );
auto addedFilterNode = std::make_unique<Functionals::FilterNode<RaVector>>( "Filter" );
auto addedSinkNode = std::make_unique<Sinks::SinkNode<RaVector>>( "Sink" );
// get non-owning aliases to ease future node management
auto sourceNode = addedSourceNode.get();
auto predicateNode = addedPredicateNode.get();
auto filterNode = addedFilterNode.get();
auto sinkNode = addedSinkNode.get();
//! [Creating Nodes]

//! [Adding Nodes to the graph]
g.addNode( sourceNode );
g.addNode( predicateNode );
g.addNode( filterNode );
g.addNode( sinkNode );
g.addNode( std::move( addedSourceNode ) );
g.addNode( std::move( addedPredicateNode ) );
g.addNode( std::move( addedFilterNode ) );
g.addNode( std::move( addedSinkNode ) );
//! [Adding Nodes to the graph]

//! [Creating links between Nodes]
Expand Down

0 comments on commit a4d7d7a

Please sign in to comment.