Skip to content

Commit

Permalink
[dataflow-rendering][tests][examples] fix missing const in dataflow g…
Browse files Browse the repository at this point in the history
…raph node access
  • Loading branch information
MathiasPaulin committed Mar 21, 2023
1 parent ddd1f8e commit 50a585c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
12 changes: 6 additions & 6 deletions examples/DataflowExamples/GraphRendering/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ class MyRendererController : public RenderGraphController
}

// Nodes of the graph
auto nodes = g.getNodes();
std::cout << "Nodes of the graph " << g.getInstanceName() << " (" << nodes->size()
const auto& nodes = g.getNodes();
std::cout << "Nodes of the graph " << g.getInstanceName() << " (" << nodes.size()
<< ") :\n";
for ( const auto& n : *( nodes ) ) {
for ( const auto& n : nodes ) {
std::cout << "\t\"" << n->getInstanceName() << "\" of type \"" << n->getTypeName()
<< "\"\n";
// Inspect input, output and interfaces of the node
Expand All @@ -210,11 +210,11 @@ class MyRendererController : public RenderGraphController
// Nodes by level after the compilation
auto c = g.compile();
if ( c ) {
auto cn = g.getNodesByLevel();
const auto& cn = g.getNodesByLevel();
std::cout << "Nodes of the graph, sorted by level when compiling the graph :\n";
for ( size_t i = 0; i < cn->size(); ++i ) {
for ( size_t i = 0; i < cn.size(); ++i ) {
std::cout << "\tLevel " << i << " :\n";
for ( const auto n : ( *cn )[i] ) {
for ( const auto n : cn[i] ) {
std::cout << "\t\t\"" << n->getInstanceName() << "\"\n";
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Dataflow/Rendering/RenderingGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ bool RenderingGraph::compile() {
if ( compiled ) {
const auto& compiledNodes = getNodesByLevel();
int idx = 1; // The renderTechnique id = 0 is reserved for ui/debug objects
for ( const auto& lvl : *compiledNodes ) {
for ( const auto& lvl : compiledNodes ) {
for ( auto n : lvl ) {
auto renderNode = dynamic_cast<RenderingNode*>( n );
if ( renderNode != nullptr ) {
Expand Down
16 changes: 7 additions & 9 deletions tests/unittest/Dataflow/renderinggraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ TEST_CASE( "Dataflow/Rendering/RenderingGraph", "[Dataflow][Rendering][Rendering
}

// Nodes of the graph
auto nodes = g->getNodes();
REQUIRE( nodes != nullptr );
std::cout << "Nodes of the graph " << g->getInstanceName() << " (" << nodes->size()
const auto& nodes = g->getNodes();
REQUIRE( nodes.size() == g->getNodesCount() );
std::cout << "Nodes of the graph " << g->getInstanceName() << " (" << nodes.size()
<< " nodes) " << g->getNodesCount() << ":\n";

REQUIRE( nodes->size() == g->getNodesCount() );

for ( const auto& n : *( nodes ) ) {
for ( const auto& n : nodes ) {
std::cout << "\t\"" << n->getInstanceName() << "\" of type \"" << n->getTypeName()
<< "\"\n";
// Inspect input, output and interfaces of the node
Expand Down Expand Up @@ -80,11 +78,11 @@ TEST_CASE( "Dataflow/Rendering/RenderingGraph", "[Dataflow][Rendering][Rendering
// Nodes by level after the compilation
auto c = g->compile();
REQUIRE( c == true );
auto cn = g->getNodesByLevel();
auto& cn = g->getNodesByLevel();
std::cout << "Nodes of the graph, sorted by level when compiling the graph :\n";
for ( size_t i = 0; i < cn->size(); ++i ) {
for ( size_t i = 0; i < cn.size(); ++i ) {
std::cout << "\tLevel " << i << " :\n";
for ( const auto n : ( *cn )[i] ) {
for ( const auto n : cn[i] ) {
std::cout << "\t\t\"" << n->getInstanceName() << "\"\n";
}
}
Expand Down

0 comments on commit 50a585c

Please sign in to comment.