X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=kernel%2Fsrc%2FbbtkBlackBox.cxx;h=2e5716e3f9ba87e897ae7f3a69d7b10568af3743;hb=e746553dde41260204aae07b809f484544de10b9;hp=b7a7ec78f4ee6d3d71be5de580d38085f24954c3;hpb=3928b4ad06b5b5fd142f696f58a7828d064e2883;p=bbtk.git diff --git a/kernel/src/bbtkBlackBox.cxx b/kernel/src/bbtkBlackBox.cxx index b7a7ec7..2e5716e 100644 --- a/kernel/src/bbtkBlackBox.cxx +++ b/kernel/src/bbtkBlackBox.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkBlackBox.cxx,v $ Language: C++ - Date: $Date: 2008/12/08 12:53:45 $ - Version: $Revision: 1.32 $ + Date: $Date: 2008/12/10 09:33:18 $ + Version: $Revision: 1.36 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -444,16 +444,18 @@ namespace bbtk //========================================================================= - void BlackBox::AddChangeObserver(const std::string& output_name, + void BlackBox::bbAddOutputObserver(const std::string& output, OutputChangeCallbackType f) { + bbGetOutputConnector(output).AddChangeObserver(f); } //========================================================================= //========================================================================= - void BlackBox::RemoveChangeObserver(const std::string& output_name, + void BlackBox::bbRemoveOutputObserver(const std::string& output_name, OutputChangeCallbackType f) { + bbtkError("BlackBox::RemoveChangeObserver NOT IMPLEMENTED"); } //========================================================================= @@ -572,13 +574,17 @@ namespace bbtk void BlackBox::bbSetStatusAndPropagate(BlackBoxInputConnector* c, IOStatus s) { + bbtkDebugMessageInc("change",5, + "=> BlackBox::bbSetStatusAndPropagate(input," + <SetStatus(s); OutputConnectorMapType::const_iterator o; for ( o = bbGetOutputConnectorMap().begin(); o != bbGetOutputConnectorMap().end(); ++o ) { - // bbSetStatusAndPropagate(o->second, OUTOFDATE); if (o->second->GetStatus()==UPTODATE) { o->second->SetStatus(OUTOFDATE); @@ -590,93 +596,21 @@ namespace bbtk (c==bbGetInputConnectorMap().find("BoxExecute")->second)) && (bbCanReact() ) ) { - bbtkDebugMessage("modified",2, + bbtkDebugMessage("change",2, "-> Execution triggered by Reactive mode or BoxExecute input change"<() ); } + bbtkDebugMessageInc("change",5, + "<= BlackBox::bbSetStatusAndPropagate(input) [" + <GetStatus()==UPTODATE) - { - i->second->SetStatus(s); - i->second->SignalChange(GetThisPointer(),i->first); - } - */ - } - //========================================================================= - - - /// Signals that the BlackBox has been modified - /* - void BlackBox::bbSetModifiedStatus(BlackBoxInputConnector* c) - { - bbtkDebugMessage("modified",1, - "==> BlackBox::bbSetModifiedStatus("<second) ) - // && (bbCanReact())) - { - bbtkDebugMessage("modified",2, - "-> Hide triggered by WinHide input change" - <bbHideWindow(); - this->bbSetStatus(MODIFIED); - return; - } - if ( (c==bbGetInputConnectorMap().find("WinClose")->second) ) - // && (bbCanReact())) - { - bbtkDebugMessage("modified",2, - "-> Close triggered by WinClose input change" - <bbHideWindow(); - this->bbSetStatus(MODIFIED); - return; - } - - if ( ( bbBoxProcessModeIsReactive() || - (c==bbGetInputConnectorMap().find("BoxExecute")->second)) - && (bbCanReact() ) ) - { - bbtkDebugMessage("modified",2, - "-> Execution triggered by Reactive mode or BoxExecute input change"<bbSetStatus(MODIFIED); - bbGlobalAddToExecutionList( GetThisPointer() ); - } - - //else if ( bbGetStatus() == MODIFIED ) //! this->bbIsUptodate()) - // { -// bbtkDebugMessage("modified",2,"-> Already modified"< Status set to modified"<bbSetStatus(MODIFIED); - } - - this->bbSignalOutputModification(false); - - bbtkDebugMessageDec("process",5, - "<= BlackBox::bbSetModifiedStatus("< BlackBox::bbSignalOutputModification(" <second->GetStatus()==UPTODATE) - { - // i->second->SetStatus(MODIFIED); + // std::cout << "Stat = " + //<second->GetStatus()) + // <second->GetStatus()==UPTODATE) + // { i->second->SignalChange(GetThisPointer(),i->first); - } + // } } if (reaction) bbGlobalProcessExecutionList(); - bbtkDebugMessageDec("process",5, + bbtkDebugMessageDec("change",5, "<= BlackBox::bbSignalOutputModification() [" < BlackBox::bbSignalOutputModification(" <second->GetStatus()==UPTODATE) - { - // i->second->SetStatus(MODIFIED); + // if (i->second->GetStatus()==UPTODATE) + // { i->second->SignalChange(GetThisPointer(),i->first); // Has to notify the output "BoxChange" also if (output != "BoxChange") @@ -728,14 +665,13 @@ namespace bbtk i = bbGetOutputConnectorMap().find("BoxChange"); if ( i != bbGetOutputConnectorMap().end() ) { - // i->second->SetStatus(MODIFIED); i->second->SignalChange(GetThisPointer(),i->first); } } if (reaction) bbGlobalProcessExecutionList(); - } + // } - bbtkDebugMessageDec("process",5, + bbtkDebugMessageDec("change",5, "<= BlackBox::bbSignalOutputModification(" <& output, bool reaction) { - bbtkDebugMessageInc("process",5, + bbtkDebugMessageInc("change",5, "=> BlackBox::bbSignalOutputModification(vector of outputs) [" <second->GetStatus()==UPTODATE) - { - // i->second->SetStatus(MODIFIED); + + // if (i->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())) { - // Already OUTOFDATE : noting to do - if (i->second->GetStatus()==UPTODATE) - { - // i->second->SetStatus(MODIFIED); + // if (i->second->GetStatus()==UPTODATE) + // { i->second->SignalChange(GetThisPointer(),i->first); if (reaction) bbGlobalProcessExecutionList(); - } + // } } - bbtkDebugMessageDec("process",5, + bbtkDebugMessageDec("change",5, "<= BlackBox::bbSignalOutputModification(vector of outputs) [" <GetInputDescriptor(i->first)->GetTypeInfo() // == typeid(Void) ) // continue; + bbtkDebugMessageDec("change",2, + bbGetName()<<"."<first + <<" ["<second<<"] " + <<" status before update = '" + <second->GetStatus()) + <<"'"<second->BackwardUpdate(); IOStatus t = i->second->GetStatus(); if (t > s) s = t; + bbtkDebugMessageDec("change",2, + bbGetName()<<"."<first + <<" ["<second<<"] " + <<" status before process = '" + <second->GetStatus()) + <<"'"< BlackBox::bbComputePostProcessStatus() [" + <second->SetStatus(UPTODATE); + bbtkDebugMessage("change",2, + bbGetName()<<"."<first<<" : " + << GetIOStatusString(t) << " -> " + << GetIOStatusString(i->second->GetStatus()) + << std::endl); } - + bbtkDebugMessage("change",2, + bbGetName()<<" new output status : " + << GetIOStatusString(new_output_status) + <second->SetStatus(new_output_status); } + + bbtkDebugMessageInc("process",4, + "<= BlackBox::bbComputePostProcessStatus() [" + <second->SetConnection(c); - - // Check the status of the from.output of c - // to set the new status of the input - IOStatus s = MODIFIED; - if ( c->GetBlackBoxFrom()->bbGetOutputConnector(c->GetBlackBoxFromOutput()).GetStatus() == OUTOFDATE ) - s = OUTOFDATE; - bbSetStatusAndPropagate(i->second,s); + // The input *MUST* be set OUTOFDATE to update its input on next execution + bbSetStatusAndPropagate(i->second,OUTOFDATE); bbtkDebugMessage("connection",2, "<== BlackBox::bbConnectInput(\""