X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkFactory.cxx;h=d541db35b9203e89b984a63daa7c2dd1a7760eb5;hb=72e1281cc66954975acc2414264239dcf055c15f;hp=669a9fbc7cfe05bc69a60627b554cec70568a28e;hpb=4dfdd2ae16994fcbda1f323d5bdc5f02b4e26f48;p=bbtk.git diff --git a/kernel/src/bbtkFactory.cxx b/kernel/src/bbtkFactory.cxx index 669a9fb..d541db3 100644 --- a/kernel/src/bbtkFactory.cxx +++ b/kernel/src/bbtkFactory.cxx @@ -548,23 +548,47 @@ namespace bbtk bbtkDebugDecTab("kernel",9); } - //=================================================================== -// ups3 EED borrame + //=================================================================== std::string Factory::GetPackageNameOfaBlackBox(std::string boxType) { - std::string result=""; + std::string packageName=""; PackageMapType::const_iterator i; - for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) - { - if ( i->second->ifBoxExist( boxType ) == true) + + std::size_t found = boxType.find(":"); + if (found!=std::string::npos) + { + packageName = boxType.substr(0,found); + } else { + for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) { - result = i->first; - } - } - return result; + if ( i->second->ifBoxExist( boxType ) == true) + { + packageName = i->first; + } // if ifBoxExist + } // for i + + } // if found + return packageName; } + + //=================================================================== + std::string Factory::GetTypeNameOfaBlackBox(std::string boxType) + { + std::string typeName=""; + + std::size_t found = boxType.find(":"); + if (found!=std::string::npos) + { + typeName = boxType.substr(found+1); + } else { + typeName=boxType; + } // if found + return typeName; + } + + //=================================================================== @@ -572,20 +596,52 @@ namespace bbtk BlackBox::Pointer Factory::NewBlackBox(const std::string& type, const std::string& name) const { - bbtkDebugMessageInc("kernel",7,"Factory::NewBlackBox(\"" + bbtkDebugMessageInc("kernel",7,"Factory::NewBlackBox(\"" <second->NewBlackBox(type,name); - if (b) break; - } + + std::string tmp = type; + std::string packageName = ((bbtk::Factory*)this)->GetPackageNameOfaBlackBox(tmp); + std::string type2 = ((bbtk::Factory*)this)->GetTypeNameOfaBlackBox(tmp); + i = mPackageMap.find(packageName); + if (i != mPackageMap.end()) + { + b = i->second->NewBlackBox(type2,name); + } else { + b =BlackBox::Pointer(); + } + +/* + std::size_t found = type.find(":"); + if (found!=std::string::npos) + { + std::string packageName = type.substr(0,found); + std::string type2 = type.substr(found+1); + i = mPackageMap.find(packageName); + if (i != mPackageMap.end()) + { + b = i->second->NewBlackBox(type2,name); + } else { + b =BlackBox::Pointer(); + } + } else { + for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) + { + b = i->second->NewBlackBox(type,name); + if (b) break; + } // for i + + } // if found : +*/ + + if (!b) - { - bbtkError("black box type \""<