-/*=========================================================================
-
-Program: bbtk
-Module: $RCSfile: bbtkBlackBox.cxx,v $
-Language: C++
-Date: $Date: 2008/06/19 09:46:41 $
-Version: $Revision: 1.21 $
-
-Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
-l'Image). All rights reserved. See doc/license.txt or
-http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
-
-This software is distributed WITHOUT ANY WARRANTY; without even
-the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the above copyright notices for more information.
-
+/*=========================================================================
+ Program: bbtk
+ Module: $RCSfile: bbtkBlackBox.cxx,v $
+ Language: C++
+ Date: $Date: 2008/11/25 11:17:13 $
+ Version: $Revision: 1.29 $
=========================================================================*/
+/* ---------------------------------------------------------------------
+
+* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+*
+* This software is governed by the CeCILL-B license under French law and
+* abiding by the rules of distribution of free software. You can use,
+* modify and/ or redistribute the software under the terms of the CeCILL-B
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+* or in the file LICENSE.txt.
+*
+* As a counterpart to the access to the source code and rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty and the software's author, the holder of the
+* economic rights, and the successive licensors have only limited
+* liability.
+*
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL-B license and that you accept its terms.
+* ------------------------------------------------------------------------ */
/**
* \file
static bool bbmgSomeBoxExecuting = false;
static bool bbmgFreezeExecution = false;
- static std::set<BlackBox::Pointer> bbmgExecutionList;
+ static std::set<BlackBox::WeakPointer> bbmgExecutionList;
//=========================================================================
BlackBox::Deleter::Deleter()
//=========================================================================
BlackBox::BlackBox(const std::string &name)
- : bbmName(name),
- bbmStatus(MODIFIED),
- bbmBoxProcessMode("Pipeline"),
- bbmParent()
-
+ :
+ bbmStatus(MODIFIED),
+ bbmExecuting(false),
+ bbmName(name),
+ bbmBoxProcessMode("Pipeline"),
+ bbmParent()
+
{
bbtkDebugMessage("object",4,"==> BlackBox::BlackBox(\""
<<name<<"\")"<<std::endl);
//=========================================================================
BlackBox::BlackBox(BlackBox& from, const std::string &name)
- : bbmName(name),
+ :
bbmStatus(from.bbmStatus),
+ bbmExecuting(false),
+ bbmName(name),
bbmBoxProcessMode(from.bbmBoxProcessMode),
bbmParent()
void BlackBox::bbExecute(bool force)
{
bbtkDebugMessageInc("process",2,
- "=> BlackBox::bbExecute() ["
+ "=> BlackBox::bbExecute("<<(int)force<<") ["
<<bbGetFullName()<<"]"<<std::endl);
- wxBusyCursor wait;
- //EED Wx::BeginBusyCursor();
+ // If already executing : return
+ if (bbGetExecuting())
+ {
+ bbtkDebugMessage("process",2,
+ " -> already executing : bailing out"<<std::endl);
+ return;
+ }
// If execution frozen : return
if (bbGlobalGetFreezeExecution())
" -> FreezeExecution global flag is 'true' : abort execution"<<std::endl);
}
+ BBTK_BUSY_CURSOR;
+
// If force is true then update is triggered even if the box is UPTODATE
if (force) bbSetModifiedStatus();
// Calls the main recursive update method
bbBackwardUpdate(Connection::Pointer());
- //EED Wx::EndBusyCursor();
-
bbtkDebugMessageDec("process",2,
"<= BlackBox::bbExecute() ["
<<bbGetFullName()<<"]"<<std::endl);
/// Copies the input / output values from another box
void BlackBox::bbCopyIOValues(BlackBox& from)
{
- bbtkDebugMessageInc("Kernel",9,
+ bbtkDebugMessageInc("Kernel",1,
"BlackBox::bbCopyIOValues("
<<from.bbGetFullName()<<") ["
<<bbGetFullName()<<"]"<<std::endl);
{
if (! i->second->GetCopyConstruct() ) continue;
std::string input = i->second->GetName();
+ bbtkDebugMessage("Kernel",2,"* Copying input "<<input<<std::endl);
this->bbSetInput(input, from.bbGetInput(input) );
}
// copies the output values
{
if (! o->second->GetCopyConstruct() ) continue;
std::string output = o->second->GetName();
+ bbtkDebugMessage("Kernel",2,"* Copying output "<<output<<std::endl);
this->bbSetOutput(output, from.bbGetOutput(output) );
}
this->bbSetStatus(MODIFIED);
bbGlobalAddToExecutionList( GetThisPointer<BlackBox>() );
}
+ /*
else if ( bbGetStatus() == MODIFIED ) //! this->bbIsUptodate())
{
bbtkDebugMessage("modified",2,"-> Already modified"<<std::endl);
return;
}
+ */
else
{
bbtkDebugMessage("modified",2,"-> Status set to modified"<<std::endl);
InputConnectorMapType::iterator i;
unsigned int namelmax = 0;
unsigned int valuelmax = 0;
- unsigned int connlmax = 0;
+ // unsigned int connlmax = 0;
for ( i = mInputConnectorMap.begin(); i != mInputConnectorMap.end(); ++i )
{
iname.push_back(i->first);
}
//=========================================================================
+ static bool bbmgGlobalProcessingExecutionList = false;
//=========================================================================
void BlackBox::bbGlobalProcessExecutionList()
{
bbtkDebugMessageInc("process",3,
"=> BlackBox::bbGlobalProcessExecutionList()"
- <<std::endl);
-
- std::set<BlackBox::Pointer>::iterator i;
- for (i=bbmgExecutionList.begin();
- i!=bbmgExecutionList.end();
- ++i)
+ <<std::endl);
+ if (bbmgGlobalProcessingExecutionList)
{
- bbtkDebugMessage("process",4,
- " -> Executing "<<(*i)->bbGetFullName()<<std::endl);
- (*i)->bbExecute(true);
+ bbtkDebugMessage("process",3,"BlackBox::bbGlobalProcessExecutionList() reentered !");
+ return;
+ }
+ bbmgGlobalProcessingExecutionList = true;
+
+ std::set<BlackBox::WeakPointer>::iterator i;
+ while (bbmgExecutionList.size()>0)
+ {
+ i = bbmgExecutionList.begin();
+ BlackBox::WeakPointer p = *i;
+ bbmgExecutionList.erase(i);
+ if (p.lock())
+ {
+ bbtkDebugMessage("process",4,
+ " -> Executing "<<
+ p.lock()->bbGetFullName()<<std::endl);
+ p.lock()->bbExecute(true);
+ }
+ else
+ {
+ bbtkGlobalError("Strange error in BlackBox::bbGlobalProcessExecutionList() : Weak bb pointer in bbmgExecutionList is no more valid...");
+ }
}
bbmgExecutionList.clear();
"<= BlackBox::bbGlobalProcessExecutionList()"
<<std::endl);
+ bbmgGlobalProcessingExecutionList = false;
}
//=========================================================================
}
void BlackBox::bbGlobalAddToExecutionList( BlackBox::Pointer b )
- {
- bbmgExecutionList.insert(b);
- }
+ {
+ bbtkDebugMessage("process",3,"* bbGlobalAddToExecutionList("<<b->bbGetFullName()<<")"<<std::endl);
+ if (bbmgGlobalProcessingExecutionList)
+ {
+ bbtkDebugMessage("process",3,"bbGlobalAddToExecutionList called inside bbGlobalProcessExecutionList !");
+ }
+ bbmgExecutionList.insert(b);
+ }
//=========================================================================