X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkBlackBox.cxx;h=bb409a1be3297c99c44cd5d4cd698b27fe126a16;hb=8a15ae69662abfba701a970f9efee218e0b126d3;hp=7955ccfc4ab4a0b1b77f13ae4246c6675c870d3c;hpb=3fb0c5f4f00f86519c93413ab2386c47c5224345;p=bbtk.git diff --git a/kernel/src/bbtkBlackBox.cxx b/kernel/src/bbtkBlackBox.cxx index 7955ccf..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/02/20 16:05:38 $ -Version: $Revision: 1.5 $ +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,6 +35,13 @@ 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), @@ -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 + // Look for factory + Package* p = bbGetDescriptor()->GetPackage(); + if ((p != 0) && ( ! p->GetFactorySet().empty() ) ) { - a = 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() ; + 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() ; @@ -1016,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; +*/ //=========================================================================