X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=kernel%2Fsrc%2FbbtkBlackBox.cxx;h=a249bfc79f9193fadebce4d7d02e4aa71054c0bc;hb=2d564c78c449d67b1d85511ba9601d3afb57c924;hp=795d8d490e6ac45e6425f081e6308d37108782ec;hpb=8c690fedb5ea897b6a69584e1e237cb5dbad97a5;p=bbtk.git diff --git a/kernel/src/bbtkBlackBox.cxx b/kernel/src/bbtkBlackBox.cxx index 795d8d4..a249bfc 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: 2009/05/28 08:12:05 $ - Version: $Revision: 1.46 $ + Date: $Date: 2012/07/26 08:28:31 $ + Version: $Revision: 1.55 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -48,8 +48,6 @@ namespace bbtk { - - static bool bbmgSomeBoxExecuting = false; static bool bbmgFreezeExecution = false; static std::set bbmgExecutionList; @@ -111,9 +109,14 @@ namespace bbtk bbmExecuting(false), bbmName(name), bbmBoxProcessMode("Pipeline"), + bbLetRecursiveExecuteManualMode(false), bbmParent() { + //JCP 02-11-09 + // bbmBoxProcessMode = "Pipeline"; +//std::cout<<"JCP BlackBox::BlackBox(const std::string &name) name=" < BlackBox::BlackBox(\"" < BlackBox::BlackBox(" <GetHelp(full); @@ -193,7 +199,6 @@ namespace bbtk //========================================================================= - /// Returns true if the UserBlackBox has an input of name name bool BlackBox::bbHasInput(const std::string& name) const { bbtkBlackBoxDebugMessage("kernel",8, @@ -209,7 +214,6 @@ namespace bbtk //========================================================================= - /// Returns true if the UserBlackBox has an output of name name bool BlackBox::bbHasOutput(const std::string& name) const { bbtkBlackBoxDebugMessage("kernel",8,"BlackBox::bbHasOutput(\"" @@ -224,7 +228,6 @@ namespace bbtk //========================================================================= - /// Gets the output type of a given name TypeInfo BlackBox::bbGetOutputType( const std::string &name ) const { bbtkBlackBoxDebugMessage("kernel",8, @@ -238,7 +241,6 @@ namespace bbtk //========================================================================= //========================================================================= - /// Gets the input type of a given name TypeInfo BlackBox::bbGetInputType( const std::string &name ) const { bbtkBlackBoxDebugMessage("kernel",8, @@ -253,7 +255,6 @@ namespace bbtk //========================================================================= - /// Allocates the i/o connectors of the black box void BlackBox::bbAllocateConnectors() { bbtkBlackBoxDebugMessage("kernel",8, @@ -280,13 +281,11 @@ namespace bbtk bbGetOutputConnectorMap()[o->second->GetName()] = new BlackBoxOutputConnector(GetThisPointer()); } - } //========================================================================= //========================================================================= - /// Desallocates the i/o connectors of the black box void BlackBox::bbDesallocateConnectors() { bbtkBlackBoxDebugMessage("kernel",8, @@ -308,14 +307,12 @@ namespace bbtk delete (o->second); } - bbtkDebugDecTab("kernel",8); - + bbtkDebugDecTab("kernel",8); } //========================================================================= //========================================================================= - /// Copies the input / output values from another box void BlackBox::bbCopyIOValues(BlackBox& from) { bbtkBlackBoxDebugMessage("kernel",1, @@ -346,7 +343,6 @@ namespace bbtk } bbtkDebugDecTab("kernel",9); - } //========================================================================= @@ -359,69 +355,69 @@ namespace bbtk #ifdef USE_WXWIDGETS || Wx::IsSomeWindowAlive() #endif - ); + ); } //========================================================================= - //========================================================================= - /// User overloadable destruction method of a black box - void BlackBox::bbUserDelete() - { - bbtkBlackBoxDebugMessage("process",5, - "=> BlackBox::bbUserDelete()" - <<" : not overloaded; using standard deletion" - < BlackBox::bbSetInputChangeTime("<SetChangeTime(t) ) - { - bool was_up_to_date = bbIsUpToDate(); - // If new time is greater than the old max time of inputs - if ( mMaxInputChangeTime.Set(t) ) - { - // If the box turned out-of-date - if ( was_up_to_date && bbIsOutOfDate() ) - { - // - if ( ( bbBoxProcessModeIsReactive() || - (c==bbGetInputConnectorMap().find("BoxExecute")->second)) - && (bbCanReact() ) ) - { - bbtkBlackBoxDebugMessage("change",2, - "an input of " - <() ); - } - // Have to propagate the modification to aval boxes - OutputConnectorMapType::iterator i; - for (i = bbGetOutputConnectorMap().begin(); - i != bbGetOutputConnectorMap().end(); - ++i) - { - i->second->SetChangeTime(t); - } - // update the MinOutputChangeTime - mMinOutputChangeTime.Set(t); - } - } - } - } - //========================================================================= - - //========================================================================= - /// Sets the ChangeTime of output - void BlackBox::bbSetOutputChangeTime(BlackBoxOutputConnector* c, - const ChangeTime& t) - { - bbtkBlackBoxDebugMessage("change",1, - "==> BlackBox::bbSetOutputChangeTime("<SetChangeTime(t); - // c->GetChangeTime() = t; - // bbUpdateMinOutputChangeTime(t); - // propagate - - } - //========================================================================= - */ - - /* - //========================================================================= - void BlackBox::bbUpdateMaxInputChangeTime(const ChangeTime& t) - { - - - if ( t > mMaxInputChangeTime ) - { - mMaxInputChangeTime = t; - if ( mMinOutputChangeTime > mMaxInputChangeTime ) - { - - } - } - - } - //========================================================================= - - //========================================================================= - void bbUpdateMinOutputChangeTime(const ChangeTime& t) - { - ChangeTime old = mMinOutputChangeTime; - mMinOutputChangeTime = MAXLONG; - OutputConnectorMapType::iterator i; - for (i = bbGetOutputConnectorMap.begin(); - i != bbGetOutputConnectorMap.end(); - ++i) - { - if (i->second->GetChangeTime() < mMinOutputChangeTime) - mMinOutputChangeTime = i->second->GetChangeTime(); - } - if ( mMinOutputChangeTime < old ) - { - } - - } - //========================================================================= - */ - - //========================================================================= - /// Signals that the BlackBox has been modified through - /// the input connector c - /// and propagates it downward - /// ** NOT USER INTENDED ** void BlackBox::bbSetStatusAndPropagate(BlackBoxInputConnector* c, IOStatus s) { @@ -579,11 +465,11 @@ namespace bbtk o->second->SetStatus(OUTOFDATE); o->second->SignalChange(GetThisPointer(),o->first); } - } + } - if ( ( bbBoxProcessModeIsReactive() || - (c==bbGetInputConnectorMap().find("BoxExecute")->second)) - && (bbCanReact() ) ) + if ( ( bbBoxProcessModeIsReactive() + || (c==bbGetInputConnectorMap().find("BoxExecute")->second)) + && (bbCanReact() ) ) { bbtkBlackBoxDebugMessage("change",2, "-> Execution triggered by Reactive mode or BoxExecute input change"< BlackBox::bbSignalOutputModification(" <second->SignalChange(GetThisPointer(),i->first); // } - } + } // for if (reaction) bbGlobalProcessExecutionList(); bbtkBlackBoxDebugMessage("change",5, "<= BlackBox::bbSignalOutputModification()" <bbCreateWindow(); // Updates its inputs - IOStatus s = bbUpdateInputs(); - - if ( (s != UPTODATE) || - bbBoxProcessModeIsAlways() ) + +// IOStatus s; + IOStatus s=UPTODATE; +// IOStatus s=OUTOFDATE; +// IOStatus s=MODIFIED; + + + if ( ( bbBoxProcessModeIsManual()==false ) || + ( (bbBoxProcessModeIsManual()==true) && (bbLetRecursiveExecuteManualMode==true) ) ) + { + s = bbUpdateInputs(); + } + + if ( (s != UPTODATE) || bbBoxProcessModeIsAlways() ) { // Displays the window (WxBlackbox) // bbShowWindow(caller); // Actual processing (virtual) - this->bbProcess(); - - - // Update the I/O statuses - bbComputePostProcessStatus(); + if ( ( bbBoxProcessModeIsManual()==false ) || + ( (bbBoxProcessModeIsManual()==true)&&(bbLetRecursiveExecuteManualMode==true) ) + ) + { + this->bbProcess(); + } // Manual analysis + +//EED ups if ((bbBoxProcessModeIsManual()==true) && (bbLetRecursiveExecuteManualMode==false)) +//EED ups { +//EED ups bbSignalOutputModification(true); +//EED ups } + + + // Update the I/O statuses + bbComputePostProcessStatus(); } else { @@ -857,8 +774,7 @@ namespace bbtk bbSetExecuting(false); bbGlobalSetSomeBoxExecuting(wasExecuting); - return; - + return; } //========================================================================= @@ -867,9 +783,6 @@ namespace bbtk //========================================================================= - /// Updates the BlackBox inputs - /// Calls RecursiveExecute on all BlackBoxInputConnector - /// \returns The maximum of final IOStatus after each input update IOStatus BlackBox::bbUpdateInputs() { bbtkBlackBoxDebugMessage("process",4, @@ -904,16 +817,13 @@ namespace bbtk bbtkBlackBoxDebugMessage("process",4, "<= BlackBox::bbUpdateInputs()" - < BlackBox::bbComputePostProcessStatus()" @@ -946,18 +856,28 @@ namespace bbtk for ( o = bbGetOutputConnectorMap().begin(); o!= bbGetOutputConnectorMap().end(); ++o) { - o->second->SetStatus(new_output_status); + +//EED if ( ( bbBoxProcessModeIsManual()==false ) || +//EED ( (bbBoxProcessModeIsManual()==true) && (bbLetRecursiveExecuteManualMode==true) ) +//EED ) +//EED { + o->second->SetStatus(new_output_status); +//EED } else { +//EED if (( (bbBoxProcessModeIsManual()==true) && (bbLetRecursiveExecuteManualMode==false) ) ) +//EED { +//EED o->second->SetStatus(UPTODATE); +//EED } +//EED } // Manual analysis + } bbtkBlackBoxDebugMessage("process",4, "<= BlackBox::bbComputePostProcessStatus()" - < to the connection c void BlackBox::bbConnectInput( const std::string& name, Connection* c) { bbtkBlackBoxDebugMessage("connection",2, @@ -965,7 +885,6 @@ namespace bbtk <GetFullName()<<")" <second->SetConnection(c); // The input *MUST* be set OUTOFDATE to update its input on next execution bbSetStatusAndPropagate(i->second,OUTOFDATE); - + bbtkBlackBoxDebugMessage("connection",2, "<== BlackBox::bbConnectInput(\"" <GetFullName()<<")" - < to the connection c void BlackBox::bbConnectOutput( const std::string& name, Connection* c) { bbtkBlackBoxDebugMessage("connection",2, "==> BlackBox::bbConnectOutput(\""<GetFullName()<<")" <GetFullName()<<")" - < from the connection c - void BlackBox::bbDisconnectInput( const std::string& name, Connection* c) + void BlackBox::bbDisconnectInput( const std::string& name, Connection* c) { bbtkBlackBoxDebugMessage("connection",2, "==> BlackBox::bbDisconnectInput(\""<GetFullName()<<")" - < from the connection c - void BlackBox::bbDisconnectOutput( const std::string& name, Connection* c) + void BlackBox::bbDisconnectOutput( const std::string& name, Connection* c) { bbtkBlackBoxDebugMessage("connection",2, "==> BlackBox::bbDisconnectOutput(\""<GetOutputDescriptor(ii->first); tempStrTypeName=id->GetTypeName(); SubsBrackets(tempStrTypeName); - std::string Name(ii->first); - SubsBrackets(Name); + std::string Name(ii->first); + SubsBrackets(Name); labelStr=labelStr+"<"+ii->first.c_str()+"> " + valueStr + Name.c_str() + " ["+tempStrTypeName+"]"; } labelStr = labelStr+ " } }" ; @@ -1330,35 +1263,35 @@ namespace bbtk //========================================================================= - void BlackBox::bbShowRelations(BlackBox::Pointer parentblackbox, + void BlackBox::bbPrintHelp(BlackBox::Pointer parentblackbox, int detail, int level /*,Factory *factory*/ ) { if (this->bbGetDescriptor()->GetPackage()) { - bbtkBlackBoxMessage("Help",1,"Black Box '"<bbGetDescriptor()->GetPackage()->GetName() <<"::"<bbGetDescriptor()->GetTypeName()<<">"<bbGetDescriptor()->GetTypeName()<<">"<bbGetDescriptor()->GetTypeName()<<">"< iname; std::vector ivalue; @@ -1370,106 +1303,124 @@ namespace bbtk unsigned int valuelmax = 0; // unsigned int connlmax = 0; for ( i = mInputConnectorMap.begin(); i != mInputConnectorMap.end(); ++i ) - { - iname.push_back(i->first); - if (iname.back().size()>namelmax) namelmax = iname.back().size(); - ivalue.push_back(bbGetInputAsString(i->first)); - if (ivalue.back().size()>valuelmax) valuelmax = ivalue.back().size(); - std::string s(""); - Connection* con = i->second->GetConnection(); - if (con!=0){ - s = con->GetOriginalBlackBoxFrom()->bbGetName(); - s += "."; - s += con->GetOriginalBlackBoxFromOutput(); - } // if con - iconn.push_back(s); - istatus.push_back(GetIOStatusString(i->second->GetStatus())); - } + { + iname.push_back(i->first); + if (iname.back().size()>namelmax) namelmax = iname.back().size(); + ivalue.push_back(bbGetInputAsString(i->first)); + if (ivalue.back().size()>valuelmax) valuelmax = ivalue.back().size(); + std::string s(""); + Connection* con = i->second->GetConnection(); + if (con!=0){ + s = con->GetOriginalBlackBoxFrom()->bbGetName(); + s += "."; + s += con->GetOriginalBlackBoxFromOutput(); + } // if con + iconn.push_back(s); + istatus.push_back(GetIOStatusString(i->second->GetStatus())); + } OutputConnectorMapType::iterator o; std::vector oname; std::vector ovalue; std::vector > oconn; std::vector ostatus; for ( o = mOutputConnectorMap.begin(); o != mOutputConnectorMap.end(); ++o ) - { - oname.push_back(o->first); - if (oname.back().size()>namelmax) namelmax = oname.back().size(); - ovalue.push_back(bbGetOutputAsString(o->first)); - if (ovalue.back().size()>valuelmax) valuelmax = ovalue.back().size(); - std::vector ss; - const std::vector& con - = o->second->GetConnectionVector(); - std::vector::const_iterator c; - for (c=con.begin();c!=con.end();++c) - { - std::string s; - s = (*c)->GetOriginalBlackBoxTo()->bbGetName(); - s += "."; - s += (*c)->GetOriginalBlackBoxToInput(); - ss.push_back(s); - } // if con - oconn.push_back(ss); - ostatus.push_back(GetIOStatusString(o->second->GetStatus())); - } + { + oname.push_back(o->first); + if (oname.back().size()>namelmax) + namelmax = oname.back().size(); + ovalue.push_back(bbGetOutputAsString(o->first)); + if (ovalue.back().size()>valuelmax) + valuelmax = ovalue.back().size(); + std::vector ss; + const std::vector& con + = o->second->GetConnectionVector(); + std::vector::const_iterator c; + for (c=con.begin();c!=con.end();++c) + { + std::string s; + s = (*c)->GetOriginalBlackBoxTo()->bbGetName(); + s += "."; + s += (*c)->GetOriginalBlackBoxToInput(); + ss.push_back(s); + } // if con + oconn.push_back(ss); + ostatus.push_back(GetIOStatusString(o->second->GetStatus())); + } if (iname.size()) - bbtkBlackBoxMessage("Help",1," * Inputs : "<::iterator i1,i2,i3,i4; for (i1=iname.begin(),i2=ivalue.begin(),i3=iconn.begin(),i4=istatus.begin(); - i1!=iname.end(),i2!=ivalue.end(),i3!=iconn.end(),i4!=istatus.end(); - ++i1,++i2,++i3,++i4) - { - std::string name(*i1); - name += "'"; - name.append(1+namelmax-name.size(),' '); - std::string value(*i2); - value += "'"; - value.append(1+valuelmax-value.size(),' '); - if (i3->size()) - bbtkBlackBoxMessage("Help",1," '"<size()) + bbtkBlackBoxMessage("help",1," '"<