Program: bbtk
Module: $RCSfile: bbtkPackage.cxx,v $
Language: C++
- Date: $Date: 2008/03/07 08:40:14 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2008/04/08 06:59:30 $
+ Version: $Revision: 1.11 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See doc/license.txt or
//==========================================================================
/// Creates an instance of an adaptor of input type <typein> and
/// output type <typeout> with name <name>
- BlackBox* Package::NewAdaptor(TypeInfo typein,
- TypeInfo typeout,
- const std::string& name) const
+ BlackBox* Package::NewAdaptor(const DataInfo& typein,
+ const DataInfo& typeout,
+ const std::string& name) const
{
bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
- ">::NewAdaptor(<"
- <<TypeName(typein)<<">,<"
- <<TypeName(typeout)<<">,\""
+ ">::NewAdaptor("
+ <<typein<<","
+ <<typeout<<",\""
<<name<<"\")"<<bbtkendl);
- AdaptorKey key(typein,typeout);
+ AdaptorKey key(typein,typeout,
+ BlackBoxDescriptor::DEFAULT_ADAPTOR);
AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
if (i == mAdaptorMap.end())
{
}
//==========================================================================
+ //==========================================================================
+ /// Creates an instance of an adaptor of input type <typein> and
+ /// output type <typeout> with name <name>
+ BlackBox* Package::NewWidgetAdaptor(const DataInfo& typein,
+ const DataInfo& typeout,
+ const std::string& name) const
+ {
+ bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
+ ">::NewWidgetAdaptor("
+ <<typein<<","
+ <<typeout<<",\""
+ <<name<<"\")"<<bbtkendl);
+ AdaptorKey key(typein,typeout,
+ BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR);
+ AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
+ if (i == mAdaptorMap.end())
+ {
+ bbtkDebugDecTab("Kernel",8);
+ return 0;
+ }
+ BlackBox* bb =i->second->CreateInstance(name);
+ bbtkDebugDecTab("Kernel",8);
+ return bb;
+
+ }
+ //==========================================================================
+
+ //==========================================================================
+ /// Returns true is the package contains
+ /// an adaptor of input type <typein> and
+ /// output type <typeout>
+ /// If successfull then adaptor contains the black box type name
+ bool Package::FindWidgetAdaptor(const DataInfo& typein,
+ const DataInfo& typeout,
+ std::string& adaptor) const
+ {
+ bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
+ ">::FindWidgetAdaptor("
+ <<typein<<","
+ <<typeout<<")"<<bbtkendl);
+
+ AdaptorKey key(typein,typeout,
+ BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR);
+ AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
+ if (i == mAdaptorMap.end())
+ {
+ bbtkDebugDecTab("Kernel",8);
+ return false;
+ }
+ adaptor = i->second->GetTypeName();
+ bbtkDebugDecTab("Kernel",8);
+ return true;
+
+ }
+ //==========================================================================
+
+
+
+ //==========================================================================
+ /// Returns true is the package contains
+ /// an adaptor of input type <typein> and
+ /// output type <typeout>
+ /// If successfull then adaptor contains the black box type name
+ bool Package::FindAdaptor(const DataInfo& typein,
+ const DataInfo& typeout,
+ std::string& adaptor) const
+ {
+ bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
+ ">::FindAdaptor("
+ <<typein<<","
+ <<typeout<<")"<<bbtkendl);
+
+ AdaptorKey key(typein,typeout,
+ BlackBoxDescriptor::DEFAULT_ADAPTOR);
+ AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
+ if (i == mAdaptorMap.end())
+ {
+ bbtkDebugDecTab("Kernel",8);
+ return false;
+ }
+ adaptor = i->second->GetTypeName();
+ bbtkDebugDecTab("Kernel",8);
+ return true;
+
+ }
+ //==========================================================================
//==========================================================================
d->SetPackage(this);
// If it is a default adaptor, also register it in the adaptors map
- if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR)
+ if ( (d->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR) ||
+ (d->GetKind() == BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR) )
{
+ bbtkDebugMessage("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\") : The box is an adaptor, inserting it in adaptors map ..."<<std::endl);
TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo();
TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
- AdaptorKey key(typein,typeout);
+ DataInfo infoin(typein,d->GetInputDescriptor("In")->GetNature());
+ DataInfo infoout(typeout,d->GetOutputDescriptor("Out")->GetNature());
+ bbtkDebugMessage("Kernel",8,"LG Adaptor "<<infoin<<" to "<<infoout
+ <<" - kind="<<d->GetKind()<<std::endl);
+
+ AdaptorKey key(infoin,infoout,d->GetKind());
+
AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
if (i == mAdaptorMap.end())
{
- bbtkDebugMessage("Kernel",8,"The box is an adaptor, inserting it in adaptors map ..."<<std::endl);
mAdaptorMap[key] = d;
}
// If already an adaptor registered : error