From: eduardo.davila@creatis.insa-lyon.fr Date: Wed, 15 Jan 2025 07:49:04 +0000 (+0100) Subject: Test code X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=df677700f40ee5fc829d4de4764cdddc9bb36a24;p=bbtk.git Test code --- diff --git a/kernel/src/bbtkBlackBox.cxx b/kernel/src/bbtkBlackBox.cxx index cb68669..0b76e37 100644 --- a/kernel/src/bbtkBlackBox.cxx +++ b/kernel/src/bbtkBlackBox.cxx @@ -76,6 +76,7 @@ void print_trace() namespace bbtk { + static bool bbmgInConstruction = false; static bool bbmgSomeBoxExecuting = false; static bool bbmgFreezeExecution = false; static std::set bbmgExecutionList; @@ -521,24 +522,28 @@ namespace bbtk "=> BlackBox::bbSignalOutputModification(" < BlackBox::bbSignalOutputModification(" <second->GetStatus()==UPTODATE) - // { - i->second->SignalChange(GetThisPointer(),i->first); - // Has to notify the output "BoxChange" also - if (output != "BoxChange") - { - i = bbGetOutputConnectorMap().find("BoxChange"); - if ( i != bbGetOutputConnectorMap().end() ) - { - i->second->SignalChange(GetThisPointer(),i->first); - } - } - if (reaction) bbGlobalProcessExecutionList(); - // } - + if (bbGlobalGetInConstruction()==false) + { + + OutputConnectorMapType::iterator i = + bbGetOutputConnectorMap().find(output); + + + if ( i == bbGetOutputConnectorMap().end() ) + { + bbtkError("BlackBox["<second->GetStatus()==UPTODATE) + // { + i->second->SignalChange(GetThisPointer(),i->first); + // Has to notify the output "BoxChange" also + if (output != "BoxChange") + { + i = bbGetOutputConnectorMap().find("BoxChange"); + if ( i != bbGetOutputConnectorMap().end() ) + { + i->second->SignalChange(GetThisPointer(),i->first); + } + } + if (reaction=true) + { + bbGlobalProcessExecutionList(); + } // if reaction + // } + + } // if inConstruction + bbtkBlackBoxDebugMessage("change",5, "<= BlackBox::bbSignalOutputModification(" <& output, bool reaction) { bbtkBlackBoxDebugMessage("change",5, "=> BlackBox::bbSignalOutputModification(vector of outputs)" <::const_iterator o; - bool changed = false; - for (o=output.begin();o!=output.end();++o) - { - // the output "BoxChange" must be signaled **AFTER** all others - if (*o == "BoxChange") continue; - // Look for the connector - i = bbGetOutputConnectorMap().find(*o); - if ( i == bbGetOutputConnectorMap().end() ) - { - bbtkError("BlackBox["<second->GetStatus()==UPTODATE) - // { - i->second->SignalChange(GetThisPointer(),i->first); - changed = true; - // } - } - // Has to notify the output "BoxChange" also - i = bbGetOutputConnectorMap().find("BoxChange"); - if ( changed && (i != bbGetOutputConnectorMap().end())) + + if (bbGlobalGetInConstruction()==false) { - // if (i->second->GetStatus()==UPTODATE) - // { - i->second->SignalChange(GetThisPointer(),i->first); - if (reaction) bbGlobalProcessExecutionList(); - // } - } - + + OutputConnectorMapType::iterator i; + std::vector::const_iterator o; + bool changed = false; + for (o=output.begin();o!=output.end();++o) + { + // the output "BoxChange" must be signaled **AFTER** all others + if (*o == "BoxChange") continue; + // Look for the connector + i = bbGetOutputConnectorMap().find(*o); + if ( i == bbGetOutputConnectorMap().end() ) + { + bbtkError("BlackBox["<second->GetStatus()==UPTODATE) + // { + i->second->SignalChange(GetThisPointer(),i->first); + changed = true; + // } + } + // Has to notify the output "BoxChange" also + i = bbGetOutputConnectorMap().find("BoxChange"); + if ( changed && (i != bbGetOutputConnectorMap().end())) + { + // if (i->second->GetStatus()==UPTODATE) + // { + i->second->SignalChange(GetThisPointer(),i->first); + if (reaction) bbGlobalProcessExecutionList(); + // } + } // if changed + } // if inConstruction bbtkBlackBoxDebugMessage("change",5, "<= BlackBox::bbSignalOutputModification(vector of outputs)" <bbProcess(); @@ -770,7 +787,7 @@ printf("EED BlackBox::bbRecursiveExecute bbProcess start %s \n", bbGetFullName() //auto duration = std::chrono::duration_cast(stop - start); //printf("EED BlackBox::bbRecursiveExecute bbProcess time= %ld %s \n", duration.count() , bbGetFullName().c_str() ); -printf("EED BlackBox::bbRecursiveExecute bbProcess end %s \n", bbGetFullName().c_str() ); +//printf("EED BlackBox::bbRecursiveExecute bbProcess end %s \n", bbGetFullName().c_str() ); } // Manual analysis @@ -1516,6 +1533,15 @@ printf("EED BlackBox::bbRecursiveExecute bbProcess end %s \n", bbGetFullName().c //========================================================================= +bool BlackBox::bbGlobalGetInConstruction() +{ + return bbmgInConstruction; +} + +void BlackBox::bbGlobalSetInConstruction(bool b) +{ + bbmgInConstruction = b; +} } // EO namespace bbtk diff --git a/kernel/src/bbtkBlackBox.h b/kernel/src/bbtkBlackBox.h index d81ff21..2bd1bbd 100644 --- a/kernel/src/bbtkBlackBox.h +++ b/kernel/src/bbtkBlackBox.h @@ -341,6 +341,9 @@ namespace bbtk //@} //JCP 09-06-09 + + static bool bbGlobalGetInConstruction(); + static void bbGlobalSetInConstruction(bool b); protected: //================================================================== diff --git a/kernel/src/bbtkComplexBlackBox.cxx b/kernel/src/bbtkComplexBlackBox.cxx index 516c7b8..b13f5aa 100644 --- a/kernel/src/bbtkComplexBlackBox.cxx +++ b/kernel/src/bbtkComplexBlackBox.cxx @@ -275,6 +275,7 @@ namespace bbtk "**> ComplexBlackBox::bbExecute()" <second->bbExecute(force); } // for i } + + bbGlobalSetInConstruction(false); + bbtkBlackBoxDebugMessage("process",2, "<** ComplexBlackBox::bbExecute()" <