Skip to content

Commit 7beccb8

Browse files
add in missing function
1 parent 6a01edc commit 7beccb8

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

tests/testGraph.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ namespace UnitTest
2727
Node *TestGraph::fetchHead() const { return head_; }
2828
// Returns the name of the current head node in the graph
2929
std::string TestGraph::fetchHeadName() const { return head_ ? std::string(head_->name()) : "NO_NODE"; }
30+
// Run the graph in a piecewise manner - initially from a specific node, then from the last node - in order to emplace a set
31+
// of dynamic edges that we expect to exist at run time
32+
NodeConstants::ProcessResult TestGraph::runDynamic(Node *startNode, std::vector<EdgeDefinition> edges) const
33+
{
34+
currentGraph_->setUpdateRequired();
35+
36+
auto result = NodeConstants::ProcessResult::Unchanged;
37+
result = startNode->run();
38+
if (result == NodeConstants::ProcessResult::Failed)
39+
return result;
40+
41+
for (const auto &edge : edges)
42+
if (!currentGraph_->addEdge(edge) ||
43+
currentGraph_->findNode(edge.targetNode)->run() == NodeConstants::ProcessResult::Failed)
44+
return NodeConstants::ProcessResult::Failed;
45+
return result;
46+
}
3047
// Append new node to the graph
3148
Node *TestGraph::appendNode(const std::string &nodeType, const std::optional<std::string> &name)
3249
{

tests/testGraph.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class TestGraph : public DissolveGraph
4646
std::string fetchHeadName() const;
4747
// Returns reference to current top node in graph, cast to the known node type
4848
template <class NodeType> NodeType *head() const { return static_cast<NodeType *>(head_); }
49+
// Run the graph in a piecewise manner - initially from a specific node, then from the last node - in order to emplace a set
50+
// of dynamic edges that we expect to exist at run time
51+
NodeConstants::ProcessResult runDynamic(Node *startNode, std::vector<EdgeDefinition> edges) const;
4952
// Append new node to the graph
5053
Node *appendNode(const std::string &nodeType, const std::optional<std::string> &name = {});
5154
// Create species insertion node chain

0 commit comments

Comments
 (0)