Skip to content
Snippets Groups Projects
Commit 838d1316 authored by Martin Killenberg's avatar Martin Killenberg
Browse files

Renamed CircularDependencyRecursionBreaker to CircularDependencyDetectionRecursionStopper

parent 06a3c447
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@
#include "ModuleImpl.h"
#include "Application.h"
#include "CircularDependencyRecursionBreaker.h"
#include "CircularDependencyDetectionRecursionStopper.h"
namespace ChimeraTK {
......@@ -109,7 +109,10 @@ namespace ChimeraTK {
/** Unique ID for the circular dependency network. 0 if the EntityOwner is not in a circular dependency network. */
size_t _circularNetworkHash{0};
detail::CircularDependencyRecursionBreaker _recursionBreaker;
/** Helper needed to stop the recusion when detecting circular dependency networks.
* Only used in the setp phase.
*/
detail::CircularDependencyDetectionRecursionStopper _recursionStopper;
};
} /* namespace ChimeraTK */
......
#ifndef CIRCULARDEPENDENCYRECURSIONBREAKER_H
#define CIRCULARDEPENDENCYRECURSIONBREAKER_H
#ifndef CIRCULAR_DEPENDENCY_DETECTION_RECURSION_STOPPER_H
#define CIRCULAR_DEPENDENCY_DETECTION_RECURSION_STOPPER_H
#include <cstddef>
......@@ -22,7 +22,7 @@ namespace ChimeraTK { namespace detail {
* After the call of startNewScan(), recusionDetected() returns false until setRecursionDetected() is called.
* If recursionDetected() after construction before calling startNewScan, an exeption is thrown.
*/
class CircularDependencyRecursionBreaker {
class CircularDependencyDetectionRecursionStopper {
static size_t _globalScanCounter;
size_t _localScanCounter;
......@@ -34,4 +34,4 @@ namespace ChimeraTK { namespace detail {
}} // namespace ChimeraTK::detail
#endif // CIRCULARDEPENDENCYRECURSIONBREAKER_H
#endif // CIRCULAR_DEPENDENCY_DETECTION_RECURSION_STOPPER_H
......@@ -135,14 +135,14 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
std::list<EntityOwner*> ApplicationModule::getInputModulesRecursively(std::list<EntityOwner*> startList) {
if(_recursionBreaker.recursionDetected()) {
if(_recursionStopper.recursionDetected()) {
return startList;
}
// If this module is already in the list we found a circular dependency.
// Remember this for the next time the recursive scan calls this function
if(std::count(startList.begin(), startList.end(), this)) {
_recursionBreaker.setRecursionDetected();
_recursionStopper.setRecursionDetected();
}
// Whether a cirular depencency has been detected or not, we must loop all inputs and add this module to the list so the calling
......
#include "CircularDependencyRecursionBreaker.h"
#include "CircularDependencyDetectionRecursionStopper.h"
#include <ChimeraTK/Exception.h>
namespace ChimeraTK { namespace detail {
size_t CircularDependencyRecursionBreaker::_globalScanCounter{0};
size_t CircularDependencyDetectionRecursionStopper::_globalScanCounter{0};
void CircularDependencyRecursionBreaker::startNewScan() { ++_globalScanCounter; }
void CircularDependencyRecursionBreaker::setRecursionDetected() { _localScanCounter = _globalScanCounter; }
bool CircularDependencyRecursionBreaker::recursionDetected() {
void CircularDependencyDetectionRecursionStopper::startNewScan() { ++_globalScanCounter; }
void CircularDependencyDetectionRecursionStopper::setRecursionDetected() { _localScanCounter = _globalScanCounter; }
bool CircularDependencyDetectionRecursionStopper::recursionDetected() {
if(_globalScanCounter == 0) {
throw ChimeraTK::logic_error(
"CircularDependencyRecursionBreaker::recursionDetected() called without starting a scan.");
"CircularDependencyDetectionRecursionStopper::recursionDetected() called without starting a scan.");
}
return _localScanCounter == _globalScanCounter;
}
......
......@@ -14,7 +14,7 @@
#include "VariableGroup.h"
#include <boost/container_hash/hash.hpp>
#include "ApplicationModule.h"
#include "CircularDependencyRecursionBreaker.h"
#include "CircularDependencyDetectionRecursionStopper.h"
namespace ChimeraTK {
......@@ -385,7 +385,7 @@ namespace ChimeraTK {
std::list<EntityOwner*> VariableNetworkNode::scanForCircularDepencency() {
// We are starting a new scan. Reset the indicator for already found circular dependencies.
detail::CircularDependencyRecursionBreaker::startNewScan();
detail::CircularDependencyDetectionRecursionStopper::startNewScan();
// find the feeder of the network
auto feeder = getOwner().getFeedingNode();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment