diff --git a/CEP/BB/BBSControl/include/BBSControl/BBSMultiStep.h b/CEP/BB/BBSControl/include/BBSControl/BBSMultiStep.h index 0b268d15bb8a769423b004ab81978068ce9168a8..a3d82253a06ba0104c82a3bf3845db186dbba7fa 100644 --- a/CEP/BB/BBSControl/include/BBSControl/BBSMultiStep.h +++ b/CEP/BB/BBSControl/include/BBSControl/BBSMultiStep.h @@ -52,6 +52,12 @@ namespace LOFAR virtual void print(ostream& os) const; private: + // Check to see if there's an infinite recursion present in the + // definition of a BBSMultiStep. This can happen when one of the steps + // (identified by the argument \a name) defining the BBSMultiStep refers + // directly or indirectly to that same BBSMultiStep. + void infiniteRecursionCheck(const string& name) const; + // Vector holding a sequence of BBSSteps. vector<const BBSStep*> itsSteps; }; diff --git a/CEP/BB/BBSControl/include/BBSControl/BBSStep.h b/CEP/BB/BBSControl/include/BBSControl/BBSStep.h index b112a367470175c7b3d5bc1dcaada0d5acd0758d..be7d346d61d20f732a7c5df20529668180db4861 100644 --- a/CEP/BB/BBSControl/include/BBSControl/BBSStep.h +++ b/CEP/BB/BBSControl/include/BBSControl/BBSStep.h @@ -67,7 +67,10 @@ namespace LOFAR virtual void print(ostream& os) const; // Return the name of this step. - const string& name() const { return itsName; } + const string& getName() const { return itsName; } + + // Return a pointer to the parent of this step. + const BBSStep* getParent() const { return itsParent; } // Return the full name of this step. The full name consists of the name // of this step, preceeded by that of its parent, etc., separated by @@ -93,12 +96,6 @@ namespace LOFAR const ACC::APS::ParameterSet& parSet, const BBSStep* parent); - // Check to see if there's an infinite recursion present in the - // definition of a BBSStep. This can happen when one of the steps - // (identified by the argument \a name) defining a BBSMultiStep refers - // directly or indirectly to that same BBSMultiStep. - void infiniteRecursionCheck(const string& name) const; - private: // Override the default values, "inherited" from the parent step object, // for those members that are specified in \a parSet. diff --git a/CEP/BB/BBSControl/src/BBSMultiStep.cc b/CEP/BB/BBSControl/src/BBSMultiStep.cc index 0384b6a5553cbdbdd07683ca096753723cd80bc1..ae078033ca99e7b9d9bddffdaddb8f6f31925f17 100644 --- a/CEP/BB/BBSControl/src/BBSMultiStep.cc +++ b/CEP/BB/BBSControl/src/BBSMultiStep.cc @@ -26,6 +26,7 @@ #include <APS/ParameterSet.h> #include <Common/LofarLogger.h> #include <BBSControl/StreamFormatting.h> +#include <BBSControl/Exceptions.h> namespace LOFAR { @@ -46,12 +47,6 @@ namespace LOFAR // Create a new step for each name in \a steps. for (uint i = 0; i < steps.size(); ++i) { - // Should add something like BBSStep::infiniteRecursionCheck(name), - // which checks, RECURSIVELY, if steps[i] may be used for the step to - // be created. -// ASSERTSTR(name != steps[i], -// "Infinite recursion detected in BBSStep definition! " -// "Please check your ParameterSet file"); infiniteRecursionCheck(steps[i]); itsSteps.push_back(BBSStep::create(steps[i], parset, this)); } @@ -72,6 +67,7 @@ namespace LOFAR void BBSMultiStep::print(ostream& os) const { + LOG_TRACE_FLOW(AUTO_FUNCTION_NAME); BBSStep::print(os); Indent id; for (uint i = 0; i < itsSteps.size(); ++i) { @@ -80,11 +76,18 @@ namespace LOFAR } -// void BBSMultiStep::addStep(const BBSStep*& aStep) -// { -// itsSteps.push_back(aStep); -// } - + void BBSMultiStep::infiniteRecursionCheck(const string& name) const + { + LOG_TRACE_FLOW(AUTO_FUNCTION_NAME); + if (name == getName()) { + THROW (BBSControlException, + "Infinite recursion detected in defintion of BBSStep \"" + << name << "\". Please check your ParameterSet file."); + } + const BBSMultiStep* parent; + if ((parent = dynamic_cast<const BBSMultiStep*>(getParent())) != 0) + parent->infiniteRecursionCheck(name); + } } // namespace BBS diff --git a/CEP/BB/BBSControl/src/BBSStep.cc b/CEP/BB/BBSControl/src/BBSStep.cc index bb619de08d4ec110faabb817e6844f1055617031..d63f66b3a860b8e931aac190f2bd8915e2e39b51 100644 --- a/CEP/BB/BBSControl/src/BBSStep.cc +++ b/CEP/BB/BBSControl/src/BBSStep.cc @@ -130,17 +130,6 @@ namespace LOFAR } - void BBSStep::infiniteRecursionCheck(const string& name) const - { - LOG_TRACE_FLOW(AUTO_FUNCTION_NAME); - if (name == itsName) - THROW (BBSControlException, - "Infinite recursion detected in defintion of BBSStep \"" - << name << "\". Please check your ParameterSet file."); - if (itsParent) itsParent->infiniteRecursionCheck(name); - } - - //##-------- P r i v a t e m e t h o d s --------##// void BBSStep::setParms(const ParameterSet& ps)