MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / read_nodes

Function read_nodes

cp-profiler/src/cpprofiler/db_handler.cpp:57–95  ·  view source on GitHub ↗

Reads all nodes from a database and builds the tree; returns `true` on success

Source from the content-addressed store, hash-verified

55
56/// Reads all nodes from a database and builds the tree; returns `true` on success
57static bool read_nodes(QSqlDatabase *db, Execution &ex)
58{
59 const auto query = "select * from Nodes;";
60
61 QSqlQuery select_stmt (*db);
62 select_stmt.prepare(query);
63
64 auto &tree = ex.tree();
65
66 const auto total_nodes = count_nodes(db);
67 print("We have {} nodes", total_nodes);
68
69 tree.db_initialize(total_nodes);
70
71 bool success = select_stmt.exec();
72
73 if(!success) return false;
74
75 while (select_stmt.next())
76 {
77 const auto nid = NodeID(select_stmt.value(0).toInt());
78 const auto pid = NodeID(select_stmt.value(1).toInt());
79 const auto alt = select_stmt.value(2).toInt();
80 const auto kids = select_stmt.value(3).toInt();
81 const auto status = tree::NodeStatus(select_stmt.value(4).toInt());
82 const auto label = select_stmt.value(5).toString().toStdString();
83
84 if (pid == NodeID::NoNode)
85 {
86 tree.db_createRoot(nid, label);
87 }
88 else
89 {
90 tree.db_addChild(nid, pid, alt, status, label);
91 }
92 }
93
94 return success;
95}
96
97/// Read all bookmarks from the database
98static bool read_bookmarks(QSqlDatabase *db, Execution &ex)

Callers 1

load_executionFunction · 0.85

Calls 10

count_nodesFunction · 0.85
nextMethod · 0.80
NodeStatusEnum · 0.70
printFunction · 0.50
NodeIDClass · 0.50
db_initializeMethod · 0.45
valueMethod · 0.45
toStringMethod · 0.45
db_createRootMethod · 0.45
db_addChildMethod · 0.45

Tested by

no test coverage detected