X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkBlackBox.cxx;h=bb409a1be3297c99c44cd5d4cd698b27fe126a16;hb=b9da3baf83b7791357c78322e3280314ec782f40;hp=3aa696ab482be13d0e63864a488278ebcd596192;hpb=a26195c366a89795288009cf7e20f11afa494970;p=bbtk.git diff --git a/kernel/src/bbtkBlackBox.cxx b/kernel/src/bbtkBlackBox.cxx index 3aa696a..bb409a1 100644 --- a/kernel/src/bbtkBlackBox.cxx +++ b/kernel/src/bbtkBlackBox.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkBlackBox.cxx,v $ Language: C++ -Date: $Date: 2008/01/22 15:02:00 $ -Version: $Revision: 1.1 $ +Date: $Date: 2008/03/11 18:46:47 $ +Version: $Revision: 1.7 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See doc/license.txt or @@ -35,12 +35,19 @@ PURPOSE. See the above copyright notices for more information. namespace bbtk { + +//EED + static bool bbmgSomeBoxExecuting = false; + static bool bbmgFreezeExecution = false; + static std::set bbmgExecutionList; + + //========================================================================= BlackBox::BlackBox(const std::string &name) : bbmName(name), bbmStatus(MODIFIED), bbmBoxProcessMode("Pipeline"),bbmParent(NULL) { - bbtkDebugMessage("Core",7,"BlackBox::BlackBox(\"" + bbtkDebugMessage("Kernel",7,"BlackBox::BlackBox(\"" <bbDesallocateConnectors(); //printf("EED BlackBox::~BlackBox 02 \n"); - bbtkDebugDecTab("Core",7); + bbtkDebugDecTab("Kernel",7); } //========================================================================= @@ -74,7 +81,7 @@ namespace bbtk /// Destruction method of a black box void BlackBox::bbDelete() { - bbtkDebugMessage("Core",5,"BlackBox::bbDelete() [" + bbtkDebugMessage("Kernel",5,"BlackBox::bbDelete() [" <bbUserDelete(); } @@ -89,7 +96,7 @@ namespace bbtk "=> BlackBox::bbExecute() [" <GetInputDescriptorMap().find(name) != bbGetDescriptor()->GetInputDescriptorMap().end()); - bbtkDebugDecTab("Core",8); + bbtkDebugDecTab("Kernel",8); return r; } //========================================================================= @@ -165,11 +172,11 @@ namespace bbtk /// Returns true if the UserBlackBox has an output of name name bool BlackBox::bbHasOutput(const std::string& name) const { - bbtkDebugMessageInc("Core",8,"BlackBox::bbHasOutput(\"" + bbtkDebugMessageInc("Kernel",8,"BlackBox::bbHasOutput(\"" <GetOutputDescriptorMap().find(name) != bbGetDescriptor()->GetOutputDescriptorMap().end()); - bbtkDebugDecTab("Core",8); + bbtkDebugDecTab("Kernel",8); return r; } //========================================================================= @@ -179,11 +186,11 @@ namespace bbtk /// Gets the output type of a given name TypeInfo BlackBox::bbGetOutputType( const std::string &name ) const { - bbtkDebugMessageInc("Core",8, + bbtkDebugMessageInc("Kernel",8, "BlackBox::bbGetOutputType(\"" <GetOutputDescriptor(name)->GetTypeInfo(); - bbtkDebugDecTab("Core",8); + bbtkDebugDecTab("Kernel",8); return r; } //========================================================================= @@ -192,11 +199,11 @@ namespace bbtk /// Gets the input type of a given name TypeInfo BlackBox::bbGetInputType( const std::string &name ) const { - bbtkDebugMessageInc("Core",8, + bbtkDebugMessageInc("Kernel",8, "BlackBox::bbGetInputType(\"" <GetInputDescriptor(name)->GetTypeInfo(); - bbtkDebugDecTab("Core",8); + bbtkDebugDecTab("Kernel",8); return r; } //========================================================================= @@ -206,7 +213,7 @@ namespace bbtk /// Allocates the i/o connectors of the black box void BlackBox::bbAllocateConnectors() { - bbtkDebugMessageInc("Core",8, + bbtkDebugMessageInc("Kernel",8, "BlackBox::bbAllocateConnectors() [" <first<<"\""<first<<"\""<second->GetName()] = new BlackBoxInputConnector(this); } @@ -224,11 +231,11 @@ namespace bbtk BlackBoxDescriptor::OutputDescriptorMapType::const_iterator o; for ( o = omap.begin(); o != omap.end(); ++o ) { - bbtkDebugMessage("Core",8,"* Allocate \""<first<<"\""<first<<"\""<second->GetName()] = new BlackBoxOutputConnector(); } - bbtkDebugDecTab("Core",8); + bbtkDebugDecTab("Kernel",8); } //========================================================================= @@ -237,7 +244,7 @@ namespace bbtk /// Desallocates the i/o connectors of the black box void BlackBox::bbDesallocateConnectors() { - bbtkDebugMessageInc("Core",8, + bbtkDebugMessageInc("Kernel",8, "BlackBox::bbDesallocateConnectors()" <first<<"\""<first<<"\""<second); } OutputConnectorMapType::const_iterator o; for ( o = bbGetOutputConnectorMap().begin(); o != bbGetOutputConnectorMap().end(); ++o ) { - bbtkDebugMessage("Core",8,"* Delete \""<first<<"\""<first<<"\""<second); } - bbtkDebugDecTab("Core",8); + bbtkDebugDecTab("Kernel",8); } //========================================================================= @@ -266,7 +273,7 @@ namespace bbtk /// Copies the input / output values from another box void BlackBox::bbCopyIOValues(BlackBox& from) { - bbtkDebugMessageInc("Core",9, + bbtkDebugMessageInc("Kernel",9, "BlackBox::bbCopyIOValues(" <bbSetOutput(output, from.bbGetOutput(output) ); } - bbtkDebugDecTab("Core",9); + bbtkDebugDecTab("Kernel",9); } //========================================================================= @@ -303,7 +310,7 @@ namespace bbtk { return ( bbGlobalGetSomeBoxExecuting() #ifdef _USE_WXWIDGETS_ - || WxBlackBox::bbGlobalIsSomeWindowAlive() + || Wx::IsSomeWindowAlive() #endif ); } @@ -465,10 +472,10 @@ namespace bbtk } if (reaction) bbGlobalProcessExecutionList(); - bbtkDebugMessageDec("Process",5, - "<= BlackBox::bbSignalOutputModification(" - < to the connection c void BlackBox::bbConnectInput( const std::string& name, Connection* c) { - bbtkDebugMessageInc("Core",7, + bbtkDebugMessageInc("Kernel",7, "BlackBox::bbConnectInput(\""< to the connection c void BlackBox::bbConnectOutput( const std::string& name, Connection* c) { - bbtkDebugMessageInc("Core",7, + bbtkDebugMessageInc("Kernel",7, "BlackBox::bbConnectOutput(\""<second->SetConnection(c); - bbtkDebugDecTab("Core",7); + bbtkDebugDecTab("Kernel",7); } //========================================================================= @@ -593,7 +600,7 @@ namespace bbtk /// Disconnects the input from the connection c void BlackBox::bbDisconnectInput( const std::string& name, Connection* c) { - bbtkDebugMessageInc("Core",7, + bbtkDebugMessageInc("Kernel",7, "BlackBox::bbDisconnectInput(\""<second->UnsetConnection(c); - bbtkDebugDecTab("Core",7); + bbtkDebugDecTab("Kernel",7); } //========================================================================= @@ -615,7 +622,7 @@ namespace bbtk /// Disconnects the output from the connection c void BlackBox::bbDisconnectOutput( const std::string& name, Connection* c) { - bbtkDebugMessageInc("Core",7, + bbtkDebugMessageInc("Kernel",7, "BlackBox::bbDisconnectOutput(\""<second->UnsetConnection(c); - bbtkDebugDecTab("Core",7); + bbtkDebugDecTab("Kernel",7); } //========================================================================= @@ -649,28 +656,40 @@ namespace bbtk // Looks for the adaptor if (bbGetOutputType(output).name() != typeid(std::string).name() ) { - BlackBox* a = 0; - try + // Look for factory + Package* p = bbGetDescriptor()->GetPackage(); + if ((p != 0) && ( ! p->GetFactorySet().empty() ) ) { - a = NewAdaptor( - bbGetOutputType(output), - typeid(std::string), - ""); - } catch (bbtk::Exception e) + Factory* f = *p->GetFactorySet().begin(); + BlackBox* a = 0; + try + { + a = f->NewAdaptor( + bbGetOutputType(output), + typeid(std::string), + ""); + } catch (bbtk::Exception e) + { + } + if (a!=NULL){ + // bbUpdate(); + a->bbSetInput("In",bbGetOutput(output)); + a->bbExecute(); + v = a->bbGetOutput("Out").unsafe_get() ; + } else { + v="? (no adaptor found)"; + } + } + else { + v="? (no factory found)"; } - if (a!=NULL){ - // bbUpdate(); - a->bbSetInput("In",bbGetOutput(output)); - a->bbExecute(); - v = a->bbGetOutput("Out").unsafe_get() ; - } else { - v="? (no adaptor found)"; - } - } else { - // bbUpdate(); - v = bbGetOutput(output).unsafe_get() ; - } + } + else + { + // bbUpdate(); + v = bbGetOutput(output).unsafe_get() ; + } return v; } //========================================================================= @@ -682,28 +701,38 @@ namespace bbtk // Looks for the adaptor if (bbGetInputType(input) != typeid(std::string)) { - BlackBox* a = 0; - try - { - a = NewAdaptor( - bbGetInputType(input), - typeid(std::string), - ""); - }catch (bbtk::Exception e) + // Look for factory + Package* p = bbGetDescriptor()->GetPackage(); + if ((p != 0) && ( ! p->GetFactorySet().empty() ) ) { - } - if (a!=NULL) - { - // bbUpdate(); - a->bbSetInput("In",bbGetInput(input)); - a->bbExecute(); - v = a->bbGetOutput("Out").unsafe_get() ; + Factory* f = *p->GetFactorySet().begin(); + BlackBox* a = 0; + try + { + a = f->NewAdaptor( + bbGetInputType(input), + typeid(std::string), + ""); + }catch (bbtk::Exception e) + { + } + if (a!=NULL) + { + // bbUpdate(); + a->bbSetInput("In",bbGetInput(input)); + a->bbExecute(); + v = a->bbGetOutput("Out").unsafe_get() ; + } + else + { + v="? (no adaptor found)"; + } } else { - v="? (no adaptor found)"; + v="? (no factory found)"; } - } + } else { v = bbGetInput(input).unsafe_get() ; @@ -758,17 +787,19 @@ namespace bbtk bool instanceOrtype, bool relative_link ) - { + { InputConnectorMapType::iterator i; // label std::string labelStr; std::string valueStr(""); - if (detail==0) - { - labelStr = bbGetName() ; - } else { - labelStr = bbGetName(); - labelStr = labelStr + " [" +this->bbGetDescriptor()->GetPackage()->GetName()+"::"+ bbGetTypeName() + "] "; + + if (detail==0) { + labelStr = bbGetName() ; +//EED 18 Fev 2008 + labelStr = labelStr + "\\n[" +this->bbGetDescriptor()->GetPackage()->GetName()+"::"+ bbGetTypeName() + "]"; + } else { + labelStr = bbGetName(); + labelStr = labelStr + " [" +this->bbGetDescriptor()->GetPackage()->GetName()+"::"+ bbGetTypeName() + "] "; } SubsBrackets(labelStr); @@ -1014,11 +1045,39 @@ namespace bbtk } //========================================================================= + bool BlackBox::bbGlobalGetSomeBoxExecuting() + { + return bbmgSomeBoxExecuting; + } + + void BlackBox::bbGlobalSetSomeBoxExecuting(bool b) + { + bbmgSomeBoxExecuting = b; + } + + void BlackBox::bbGlobalSetFreezeExecution(bool b) + { + bbmgFreezeExecution = b; + } + + bool BlackBox::bbGlobalGetFreezeExecution() + { + return bbmgFreezeExecution; + } + + void BlackBox::bbGlobalAddToExecutionList( BlackBox* b ) + { + bbmgExecutionList.insert(b); + } + + //========================================================================= // Static members initialization +/*EED bool BlackBox::bbmgSomeBoxExecuting = false; bool BlackBox::bbmgFreezeExecution = false; std::set BlackBox::bbmgExecutionList; +*/ //=========================================================================