Module: $RCSfile: bbtkFactory.cxx,v $
Language: C++
-Date: $Date: 2008/03/11 12:27:21 $
-Version: $Revision: 1.30 $
+Date: $Date: 2008/04/09 11:16:57 $
+Version: $Revision: 1.32 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
//===================================================================
void Factory::Reset()
{
- /*
-printf("EED kkkkkkkkkkkkkkkkkkkkkkkk Factory::Reset() \n");
-printf("EED kkkkkkkkkkkkkkkkkkkkkkkk Factory::Reset() \n");
-printf("EED kkkkkkkkkkkkkkkkkkkkkkkk Factory::Reset() \n");
-printf("EED kkkkkkkkkkkkkkkkkkkkkkkk Factory::Reset() \n");
-printf("EED kkkkkkkkkkkkkkkkkkkkkkkk Factory::Reset() \n");
-printf("EED kkkkkkkkkkkkkkkkkkkkkkkk Factory::Reset() \n");
- */
bbtkDebugMessageInc("Kernel",7,"Factory::Reset()"<<std::endl);
CloseAllPackages();
bbtkDebugDecTab("Kernel",7);
//===================================================================
/// Creates an instance of a black box of type <type> with name <name>
- BlackBox* Factory::NewAdaptor(TypeInfo typein,
- TypeInfo typeout,
- const std::string& name) const
+ BlackBox* Factory::NewAdaptor(const DataInfo& typein,
+ const DataInfo& typeout,
+ const std::string& name) const
{
- bbtkDebugMessageInc("Kernel",8,"Factory::NewAdaptor(<"
- <<TypeName(typein)<<">,<"
- <<TypeName(typeout)<<">,\""
+ bbtkDebugMessageInc("Kernel",8,"Factory::NewAdaptor("
+ <<typein<<","
+ <<typeout<<",\""
<<name<<"\")"<<bbtkendl);
}
if (!b)
{
- bbtkError("no <"
- <<TypeName(typein)<<"> to <"
- <<TypeName(typeout)
- <<"> adaptor available");
+ bbtkError("no "<<typein<<" to "<<typeout
+ <<" adaptor available");
+ }
+
+ bbtkDebugDecTab("Kernel",7);
+ return b;
+ }
+ //===================================================================
+
+
+ //===================================================================
+ /// Creates an instance of a black box of type <type> with name <name>
+ BlackBox* Factory::NewWidgetAdaptor(const DataInfo& typein,
+ const DataInfo& typeout,
+ const std::string& name) const
+ {
+ bbtkDebugMessageInc("Kernel",8,"Factory::NewWidgetAdaptor(<"
+ <<typein<<">,<"
+ <<typeout<<">,\""
+ <<name<<"\")"<<bbtkendl);
+
+
+ BlackBox* b = 0;
+ PackageMapType::const_iterator i;
+ for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+ {
+ b = i->second.mPackage->NewWidgetAdaptor(typein,
+ typeout,
+ name);
+ if (b) break;
+ }
+ if (!b)
+ {
+ bbtkError("no "<<typein<<" to "<<typeout
+ <<"> widget adaptor available");
}
bbtkDebugDecTab("Kernel",7);
}
//===================================================================
+ //===================================================================
+ /// Creates an instance of a black box of type <type> with name <name>
+ bool Factory::FindAdaptor(const DataInfo& typein,
+ const DataInfo& typeout,
+ std::string& adaptor) const
+ {
+ bbtkDebugMessageInc("Kernel",8,"Factory::FindAdaptor(<"
+ <<typein<<">,<"
+ <<typeout<<">)"<<bbtkendl);
+
+ bool b = false;
+ PackageMapType::const_iterator i;
+ for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+ {
+ b = i->second.mPackage->FindAdaptor(typein,
+ typeout,
+ adaptor);
+ if (b) break;
+ }
+ /*
+ if (!b)
+ {
+ bbtkError("no "<<typein<<" to "<<typeout
+ <<"> widget adaptor available");
+ }
+ */
+
+ bbtkDebugDecTab("Kernel",7);
+ return b;
+ }
+ //===================================================================
+
+ //===================================================================
+ /// Creates an instance of a black box of type <type> with name <name>
+ bool Factory::FindWidgetAdaptor(const DataInfo& typein,
+ const DataInfo& typeout,
+ std::string& adaptor) const
+ {
+ bbtkDebugMessageInc("Kernel",8,"Factory::FindWidgetAdaptor(<"
+ <<typein<<">,<"
+ <<typeout<<">)"<<bbtkendl);
+
+ bool b = false;
+ PackageMapType::const_iterator i;
+ for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+ {
+ b = i->second.mPackage->FindWidgetAdaptor(typein,
+ typeout,
+ adaptor);
+ if (b) break;
+ }
+ bbtkDebugDecTab("Kernel",7);
+ return b;
+ }
+ //===================================================================
+
+ //===================================================================
+ /// Creates an instance of a black box of type <type> with name <name>
+ bool Factory::FindWidgetAdaptor2(const DataInfo& typein,
+ const DataInfo& typeout,
+ std::string& widget,
+ std::string& adaptor) const
+ {
+ bbtkDebugMessageInc("Kernel",8,"Factory::FindWidgetAdaptor(<"
+ <<typein<<">,<"
+ <<typeout<<">)"<<bbtkendl);
+
+ bool b = false;
+ adaptor = widget = "";
+ PackageMapType::const_iterator i;
+ for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+ {
+ b = i->second.mPackage->FindWidgetAdaptor(typein,
+ typeout,
+ widget);
+ if (b) break;
+ }
+ if (!b)
+ {
+ // Look for a widget adaptor with good nature out
+ bbtkMessage("Kernel",5,
+ "*** Looking for a two pieces widget adaptor for : "
+ << typein << "->"<<typeout<<std::endl);
+ for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+ {
+ Package::AdaptorMapType::const_iterator j;
+ for (j=i->second.mPackage->GetAdaptorMap().begin();
+ j!=i->second.mPackage->GetAdaptorMap().end();
+ ++j)
+ {
+ if ( ( j->first.mKind ==
+ BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR) &&
+ //(j->first.mTypeIn == typein) &&
+ (j->first.mTypeOut.GetNature() == typeout.GetNature() )
+ )
+ {
+ widget = j->second->GetTypeName();
+ bbtkMessage("Kernel",5,
+ "===> Found first part : "<<widget
+ << " "<<j->first.mTypeIn<<"->"
+ <<j->first.mTypeOut<<std::endl);
+ DataInfo ti( j->first.mTypeOut.GetType(), "");
+ DataInfo to( typeout.GetType(), "");
+ b = FindAdaptor( ti, to, adaptor );
+ if (b)
+ {
+ bbtkMessage("Kernel",5,
+ "===> Found second part : "<<adaptor
+ <<std::endl);
+ break;
+ }
+ else
+ {
+ bbtkMessage("Kernel",5,
+ "===> No second part found"<<std::endl);
+ }
+ }
+ }
+ if (b) break;
+ }
+ }
+ bbtkDebugDecTab("Kernel",7);
+ return b;
+ }
+ //===================================================================
+
//===================================================================
/// Creates an instance of a connection
Connection* Factory::NewConnection(BlackBox* from,
}
//===================================================================
+ //===================================================================
+ void Factory::CheckPackages() const
+ {
+ bbtkMessage("Debug",1,"****** Checking Factory "<<(void*)this
+ <<std::endl);
+ PackageMapType::const_iterator i;
+ for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+ {
+ i->second.mPackage->CheckBoxes();
+ }
+ bbtkMessage("Debug",1,"****** Checking Factory "<<(void*)this
+ <<" ... OK"<<std::endl);
+ }
+ //===================================================================
+
//===================================================================
void Factory::WriteDotFilePackagesList(FILE *ff)
{