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
namespace bbtk
{
+
+//EED
+ static bool bbmgSomeBoxExecuting = false;
+ static bool bbmgFreezeExecution = false;
+ static std::set<BlackBox*> 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(\""
<<name<<"\")"<<std::endl);
}
//=========================================================================
bbmStatus(from.bbmStatus),
bbmBoxProcessMode(from.bbmBoxProcessMode),bbmParent(NULL)
{
- bbtkDebugMessage("Core",7,"BlackBox::BlackBox("
+ bbtkDebugMessage("Kernel",7,"BlackBox::BlackBox("
<<from.bbGetFullName()<<",\""
<<name<<"\")"<<std::endl);
}
BlackBox::~BlackBox()
{
// std::cout << "EED BlackBox::~BlackBox 01 [" << bbGetName()<<"]\n";
- bbtkDebugMessageInc("Core",7,"BlackBox::~BlackBox()"<<std::endl);
+ bbtkDebugMessageInc("Kernel",7,"BlackBox::~BlackBox()"<<std::endl);
this->bbDesallocateConnectors();
//printf("EED BlackBox::~BlackBox 02 \n");
- bbtkDebugDecTab("Core",7);
+ bbtkDebugDecTab("Kernel",7);
}
//=========================================================================
/// Destruction method of a black box
void BlackBox::bbDelete()
{
- bbtkDebugMessage("Core",5,"BlackBox::bbDelete() ["
+ bbtkDebugMessage("Kernel",5,"BlackBox::bbDelete() ["
<<bbGetFullName()<<"]"<<std::endl);
this->bbUserDelete();
}
"=> BlackBox::bbExecute() ["
<<bbGetFullName()<<"]"<<std::endl);
- wx::BeginBusyCursor();
+ Wx::BeginBusyCursor();
// If execution frozen : return
if (bbGlobalGetFreezeExecution())
// Calls the main recursive update method
bbBackwardUpdate(0);
- wx::EndBusyCursor();
+ Wx::EndBusyCursor();
bbtkDebugMessageDec("Process",1,
"<= BlackBox::bbExecute() ["
/// Returns true if the UserBlackBox has an input of name name
bool BlackBox::bbHasInput(const std::string& name) const
{
- bbtkDebugMessageInc("Core",8,
+ bbtkDebugMessageInc("Kernel",8,
"BlackBox::bbHasInput(\""
<<name<<"\") ["<<bbGetFullName()<<"]"
<<std::endl);
bool r = ( bbGetDescriptor()->GetInputDescriptorMap().find(name)
!= bbGetDescriptor()->GetInputDescriptorMap().end());
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
return r;
}
//=========================================================================
/// 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(\""
<<name<<"\") ["<<bbGetFullName()<<"]"<<std::endl);
bool r = ( bbGetDescriptor()->GetOutputDescriptorMap().find(name)
!= bbGetDescriptor()->GetOutputDescriptorMap().end());
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
return r;
}
//=========================================================================
/// Gets the output type of a given name
TypeInfo BlackBox::bbGetOutputType( const std::string &name ) const
{
- bbtkDebugMessageInc("Core",8,
+ bbtkDebugMessageInc("Kernel",8,
"BlackBox::bbGetOutputType(\""
<<name<<"\") ["<<bbGetFullName()<<"]"<<std::endl);
TypeInfo r = bbGetDescriptor()->GetOutputDescriptor(name)->GetTypeInfo();
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
return r;
}
//=========================================================================
/// Gets the input type of a given name
TypeInfo BlackBox::bbGetInputType( const std::string &name ) const
{
- bbtkDebugMessageInc("Core",8,
+ bbtkDebugMessageInc("Kernel",8,
"BlackBox::bbGetInputType(\""
<<name<<"\") ["<<bbGetFullName()<<"]"<<std::endl);
TypeInfo r = bbGetDescriptor()->GetInputDescriptor(name)->GetTypeInfo();
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
return r;
}
//=========================================================================
/// Allocates the i/o connectors of the black box
void BlackBox::bbAllocateConnectors()
{
- bbtkDebugMessageInc("Core",8,
+ bbtkDebugMessageInc("Kernel",8,
"BlackBox::bbAllocateConnectors() ["
<<bbGetFullName()<<"]"
<<std::endl);
BlackBoxDescriptor::InputDescriptorMapType::const_iterator i;
for ( i = imap.begin(); i != imap.end(); ++i )
{
- bbtkDebugMessage("Core",8,"* Allocate \""<<i->first<<"\""<<std::endl);
+ bbtkDebugMessage("Kernel",8,"* Allocate \""<<i->first<<"\""<<std::endl);
bbGetInputConnectorMap()[i->second->GetName()]
= new BlackBoxInputConnector(this);
}
BlackBoxDescriptor::OutputDescriptorMapType::const_iterator o;
for ( o = omap.begin(); o != omap.end(); ++o )
{
- bbtkDebugMessage("Core",8,"* Allocate \""<<o->first<<"\""<<std::endl);
+ bbtkDebugMessage("Kernel",8,"* Allocate \""<<o->first<<"\""<<std::endl);
bbGetOutputConnectorMap()[o->second->GetName()]
= new BlackBoxOutputConnector();
}
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
}
//=========================================================================
/// Desallocates the i/o connectors of the black box
void BlackBox::bbDesallocateConnectors()
{
- bbtkDebugMessageInc("Core",8,
+ bbtkDebugMessageInc("Kernel",8,
"BlackBox::bbDesallocateConnectors()"
<<std::endl);
for ( i = bbGetInputConnectorMap().begin();
i != bbGetInputConnectorMap().end(); ++i )
{
- bbtkDebugMessage("Core",8,"* Delete \""<<i->first<<"\""<<std::endl);
+ bbtkDebugMessage("Kernel",8,"* Delete \""<<i->first<<"\""<<std::endl);
delete (i->second);
}
OutputConnectorMapType::const_iterator o;
for ( o = bbGetOutputConnectorMap().begin();
o != bbGetOutputConnectorMap().end(); ++o )
{
- bbtkDebugMessage("Core",8,"* Delete \""<<o->first<<"\""<<std::endl);
+ bbtkDebugMessage("Kernel",8,"* Delete \""<<o->first<<"\""<<std::endl);
delete (o->second);
}
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
}
//=========================================================================
/// Copies the input / output values from another box
void BlackBox::bbCopyIOValues(BlackBox& from)
{
- bbtkDebugMessageInc("Core",9,
+ bbtkDebugMessageInc("Kernel",9,
"BlackBox::bbCopyIOValues("
<<from.bbGetFullName()<<") ["
<<bbGetFullName()<<"]"<<std::endl);
this->bbSetOutput(output, from.bbGetOutput(output) );
}
- bbtkDebugDecTab("Core",9);
+ bbtkDebugDecTab("Kernel",9);
}
//=========================================================================
{
return ( bbGlobalGetSomeBoxExecuting()
#ifdef _USE_WXWIDGETS_
- || WxBlackBox::bbGlobalIsSomeWindowAlive()
+ || Wx::IsSomeWindowAlive()
#endif
);
}
}
if (reaction) bbGlobalProcessExecutionList();
- bbtkDebugMessageDec("Process",5,
- "<= BlackBox::bbSignalOutputModification("
- <<output<<") ["
- <<bbGetFullName()<<"]"<<std::endl);
+ bbtkDebugMessageDec("Process",5,
+ "<= BlackBox::bbSignalOutputModification("
+ <<output<<") ["
+ <<bbGetFullName()<<"]"<<std::endl);
}
//=========================================================================
<<std::endl);
IOStatus s = UPTODATE;
-
+
InputConnectorMapType::iterator i;
for ( i = bbGetInputConnectorMap().begin();
i!= bbGetInputConnectorMap().end(); ++i)
/// Connects the input <name> to the connection c
void BlackBox::bbConnectInput( const std::string& name, Connection* c)
{
- bbtkDebugMessageInc("Core",7,
+ bbtkDebugMessageInc("Kernel",7,
"BlackBox::bbConnectInput(\""<<name<<"\","<<c<<") ["
<<bbGetFullName()<<"]"
<<std::endl);
// bbSetModifiedStatus();
- bbtkDebugDecTab("Core",7);
+ bbtkDebugDecTab("Kernel",7);
}
//=========================================================================
/// Connects the output <name> to the connection c
void BlackBox::bbConnectOutput( const std::string& name, Connection* c)
{
- bbtkDebugMessageInc("Core",7,
+ bbtkDebugMessageInc("Kernel",7,
"BlackBox::bbConnectOutput(\""<<name<<"\","<<c<<") ["
<<bbGetFullName()<<"]"<<std::endl);
}
i->second->SetConnection(c);
- bbtkDebugDecTab("Core",7);
+ bbtkDebugDecTab("Kernel",7);
}
//=========================================================================
/// Disconnects the input <name> from the connection c
void BlackBox::bbDisconnectInput( const std::string& name, Connection* c)
{
- bbtkDebugMessageInc("Core",7,
+ bbtkDebugMessageInc("Kernel",7,
"BlackBox::bbDisconnectInput(\""<<name
<<"\","<<c<<") ["
<<bbGetFullName()<<"]"
}
i->second->UnsetConnection(c);
- bbtkDebugDecTab("Core",7);
+ bbtkDebugDecTab("Kernel",7);
}
//=========================================================================
/// Disconnects the output <name> from the connection c
void BlackBox::bbDisconnectOutput( const std::string& name, Connection* c)
{
- bbtkDebugMessageInc("Core",7,
+ bbtkDebugMessageInc("Kernel",7,
"BlackBox::bbDisconnectOutput(\""<<name
<<"\","<<c<<") ["
<<bbGetFullName()<<"]"
}
i->second->UnsetConnection(c);
- bbtkDebugDecTab("Core",7);
+ bbtkDebugDecTab("Kernel",7);
}
//=========================================================================
// 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<std::string>() ;
+ } 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<std::string>() ;
- } else {
- v="? (no adaptor found)";
- }
- } else {
- // bbUpdate();
- v = bbGetOutput(output).unsafe_get<std::string>() ;
- }
+ }
+ else
+ {
+ // bbUpdate();
+ v = bbGetOutput(output).unsafe_get<std::string>() ;
+ }
return v;
}
//=========================================================================
// 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<std::string>() ;
+ 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<std::string>() ;
+ }
+ else
+ {
+ v="? (no adaptor found)";
+ }
}
else
{
- v="? (no adaptor found)";
+ v="? (no factory found)";
}
- }
+ }
else
{
v = bbGetInput(input).unsafe_get<std::string>() ;
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);
}
//=========================================================================
+ 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*> BlackBox::bbmgExecutionList;
+*/
//=========================================================================