Program: bbtk
Module: $RCSfile: bbtkBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/10/17 08:18:12 $
- Version: $Revision: 1.25 $
+ Date: $Date: 2008/12/03 09:34:37 $
+ Version: $Revision: 1.30 $
=========================================================================*/
/* ---------------------------------------------------------------------
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)
:
bbmStatus(MODIFIED),
+ bbmExecuting(false),
bbmName(name),
bbmBoxProcessMode("Pipeline"),
bbmParent()
BlackBox::BlackBox(BlackBox& from, const std::string &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);
+ // If already executing : return
+ if (bbGetExecuting())
+ {
+ bbtkDebugMessage("process",2,
+ " -> already executing : bailing out"<<std::endl);
+ return;
+ }
// If execution frozen : return
if (bbGlobalGetFreezeExecution())
/// 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) );
}
{
bbtkDebugMessage("modified",2,"-> Status set to modified"<<std::endl);
this->bbSetStatus(MODIFIED);
+ std::cout << "Status set to modified" <<std::endl;
}
this->bbSignalOutputModification(false);
}
//=========================================================================
+ 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);
+ }
//=========================================================================