X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkPackage.cxx;h=cdc19203d9e2408d0b46f81e0b7785a10e0741ec;hb=141959873bfc3610f427de9a7690458a8b18bd2a;hp=4acb0f16192f8351b1219b8f73e0e2abfba64834;hpb=a26195c366a89795288009cf7e20f11afa494970;p=bbtk.git diff --git a/kernel/src/bbtkPackage.cxx b/kernel/src/bbtkPackage.cxx index 4acb0f1..cdc1920 100644 --- a/kernel/src/bbtkPackage.cxx +++ b/kernel/src/bbtkPackage.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkPackage.cxx,v $ Language: C++ - Date: $Date: 2008/01/22 15:02:00 $ - Version: $Revision: 1.1 $ + Date: $Date: 2008/03/07 08:40:14 $ + Version: $Revision: 1.10 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See doc/license.txt or @@ -35,17 +35,18 @@ namespace bbtk const std::string& description, const std::string& version, const std::string& BBTKVersion) - : mName(name), - mAuthor(author), - mDescription(description), - mVersion(version), - mBBTKVersion(BBTKVersion) + : + mName(name), + mAuthor(author), + mDescription(description), + mVersion(version), + mBBTKVersion(BBTKVersion) { - std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_doc_tmp(); + std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir(); char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1]; std::string url = default_doc_dir; if (c != '/' && c !='\\') url = url + "/"; - url = url + "doc_tmp/" + name + "/index.html"; + url = url + "temp_dir/" + name + "/index.html"; SetDocURL(url); SetDocRelativeURL("Relative url not set"); @@ -61,7 +62,7 @@ namespace bbtk // std::cout << " url=["<second; - } + i!=mBlackBoxMap.end(); + ++i) + { + delete i->second; + } // Adaptors are also stored in the black box map : hence already deleted /* AdaptorMapType::const_iterator j; for (j=mAdaptorMap.begin(); - j!=mAdaptorMap.end(); - ++j) + j!=mAdaptorMap.end(); + ++j) { - delete j->second; - } + delete j->second; + } */ - bbtkDebugDecTab("Core",7); + bbtkDebugDecTab("Kernel",7); } //========================================================================== @@ -100,16 +101,16 @@ namespace bbtk BlackBox* Package::NewBlackBox(const std::string& type, const std::string& name) const { - bbtkDebugMessageInc("Core",8,"Package<"<::NewBlackBox(\""<::NewBlackBox(\""<second->CreateInstance(name); - bbtkDebugDecTab("Core",8); + bbtkDebugDecTab("Kernel",8); return bb; } @@ -124,7 +125,7 @@ namespace bbtk TypeInfo typeout, const std::string& name) const { - bbtkDebugMessageInc("Core",8,"Package<"<::NewAdaptor(<" <,<" <,\"" @@ -134,11 +135,11 @@ namespace bbtk AdaptorMapType::const_iterator i = mAdaptorMap.find(key); if (i == mAdaptorMap.end()) { - bbtkDebugDecTab("Core",8); + bbtkDebugDecTab("Kernel",8); return 0; } BlackBox* bb =i->second->CreateInstance(name); - bbtkDebugDecTab("Core",8); + bbtkDebugDecTab("Kernel",8); return bb; } @@ -151,13 +152,13 @@ namespace bbtk /// Registers a black box descriptor in the package bool Package::RegisterBlackBox(BlackBoxDescriptor* d) { - bbtkDebugMessageInc("Core",8,"Package<"<::RegisterBlackBox(\""<GetTypeName()<<"\")"<::RegisterBlackBox(\""<GetTypeName()<<"\")"<GetTypeName()] = d; d->SetPackage(this); // If it is a default adaptor, also register it in the adaptors map - if ( d->GetCategory() == BlackBoxDescriptor::DEFAULT_ADAPTOR) + if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR) { TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo(); TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo(); @@ -165,7 +166,7 @@ namespace bbtk AdaptorMapType::const_iterator i = mAdaptorMap.find(key); if (i == mAdaptorMap.end()) { - bbtkDebugMessage("Core",8,"The box is an adaptor, inserting it in adaptors map ..."< as default adaptor but there is already a default adaptor registered (<" <second->GetTypeName()<<">)"); } - - } - bbtkDebugDecTab("Core",8); + bbtkDebugDecTab("Kernel",8); return true; } @@ -192,24 +191,24 @@ namespace bbtk /// UnRegisters a black box descriptor from the package void Package::UnRegisterBlackBox(const std::string& name) { - bbtkDebugMessageInc("Core",8,"Package<"<::UnRegisterBlackBox(\""<::UnRegisterBlackBox(\""< does not contains the black box <"<"); - } + { + bbtkDebugDecTab("Kernel",8); + bbtkError("UnRegister : The package <"< does not contains the black box <"<"); + } mBlackBoxMap.erase(i); // Is it also in the adaptors map ? /* AdaptorMapType::iterator j = mAdaptorMap.find(name); if (j != mAdaptorMap.end()) { - mAdaptorMap.erase(j); + mAdaptorMap.erase(j); } */ - bbtkDebugDecTab("Core",8); + bbtkDebugDecTab("Kernel",8); } //========================================================================== @@ -217,20 +216,20 @@ namespace bbtk /// Changes the name of a black box type void Package::ChangeBlackBoxName( const std::string& oldname, const std::string& newname ) { - bbtkDebugMessageInc("Core",8,"Package<"<::ChangeBlackBoxName(\""<::ChangeBlackBoxName(\""< does not contains the black box <"<"); + bbtkDebugDecTab("Kernel",8); + bbtkError("ChangeBlackBoxName : The package <"< does not contains the black box <"<"); } i->second->SetTypeName(newname); mBlackBoxMap[newname] = i->second; mBlackBoxMap.erase(i); - bbtkDebugDecTab("Core",8); + bbtkDebugDecTab("Kernel",8); } //========================================================================== @@ -240,7 +239,7 @@ namespace bbtk /// Registers an adaptor descriptor in the package bool Package::RegisterAdaptor(BlackBoxDescriptor* d) { - bbtkDebugMessage("Core",8,"Package<"<::RegisterAdaptor(\""<GetTypeName()<<"\")"<::RegisterAdaptor(\""<GetTypeName()<<"\")"<GetInputDescriptor("In")->GetTypeInfo(); TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo(); @@ -259,7 +258,7 @@ namespace bbtk { unsigned int lmax = 0; std::vector names; - std::vector categs; + std::vector kinds; std::vector descrs; BlackBoxMapType::const_iterator i; @@ -268,25 +267,25 @@ namespace bbtk ++i) { if ( adaptors || - ( i->second->GetCategory() == BlackBoxDescriptor::STANDARD) ) + ( i->second->GetKind() == BlackBoxDescriptor::STANDARD) ) { std::string name(" "); name += i->second->GetTypeName(); names.push_back(name); - std::string categ; - if ( i->second->GetCategory() == BlackBoxDescriptor::ADAPTOR ) + std::string kind; + if ( i->second->GetKind() == BlackBoxDescriptor::ADAPTOR ) { - categ = std::string("[A]"); + kind = std::string("[A]"); } - else if ( i->second->GetCategory() == + else if ( i->second->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR ) { - categ = std::string("[DA]"); + kind = std::string("[DA]"); } - categs.push_back(categ); + kinds.push_back(kind); - unsigned int l = name.size()+categ.size(); + unsigned int l = name.size()+kind.size(); if (l>lmax) lmax = l; std::string descr; @@ -303,7 +302,7 @@ namespace bbtk std::string offs; offs.append(lmax+3,' '); std::vector::iterator ni,ci,di; - for (ni = names.begin(), ci = categs.begin(), di = descrs.begin(); + for (ni = names.begin(), ci = kinds.begin(), di = descrs.begin(); ni != names.end(); ++ni, ++ci, ++di) { std::string space; @@ -318,7 +317,7 @@ namespace bbtk else bbtkMessage("Help",1,d << std::endl); // d = d.substr(dmax,d.size()); - // } + // } } } @@ -333,11 +332,11 @@ namespace bbtk i!=mBlackBoxMap.end(); ++i) { - if ( i->second->GetCategory() != BlackBoxDescriptor::STANDARD ) + if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD ) { bbtkMessage("Help",1, " "<second->GetTypeName()); - if ( i->second->GetCategory() == + if ( i->second->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR ) { bbtkMessage("Help",1, @@ -347,7 +346,7 @@ namespace bbtk { bbtkMessage("Help",1, " : "<second->GetDescription()); - + } bbtkMessage("Help",1,std::endl); } @@ -364,7 +363,7 @@ namespace bbtk { bbtkMessage("Help",1, " : "<second->GetDescription()); - + } bbtkMessage("Help",1,std::endl); } @@ -376,18 +375,18 @@ namespace bbtk /// Prints help on a black box void Package::HelpBlackBox(const std::string& name, bool full) const { - bbtkDebugMessageInc("Core",8,"Package<"<::HelpBlackBox(\"" + bbtkDebugMessageInc("Kernel",8,"Package<"<::HelpBlackBox(\"" < does not contains the black box <"<"); } // bbtkMessage("Help",1,"["<second->GetHelp(full); - bbtkDebugDecTab("Core",8); + bbtkDebugDecTab("Kernel",8); } //========================================================================== @@ -397,16 +396,16 @@ namespace bbtk /// Returns true iff the package contains the box of name boxname bool Package::ContainsBlackBox(const std::string& name) const { - bbtkDebugMessageInc("Core",8,"Package<"<::HelpBlackBox(\"" + bbtkDebugMessageInc("Kernel",8,"Package<"<::HelpBlackBox(\"" <::CreateHtmlPage(\"" + bbtkDebugMessageInc("Kernel",9,"Package<"<::CreateHtmlPage(\"" <\n"; s << " Author(s) : " << GetAuthor() << "\n"; - s << " Version : " + s << " Author(s) : " + << GetCategory() << "\n"; + s << " Version : " << GetVersion() << "\n"; s << " bbtk Version : " << GetBBTKVersion() << "\n"; @@ -527,16 +528,17 @@ namespace bbtk BlackBoxMapType::const_iterator i; for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i) { - if ( i->second->GetCategory() != BlackBoxDescriptor::STANDARD) + if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD) continue; std::string name = i->second->GetTypeName(); Utilities::html_format(name); std::string descr = i->second->GetDescription(); - + Utilities::html_format(descr); + s << ""; s << ""; - s << "
  • " <"; s << " "; @@ -546,7 +548,7 @@ namespace bbtk s << "\n"; - s << "
  • \n"; + s << "\n"; s << "\n"; //------------------- @@ -556,21 +558,21 @@ namespace bbtk // s << "
    \n"; s << "

    Adaptors : \n"; s << "

      \n"; - + // BlackBoxMapType::const_iterator i; s << "

      \n"; for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end();++i) { - if ( i->second->GetCategory() == BlackBoxDescriptor::STANDARD) + if ( i->second->GetKind() == BlackBoxDescriptor::STANDARD) continue; - + std::string name = i->second->GetTypeName(); Utilities::html_format(name); std::string descr = i->second->GetDescription(); - + s << ""; s << " "; @@ -578,8 +580,8 @@ namespace bbtk s << "\n"; } s << "
      "; - s << "
    • " <"; s << "
    • \n"; - - s << "

    \n"; + + s << "\n"; s << "
    \n"; } @@ -601,11 +603,13 @@ namespace bbtk // Computes output directory from filename to pass it to // BlackBoxDescriptor::InsertHtmlHelp std::string dir; - std::string::size_type slash_position = - filename.find_last_of(ConfigurationFile::GetInstance().Get_file_separator ()); - if (slash_position != std::string::npos) { + + std::string::size_type slash_position = filename.find_last_of("/\\"); + + + if (slash_position != std::string::npos) { if (slash_position == 0) - slash_position = 1; + slash_position = 1; dir = filename.substr(0,slash_position); } @@ -624,8 +628,9 @@ namespace bbtk ptm = gmtime ( &rawtime ); s << "


    \n"; - s << "Automatically generated by "< from " - < on " + s << "Automatically generated by "< "//from " + // < + <<"on " << ptm->tm_mday << "/" << ptm->tm_mon << "/" << ptm->tm_year+1900 << " - " << ptm->tm_hour << ":" << ptm->tm_min << " GMT\n"; s << "\n"; @@ -633,7 +638,7 @@ namespace bbtk //---------------------- // End - bbtkDebugDecTab("Core",9); + bbtkDebugDecTab("Kernel",9); } //========================================================================== }