]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkPackage.cxx
Merge branch 'wt-version'
[bbtk.git] / kernel / src / bbtkPackage.cxx
index 2a1fc8d3772fdf05e8f6aa4c535c05eb6a6e9ddb..91cdb518372b220f124b1de33af8dc5c22c8912a 100644 (file)
@@ -1,33 +1,40 @@
+/*
+ # ---------------------------------------------------------------------
+ #
+ # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+ #                        pour la SantÈ)
+ # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+ # Previous Authors : Laurent Guigues, Jean-Pierre Roux
+ # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+ #
+ #  This software is governed by the CeCILL-B license under French law and
+ #  abiding by the rules of distribution of free software. You can  use,
+ #  modify and/ or redistribute the software under the terms of the CeCILL-B
+ #  license as circulated by CEA, CNRS and INRIA at the following URL
+ #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+ #  or in the file LICENSE.txt.
+ #
+ #  As a counterpart to the access to the source code and  rights to copy,
+ #  modify and redistribute granted by the license, users are provided only
+ #  with a limited warranty  and the software's author,  the holder of the
+ #  economic rights,  and the successive licensors  have only  limited
+ #  liability.
+ #
+ #  The fact that you are presently reading this means that you have had
+ #  knowledge of the CeCILL-B license and that you accept its terms.
+ # ------------------------------------------------------------------------ */
+
+
 
 /*=========================================================================                                                                               
   Program:   bbtk
   Module:    $RCSfile: bbtkPackage.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 12:18:51 $
-  Version:   $Revision: 1.28 $
+  Date:      $Date: 2012/11/16 08:49:01 $
+  Version:   $Revision: 1.37 $
 =========================================================================*/
 
-/* ---------------------------------------------------------------------
-
-* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
-* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
-*
-*  This software is governed by the CeCILL-B license under French law and 
-*  abiding by the rules of distribution of free software. You can  use, 
-*  modify and/ or redistribute the software under the terms of the CeCILL-B 
-*  license as circulated by CEA, CNRS and INRIA at the following URL 
-*  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
-*  or in the file LICENSE.txt.
-*
-*  As a counterpart to the access to the source code and  rights to copy,
-*  modify and redistribute granted by the license, users are provided only
-*  with a limited warranty  and the software's author,  the holder of the
-*  economic rights,  and the successive licensors  have only  limited
-*  liability. 
-*
-*  The fact that you are presently reading this means that you have had
-*  knowledge of the CeCILL-B license and that you accept its terms.
-* ------------------------------------------------------------------------ */                                                                         
+
 
 /**
  *\file
@@ -78,8 +85,10 @@ namespace bbtk
     mDescription(description),
     mVersion(version)
   {
+
     bbtkDebugMessage("object",2,"==> Package('"<<name<<"',...)"
                     <<bbtkendl);
+
     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; 
@@ -118,49 +127,49 @@ namespace bbtk
 
 
   //==========================================================================
-         void PackageReleaseBlackBoxDescriptorInternal(Package::WeakPointer pack,
-                                                       const std::string& descname)
-         {
-               // Try to release descriptor
-               std::string packname = pack.lock()->GetName();
-
-               bbtkDebugMessage("package",5,"--- Releasing descriptor '"
-                                <<packname<<"::"<<descname<<"'"<<bbtkendl);
-
-
-               Package::BlackBoxMapType::iterator desc = 
-                 pack.lock()->GetBlackBoxMap().find(descname);
-               if (desc ==  pack.lock()->GetBlackBoxMap().end())
-                 {
-               bbtkDebugMessage("package",5,
-                                "    Descriptor has already been released"
-                                <<bbtkendl);
-               return;
+  void PackageReleaseBlackBoxDescriptorInternal(Package::WeakPointer pack,
+                                               const std::string& descname)
+  {
+    // Try to release descriptor
+    std::string packname = pack.lock()->GetName();
+    
+    bbtkDebugMessage("package",5,"--- Releasing descriptor '"
+                    <<packname<<"::"<<descname<<"'"<<bbtkendl);
+    
+    
+    Package::DescriptorMapType::iterator desc = 
+      pack.lock()->GetDescriptorMap().find(descname);
+    if (desc ==  pack.lock()->GetDescriptorMap().end())
+      {
+       bbtkDebugMessage("package",5,
+                        "    Descriptor has already been released"
+                       <<bbtkendl);
+       return;
                  }
-               //    bbtkDebugMessage("package",3,
-               //                   "    Trying unreferencing it ... "<<std::endl);
-               BlackBoxDescriptor::WeakPointer pdesc = desc->second;
-               desc->second.reset();
-               // if it is dead : remove it 
-               if (pdesc.expired()) 
-               {
-                 bbtkDebugMessage("package",2," ==> '"<<packname<<"::"<<descname<<"' Descriptor expired"<<bbtkendl);
-                 if (pack.expired()) 
-                 {
-                       bbtkDebugMessage("package",2,
-                                        "     ... and caused its package death"
-                                        <<bbtkendl);
-                       return;
-                 } // pack.expired
-                 desc = pack.lock()->GetBlackBoxMap().find(descname);
-                 if (desc !=  pack.lock()->GetBlackBoxMap().end())       pack.lock()->GetBlackBoxMap().erase(desc);
-               }   else    {  //pdesc.expired
-                    bbtkDebugMessage("package",5,"    ... Descriptor still alive ("
-                                <<pdesc.use_count()<<" refs)"
-                                <<bbtkendl);
-                    pack.lock()->GetBlackBoxMap()[descname] = pdesc.lock();
-               } // pdesc.expired
-         }
+    //    bbtkDebugMessage("package",3,
+    //              "    Trying unreferencing it ... "<<std::endl);
+    BlackBoxDescriptor::WeakPointer pdesc = desc->second;
+    desc->second.reset();
+    // if it is dead : remove it 
+    if (pdesc.expired()) 
+      {
+       bbtkDebugMessage("package",2," ==> '"<<packname<<"::"<<descname<<"' Descriptor expired"<<bbtkendl);
+       if (pack.expired()) 
+         {
+           bbtkDebugMessage("package",2,
+                             "     ... and caused its package death"
+                            <<bbtkendl);
+           return;
+         } // pack.expired
+       desc = pack.lock()->GetDescriptorMap().find(descname);
+       if (desc !=  pack.lock()->GetDescriptorMap().end())       pack.lock()->GetDescriptorMap().erase(desc);
+      }   else    {  //pdesc.expired
+      bbtkDebugMessage("package",5,"    ... Descriptor still alive ("
+                      <<pdesc.use_count()<<" refs)"
+                      <<bbtkendl);
+      pack.lock()->GetDescriptorMap()[descname] = pdesc.lock();
+    } // pdesc.expired
+  }
   //==========================================================================
 
 
@@ -173,7 +182,7 @@ namespace bbtk
                     packname<<"')"<<bbtkendl);
 
     long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 
-    long ndesc = pack.lock()->GetBlackBoxMap().size();
+    long ndesc = pack.lock()->GetDescriptorMap().size();
     long nrefs = pack.use_count();
 
     bbtkDebugMessage("package",5," "<<nrefs<<" refs / "
@@ -207,9 +216,9 @@ namespace bbtk
 
        // The list of descriptors names at start
        std::vector<std::string> descnamelist;
-       BlackBoxMapType::iterator i;
-       for (i=pack.lock()->mBlackBoxMap.begin();
-            i!= pack.lock()->mBlackBoxMap.end();
+       DescriptorMapType::iterator i;
+       for (i=pack.lock()->mDescriptorMap.begin();
+            i!= pack.lock()->mDescriptorMap.end();
             ++i)
          descnamelist.push_back(i->first);
 
@@ -227,11 +236,13 @@ namespace bbtk
                                 <<"') : package expired during release : bailing out"<<bbtkendl);
                break;
              }
-           
+  
 #if defined(MACOSX)
-                 BlackBoxDescriptor::Pointer desc = pack.lock()->mBlackBoxMap[*descname];
+                 BlackBoxDescriptor::Pointer desc = pack.lock()->mDescriptorMap[*descname];
                  if ( (dyn==0) || (boost::dynamic_pointer_cast<ComplexBlackBoxDescriptor>(desc)) )
+                 {
                          PackageReleaseBlackBoxDescriptorInternal(pack,*descname);
+                 } 
 #else
                  PackageReleaseBlackBoxDescriptorInternal(pack,*descname);
 #endif
@@ -242,10 +253,7 @@ namespace bbtk
        UnLoadDynamicLibrary(pack);
        // Unload orphan dl packages 
        Package::UnLoadReleasedDynamicallyLoadedPackages();
-       
 
-       
-       
       }
     
 #ifdef BBTK_COMPILE_DEBUG_MESSAGES
@@ -256,7 +264,7 @@ namespace bbtk
     if (!pack.expired())
       {
        long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 
-       long ndesc = pack.lock()->GetBlackBoxMap().size();
+       long ndesc = pack.lock()->GetDescriptorMap().size();
        long nrefs = pack.use_count();
        
        bbtkDebugMessage("package",1," ... Package still alive ("
@@ -289,7 +297,7 @@ namespace bbtk
                     <<descr.use_count()<<bbtkendl);
 
     long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 
-    long ndesc = pack.lock()->GetBlackBoxMap().size();
+    long ndesc = pack.lock()->GetDescriptorMap().size();
     long nrefs = pack.use_count();
 
     bbtkDebugMessage("package",5," "<<nrefs<<" refs / "
@@ -325,7 +333,7 @@ namespace bbtk
     if (!pack.expired())
       {
        long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 
-       long ndesc = pack.lock()->GetBlackBoxMap().size();
+       long ndesc = pack.lock()->GetDescriptorMap().size();
        long nrefs = pack.use_count();
        
        bbtkDebugMessage("package",3," ... Package still alive ("
@@ -350,11 +358,8 @@ namespace bbtk
   /// to test that a dyn lib is a valid bbtk package lib
   /// NB : The BBTK version exported from the library 
   ///      is tested against the current bbtk version
-  DynamicLibraryHandler Package::OpenDynamicLibrary
-  ( const std::string& libname,
-    const std::string& package_name,
-    DLGetPackageFunction& getpack,
-    DLDeletePackageFunction& delpack)
+  DynamicLibraryHandler Package::OpenDynamicLibrary( const std::string& libname,const std::string& package_name,
+                                                                                                        DLGetPackageFunction& getpack, DLDeletePackageFunction& delpack)
   {
     bbtkDebugMessage("package",3,"==> Package::OpenDynamicLibrary("
                     <<libname<<")"<<std::endl);
@@ -367,8 +372,8 @@ namespace bbtk
          
     if (!handler)
       {
-       bbtkMessage("package",2,
-                   "Could not open shared library [" <<libname<<"] : "
+       bbtkMessage("package",0,
+                   "BBTK ..ERROR.. loading could not open shared library [" <<libname<<"] : "
                    <<dlerror() << std::endl);
        return 0;
       }
@@ -377,15 +382,13 @@ namespace bbtk
 
     // Loads the Package bbtk version function 
     std::string getvername(package_name);
-    getvername += 
-      BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_BBTK_VERSION_FUNCTION_NAME);
-    DLGetPackageBBTKVersionFunction getbbtkversion 
-      = (DLGetPackageBBTKVersionFunction)(dlsym(handler,getvername.c_str()));
+    getvername += BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_BBTK_VERSION_FUNCTION_NAME);
+    DLGetPackageBBTKVersionFunction getbbtkversion  = (DLGetPackageBBTKVersionFunction)(dlsym(handler,getvername.c_str()));
     if (!getbbtkversion)
       {
        bbtkDebugMessage("package",3,"***"<<std::endl);
-       bbtkMessage("package",2,
-                   "Shared library ["<<libname
+       bbtkMessage("package",0,
+                   "BBTK ..ERROR.. loading shared library ["<<libname
                    <<"] is not a valid bbtk package."
                    <<" Symbol ["<<getvername<<"] :"<<dlerror()<< std::endl);
        dlclose(handler);
@@ -395,14 +398,16 @@ namespace bbtk
     bbtkDebugMessage("package",3,"* Symbol ["<<getvername
                     <<"] found"<<std::endl);
     // version matches ?
+
     if (getbbtkversion() != bbtk::GetVersion())
       {
-       bbtkMessage("package",2,
-                   "Shared library ["<<libname
+       bbtkMessage("package",0,
+                   "BBTK ..ERROR.. loading: "<<package_name
+                       <<" - Shared library ["<<libname
                    <<"] was build with bbtk version "
                    <<getbbtkversion()
                    <<" but the current program runs with version "
-                   <<bbtk::GetVersion()<<" : cannot load it"<<std::endl);
+                   <<bbtk::GetVersion()<<" : cannot load it. You have to recompile your BBTK-Package."<<std::endl);
        dlclose(handler);
        return 0;
        
@@ -415,8 +420,8 @@ namespace bbtk
     getpack = (DLGetPackageFunction)(dlsym(handler, getpackname.c_str()));
     if (!getpack)
       {
-       bbtkMessage("package",2,
-                   "Shared library ["<<libname
+       bbtkMessage("package",0,
+                   "BBTK ..ERROR.. loading shared library ["<<libname
                    <<"] is not a valid bbtk package."
                    <<" Symbol ["<<getpackname<<"] :"<<dlerror()<< std::endl);
        dlclose(handler);
@@ -431,8 +436,8 @@ namespace bbtk
     delpack = (DLDeletePackageFunction)(dlsym(handler, delpackname.c_str()));
     if (!delpack)
       {
-       bbtkMessage("package",2,
-                   "Shared library ["<<libname
+       bbtkMessage("package",0,
+                   "BBTK ..ERROR.. loading shared library ["<<libname
                    <<"] is not a valid bbtk package."
                    <<" Symbol ["<<delpackname<<"] :"<<dlerror()<< std::endl);
        dlclose(handler);
@@ -448,8 +453,8 @@ namespace bbtk
     handler = LoadLibrary(libname.c_str());
     if (!handler)
       {
-       bbtkMessage("package",2,
-                   "Could not open shared library [" <<libname<<"]"
+       bbtkMessage("package",0,
+                   "BBTK ..ERROR..  could not open shared library [" <<libname<<"]"
                    << std::endl);
        DWORD dwErrorCode = 0;
        dwErrorCode = GetLastError();
@@ -462,16 +467,14 @@ namespace bbtk
     
     // Loads the Package bbtk version function 
     std::string getvername(package_name);
-    getvername += 
-      BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_BBTK_VERSION_FUNCTION_NAME);
-    DLGetPackageBBTKVersionFunction getbbtkversion 
-      = (DLGetPackageBBTKVersionFunction)(GetProcAddress(handler,
-                                                       getvername.c_str()));
+    getvername += BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_BBTK_VERSION_FUNCTION_NAME);
+    DLGetPackageBBTKVersionFunction getbbtkversion = (DLGetPackageBBTKVersionFunction)(GetProcAddress(handler, getvername.c_str()));
+         
     if (!getbbtkversion)
       {
        FreeLibrary(handler);
-       bbtkMessage("package",2,
-                   "Shared library ["<<libname
+       bbtkMessage("package",0,
+                   "BBTK ..ERROR.. loading shared library ["<<libname
                    <<"] is not a valid bbtk package."
                    <<" Symbol ["<<getbbtkversion<<"] not found"<< std::endl);
        return 0;
@@ -480,15 +483,15 @@ namespace bbtk
     // version matches ?
     if (getbbtkversion() != bbtk::GetVersion())
       {
-       FreeLibrary(handler);
-       bbtkMessage("package",2,
-                   "Shared library ["<<libname
-                   <<"] was build with bbtk version "
-                   <<getbbtkversion()
-                   <<" but the current program runs with version "
-                   <<bbtk::GetVersion()<<" : cannot load it"<<std::endl);
-       return 0;
-       
+                 FreeLibrary(handler);
+                 bbtkMessage("package",0,
+                               "BBTK ..ERROR.. loading: "<<package_name
+                               <<" - Shared library ["<<libname
+                               <<"] was build with bbtk version "
+                               <<getbbtkversion()
+                               <<" but the current program runs with version "
+                               <<bbtk::GetVersion()<<" : cannot load it. You have to recompile your BBTK-Package."<<std::endl);
+                 return 0;
       }
 
      // Loads the Package get function
@@ -498,8 +501,8 @@ namespace bbtk
     if (!getpack)
       {
        FreeLibrary(handler);
-       bbtkMessage("package",2,
-                   "Shared library ["<<libname
+       bbtkMessage("package",0,
+                   "BBTK ..ERROR.. loading shared library ["<<libname
                    <<"] is not a valid bbtk package."
                    <<" Symbol ["<<getpackname<<"] not found"<< std::endl);
        return 0;
@@ -512,8 +515,8 @@ namespace bbtk
     if (!delpack)
       {
        FreeLibrary(handler);
-       bbtkMessage("package",2,
-                   "Shared library ["<<libname
+       bbtkMessage("package",0,
+                   "BBTK ..ERROR.. loading shared library ["<<libname
                    <<"] is not a valid bbtk package."
                    <<" Symbol ["<<delpackname<<"] not found"<< std::endl);
        return 0;
@@ -575,25 +578,23 @@ namespace bbtk
   {
     if (pack.expired() || (!pack.lock()->mDynamicLibraryHandler))
       return;
-    
-    
+
     std::string packname = pack.lock()->GetName();
     bbtkDebugMessage("package",5,"==> Package::UnLoadDynamicLibrary('"
                     <<packname<<"')"
                     <<std::endl);
-    
-    if (!pack.lock()->GetBlackBoxMap().empty())
+
+    if (!pack.lock()->GetDescriptorMap().empty())
       {
-       
+
        bbtkDebugMessage("package",5,"   Package not empty ... abort"
                         <<std::endl);
        return;
        /*
        bbtkGlobalError("Package::UnLoadDynamicLibrary('"<<packname<<") : "
-                       <<"BlackBoxMap not empty "
+                       <<"DescriptorMap not empty "
                        <<BBTK_INTERNAL_ERROR_MESSAGE);
        */
-       
       }
 
     if (pack.use_count()!=1)
@@ -616,13 +617,11 @@ namespace bbtk
        bbtkDebugMessage("package",1,"==> package '"<<packname
                         <<"' put in the 'to unload' list"
                         <<std::endl);
-
       }
 
     bbtkDebugMessage("package",5,"<== Package::UnLoadDynamicLibrary('"
                     <<packname<<"')"
-                    <<std::endl);
-    
+                    <<std::endl); 
   }
   //==========================================================================
 
@@ -682,21 +681,32 @@ namespace bbtk
   }
   //==========================================================================
 
+       bool Package::ifBoxExist( std::string type)     
+    {
+               bool ok=false;
+               DescriptorMapType::const_iterator i = mDescriptorMap.find(type);
+               if (i != mDescriptorMap.end())  
+               {
+                       ok=true;
+               }
+               return ok;
+    }
+       
   //==========================================================================
   /// Creates an instance of a black box of type <type> with name <name>
   BlackBox::Pointer Package::NewBlackBox(const std::string& type, 
                                         const std::string& name) const
   {
-    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::NewBlackBox(\""<<type<<"\",\""<<name<<"\")"<<bbtkendl);
+    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<">::NewBlackBox(\""<<type<<"\",\""<<name<<"\")"<<bbtkendl);
     
-    BlackBoxMapType::const_iterator i = mBlackBoxMap.find(type);
-    if (i == mBlackBoxMap.end())  
+    DescriptorMapType::const_iterator i = mDescriptorMap.find(type);
+    if (i == mDescriptorMap.end())  
     {
-          bbtkDebugDecTab("Kernel",8);
+          bbtkDebugDecTab("kernel",8);
           return BlackBox::Pointer();
     }
     BlackBox::Pointer bb =i->second->NewBlackBox(name);
-    bbtkDebugDecTab("Kernel",8);
+    bbtkDebugDecTab("kernel",8);
     return bb;   
 
   }
@@ -711,7 +721,7 @@ namespace bbtk
                                const DataInfo& typeout,
                                const std::string& name) const
   {
-    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
+    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<
                        ">::NewAdaptor("
                        <<typein<<","
                        <<typeout<<",\""
@@ -722,11 +732,11 @@ namespace bbtk
     AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
     if (i == mAdaptorMap.end())  
       {
-       bbtkDebugDecTab("Kernel",8);
+       bbtkDebugDecTab("kernel",8);
        return BlackBox::Pointer();
       }
     BlackBox::Pointer bb =i->second.lock()->NewBlackBox(name);
-    bbtkDebugDecTab("Kernel",8);
+    bbtkDebugDecTab("kernel",8);
     return bb;   
 
   }
@@ -739,7 +749,7 @@ namespace bbtk
                                      const DataInfo& typeout,
                                      const std::string& name) const
   {
-    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
+    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<
                        ">::NewWidgetAdaptor("
                        <<typein<<","
                        <<typeout<<",\""
@@ -750,11 +760,11 @@ namespace bbtk
     AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
     if (i == mAdaptorMap.end())  
       {
-       bbtkDebugDecTab("Kernel",8);
+       bbtkDebugDecTab("kernel",8);
        return BlackBox::Pointer();
       }
     BlackBox::Pointer bb =i->second.lock()->NewBlackBox(name);
-    bbtkDebugDecTab("Kernel",8);
+    bbtkDebugDecTab("kernel",8);
     return bb;   
 
   }
@@ -771,7 +781,7 @@ namespace bbtk
                                  const DataInfo& typeout,
                                  std::string& adaptor) const
   {
-    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
+    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<
                        ">::FindWidgetAdaptor("
                        <<typein<<","
                        <<typeout<<")"<<bbtkendl);
@@ -784,11 +794,11 @@ namespace bbtk
     AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
     if (i == mAdaptorMap.end())  
       {
-       bbtkDebugDecTab("Kernel",8);
+       bbtkDebugDecTab("kernel",8);
        return false;
       }
     adaptor = i->second.lock()->GetTypeName();
-    bbtkDebugDecTab("Kernel",8);
+    bbtkDebugDecTab("kernel",8);
     return true;   
 
   }
@@ -805,7 +815,7 @@ namespace bbtk
                            const DataInfo& typeout,
                            std::string& adaptor) const
   {
-    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
+    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<
                        ">::FindAdaptor("
                        <<typein<<","
                        <<typeout<<")"<<bbtkendl);
@@ -815,11 +825,11 @@ namespace bbtk
     AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
     if (i == mAdaptorMap.end())  
       {
-       bbtkDebugDecTab("Kernel",8);
+       bbtkDebugDecTab("kernel",8);
        return false;
       }
     adaptor = i->second.lock()->GetTypeName();
-    bbtkDebugDecTab("Kernel",8);
+    bbtkDebugDecTab("kernel",8);
     return true;   
 
   }
@@ -828,26 +838,26 @@ namespace bbtk
 
   //==========================================================================
   /// Registers a black box descriptor in the package
-  bool Package::RegisterBlackBox(BlackBoxDescriptor::Pointer d) 
+  bool Package::Register(BlackBoxDescriptor::Pointer d) 
   {
-    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\")"<<std::endl);
+    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<">::Register(\""<<d->GetTypeName()<<"\")"<<std::endl);
     
-    BlackBoxMapType::iterator i = mBlackBoxMap.find(d->GetTypeName());
-    if (i!=mBlackBoxMap.end())
+    DescriptorMapType::iterator i = mDescriptorMap.find(d->GetTypeName());
+    if (i!=mDescriptorMap.end())
       {
        bbtkWarning("Package<"<<GetName()<<"> : Trying to register box type <"
                    <<d->GetTypeName()<<"> which is already in the package");
        return false;
       }
 
-    mBlackBoxMap[d->GetTypeName()] = d;
+    mDescriptorMap[d->GetTypeName()] = d;
     //    d->Reference();
     d->SetPackage(GetThisPointer<Package>());
     
     // If it is a default adaptor, also register it in the adaptors map
     if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR )
       {
-       bbtkDebugMessage("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\") : The box is an adaptor, inserting it in adaptors map ..."<<std::endl);   
+       bbtkDebugMessage("kernel",8,"Package<"<<GetName()<<">::Register(\""<<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();
@@ -877,7 +887,7 @@ namespace bbtk
     // If it is a default adaptor, also register it in the adaptors map
     else if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_GUI)
       {
-       bbtkDebugMessage("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\") : The box is a widget adaptor, inserting it in adaptors map ..."<<std::endl);   
+       bbtkDebugMessage("kernel",8,"Package<"<<GetName()<<">::Register(\""<<d->GetTypeName()<<"\") : The box is a widget adaptor, inserting it in adaptors map ..."<<std::endl);   
        
        TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
        DataInfo infoin(typeid(void),"");
@@ -905,20 +915,20 @@ namespace bbtk
       }
     
 
-    bbtkDebugDecTab("Kernel",8);
+    bbtkDebugDecTab("kernel",8);
    
     return true;
   }
   //==========================================================================
   
   //===================================================================
-  void Package::CheckBoxes() const
+  void Package::Check() const
   {
     bbtkMessage("debug",1,"****** Checking Package "<<(void*)this
                <<" ["<<GetName()<<"]"<<std::endl);
-    BlackBoxMapType::const_iterator i;
-    for (i=mBlackBoxMap.begin();
-        i!=mBlackBoxMap.end();
+    DescriptorMapType::const_iterator i;
+    for (i=mDescriptorMap.begin();
+        i!=mDescriptorMap.end();
         ++i) 
       {
        i->second->Check(true);
@@ -931,39 +941,40 @@ namespace bbtk
 
   //==========================================================================
   /// Changes the name of a black box type
-  void Package::ChangeBlackBoxName( const std::string& oldname, const std::string& newname )
+  void Package::ChangeDescriptorName( const std::string& oldname, const std::string& newname )
   { 
-    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::ChangeBlackBoxName(\""<<oldname<<"\",\""<<newname<<"\")"<<std::endl);
+    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()
+                       <<">::ChangeDescriptorName(\""<<oldname
+                       <<"\",\""<<newname<<"\")"<<std::endl);
     // Looking into the bb map
-    BlackBoxMapType::iterator i = mBlackBoxMap.find(oldname);
-    if (i == mBlackBoxMap.end())  
+    DescriptorMapType::iterator i = mDescriptorMap.find(oldname);
+    if (i == mDescriptorMap.end())  
       {
-         bbtkDebugDecTab("Kernel",8);
-         bbtkError("ChangeBlackBoxName : The package <"<<GetName()<<"> does not contains the black box <"<<oldname<<">");
+         bbtkDebugDecTab("kernel",8);
+         bbtkError("ChangeDescriptorName : The package <"<<GetName()<<"> does not contains the black box <"<<oldname<<">");
       }
 
     i->second->SetTypeName(newname);
-    mBlackBoxMap[newname] = i->second;
-    mBlackBoxMap.erase(i);
+    mDescriptorMap[newname] = i->second;
+    mDescriptorMap.erase(i);
 
-    bbtkDebugDecTab("Kernel",8);    
+    bbtkDebugDecTab("kernel",8);    
   }
   //==========================================================================
 
 
 
   //==========================================================================
-  /// Displays the list of black boxes of the package
-  void Package::PrintBlackBoxes(bool description, bool adaptors) const
+  void Package::PrintHelpListDescriptors(bool description, bool adaptors) const
   {
     unsigned int lmax = 0;
     std::vector<std::string> names;
     std::vector<std::string> kinds;
     std::vector<std::string> descrs;
 
-    BlackBoxMapType::const_iterator i;
-    for (i=mBlackBoxMap.begin();
-        i!=mBlackBoxMap.end();
+    DescriptorMapType::const_iterator i;
+    for (i=mDescriptorMap.begin();
+        i!=mDescriptorMap.end();
         ++i) 
       {
        if ( adaptors || 
@@ -1007,15 +1018,15 @@ namespace bbtk
       {
        std::string space;
        space.append(lmax - ni->size() - ci->size(),' ');
-       bbtkMessage("Help",1,*ni << space << *ci );
+       bbtkMessage("help",1,*ni << space << *ci );
        std::string d(*di);
        unsigned int dmax = 75 - lmax;
        //      while (d.size() > dmax ) 
        //  {
        if (d.size()>dmax) 
-         bbtkMessage("Help",1,d.substr(0,dmax) << "..." << std::endl);
+         bbtkMessage("help",1,d.substr(0,dmax) << "..." << std::endl);
        else 
-         bbtkMessage("Help",1,d << std::endl);
+         bbtkMessage("help",1,d << std::endl);
        //    d = d.substr(dmax,d.size());
        //  }
       }
@@ -1025,30 +1036,30 @@ namespace bbtk
 
   //==========================================================================
   /// Displays the list of adaptors of the package
-  void Package::PrintAdaptors(bool description) const
+  void Package::PrintHelpListAdaptors(bool description) const
   {
-    BlackBoxMapType::const_iterator i;
-    for (i=mBlackBoxMap.begin();
-        i!=mBlackBoxMap.end();
+    DescriptorMapType::const_iterator i;
+    for (i=mDescriptorMap.begin();
+        i!=mDescriptorMap.end();
         ++i) 
       {
        if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD ) 
          {
-           bbtkMessage("Help",1,
+           bbtkMessage("help",1,
                        "  "<<i->second->GetTypeName());
            if ( i->second->GetKind() == 
                 BlackBoxDescriptor::DEFAULT_ADAPTOR )
              {
-               bbtkMessage("Help",1,
+               bbtkMessage("help",1,
                            " [default]");
              }  
            if (description) 
              {
-               bbtkMessage("Help",1,
+               bbtkMessage("help",1,
                            " : "<<i->second->GetDescription());
 
              } 
-           bbtkMessage("Help",1,std::endl);
+           bbtkMessage("help",1,std::endl);
          }
       } 
     /*
@@ -1057,36 +1068,37 @@ namespace bbtk
         i!=mAdaptorMap.end();
         ++i) 
       {
-       bbtkMessage("Help",1,
+       bbtkMessage("help",1,
                    "  "<<i->second->GetTypeName());
        if (detail_level>0) 
          {
-           bbtkMessage("Help",1,
+           bbtkMessage("help",1,
                        " : "<<i->second->GetDescription());
   
          } 
-       bbtkMessage("Help",1,std::endl);
+       bbtkMessage("help",1,std::endl);
       }
     */ 
   }
   //==========================================================================
 
   //==========================================================================
-  /// Prints help on a black box
-  void Package::HelpBlackBox(const std::string& name, bool full) const
+  /// Prints help on a black box descriptor
+  void Package::PrintHelpDescriptor(const std::string& name, bool full) const
   {
-    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
+    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()
+                       <<">::PrintHelpDescriptor(\""
                        <<name<<"\")"<<bbtkendl);
 
-    BlackBoxMapType::const_iterator i = mBlackBoxMap.find(name);
-    if (i == mBlackBoxMap.end())  
+    DescriptorMapType::const_iterator i = mDescriptorMap.find(name);
+    if (i == mDescriptorMap.end())  
       {
-       bbtkDebugDecTab("Kernel",8);
+       bbtkDebugDecTab("kernel",8);
        bbtkError("The package <"<<GetName()<<"> does not contains the black box <"<<name<<">");
       }
-    //    bbtkMessage("Help",1,"["<<GetName()<<"] ");
+    //    bbtkMessage("help",1,"["<<GetName()<<"] ");
     i->second->GetHelp(full);
-    bbtkDebugDecTab("Kernel",8);
+    bbtkDebugDecTab("kernel",8);
 
   }
   //==========================================================================
@@ -1094,18 +1106,19 @@ namespace bbtk
 
   //==========================================================================
   /// Returns true iff the package contains the box of name boxname
-  bool Package::ContainsBlackBox(const std::string& name) const 
+  bool Package::ContainsDescriptor(const std::string& name) const 
   {
-    bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
+    bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()
+                       <<">::ContainsDescriptor(\""
                        <<name<<"\")"<<bbtkendl);
     
-    BlackBoxMapType::const_iterator i = mBlackBoxMap.find(name);
-    if (i == mBlackBoxMap.end())  
+    DescriptorMapType::const_iterator i = mDescriptorMap.find(name);
+    if (i == mDescriptorMap.end())  
     {
-      bbtkDebugDecTab("Kernel",8);
+      bbtkDebugDecTab("kernel",8);
       return false;
     }
-    bbtkDebugDecTab("Kernel",8);
+    bbtkDebugDecTab("kernel",8);
     return true;
   }
   //==========================================================================
@@ -1122,9 +1135,11 @@ namespace bbtk
                               int level,
                               bool relative_link ) const
   {
-    bbtkDebugMessageInc("Kernel",9,"Package<"<<GetName()<<">::CreateHtmlPage(\""
+    bbtkDebugMessageInc("kernel",9,"Package<"<<GetName()<<">::CreateHtmlPage(\""
                        <<filename<<"\")"<<bbtkendl);
 
+//std::cout<<"JCP bbtkPackage.cxx void Package::CreateHtmlPage() ln 1133"<<std::endl;
+
     //---------------------
     // Open output file
     std::ofstream s;
@@ -1215,7 +1230,7 @@ namespace bbtk
          << bbtk::GetVersion() << "</TD></TR>\n";
        s << "</TABLE>\n";
       }
-
+//std::cout<<"JCP bbtkPackage.cxx void Package::CreateHtmlPage() ln 1225"<<std::endl;
     //-------------------
     // Table of contents
     // Black boxes list
@@ -1225,65 +1240,65 @@ namespace bbtk
 
     s << "<p><TABLE cellspacing=0  cellpadding=3>\n";
 
-    BlackBoxMapType::const_iterator i;
-    for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i) 
-      {
-       if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD) 
-         continue;
+    DescriptorMapType::const_iterator i;
+//std::cout<<"JCP bbtkPackage.cxx void Package::CreateHtmlPage() ln 1236"<<std::endl;
+    for (i=mDescriptorMap.begin(); i!=mDescriptorMap.end(); ++i) {
+               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 << "<TR>";
-       s << "<TD style='vertical-align: top;'>";
-       s << "&nbsp;&nbsp;&nbsp;<a name=\"toc_"<<name
-         <<"\" href=\"#"<<name<<"\">"
-         <<name<<"</a>";
-       s << "</TD> ";
-       s << " <TD style='vertical-align: top;'>" << descr << " </TD>";
-        s << "</TR>\n";
-      }    
-    s << "</TABLE>\n";
-    
+               std::string name = i->second->GetTypeName();
+               Utilities::html_format(name);
+               std::string descr = i->second->GetDescription();
+               //Utilities::html_format(descr);
+//std::cout<<"JCP bbtkPackage.cxx void Package::CreateHtmlPage() ln 1246"<<std::endl;
+               s << "<TR>";
+               s << "<TD style='vertical-align: top;'>";
+               s << "&nbsp;&nbsp;&nbsp;<a name=\"toc_"<<name
+               <<"\" href=\"#"<<name<<"\">"
+               <<name<<"</a>";
+               s << "</TD> ";
+               s << " <TD style='vertical-align: top;'>" << descr << " </TD>";
+               s << "</TR>\n";
+               }    
+               s << "</TABLE>\n";
+
+
+               s << "</ul>\n";
+               s << "</div>\n";
     
-    s << "</ul>\n";
-    s << "</div>\n";
-    
-    //-------------------
-    // Adaptors list
-    if (mAdaptorMap.size()>0) 
-      {
-       //  s << "<div class=\"contents\">\n";
-       s << "<p><b> Adaptors : </b>\n";
-       s << "<ul>\n";
-
-       //    BlackBoxMapType::const_iterator i;
-       s << "<p><TABLE cellspacing=0  cellpadding=3>\n";
-       for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end();++i) 
-         {
-           if ( i->second->GetKind() == BlackBoxDescriptor::STANDARD) 
-             continue;
-    
-           std::string name = i->second->GetTypeName();
-           Utilities::html_format(name);
-           std::string descr = i->second->GetDescription();
+               //-------------------
+               // Adaptors list
+               if (mAdaptorMap.size()>0) 
+               {
+                       //  s << "<div class=\"contents\">\n";
+                       s << "<p><b> Adaptors : </b>\n";
+                       s << "<ul>\n";
+//std::cout<<"JCP bbtkPackage.cxx void Package::CreateHtmlPage() ln 1268"<<std::endl;
+                       //    DescriptorMapType::const_iterator i;
+                       s << "<p><TABLE cellspacing=0  cellpadding=3>\n";
+                       for (i=mDescriptorMap.begin(); i!=mDescriptorMap.end();++i) 
+                       {
+                               if ( i->second->GetKind() == BlackBoxDescriptor::STANDARD) 
+                                       continue;
     
-           s << "<TR>";
-           s << "<TD style='vertical-align: top;'>";
-           s << "&nbsp;&nbsp;&nbsp;<a name=\"toc_"<<name
-             <<"\" href=\"#"<<name<<"\">"
-             <<name<<"</a>";
-           s << "</TD> ";
-           s << " <TD style='vertical-align: top;'>" << descr << " </TD>";
-           s << "</TR>\n";
-         }    
-       s << "</TABLE>\n";
-
-       s << "</ul>\n";
-       s << "</div>\n";
-      }
+                               std::string name = i->second->GetTypeName();
+                               Utilities::html_format(name);
+                               std::string descr = i->second->GetDescription();
+                   
+                               s << "<TR>";
+                               s << "<TD style='vertical-align: top;'>";
+                               s << "&nbsp;&nbsp;&nbsp;<a name=\"toc_"<<name
+                                 <<"\" href=\"#"<<name<<"\">"
+                                 <<name<<"</a>";
+                               s << "</TD> ";
+                               s << " <TD style='vertical-align: top;'>" << descr << " </TD>";
+                               s << "</TR>\n";
+                       }    
+                       s << "</TABLE>\n";
+
+                       s << "</ul>\n";
+                       s << "</div>\n";
+               }
     
     
     //  s << "<div class=\"node\">\n";
@@ -1302,23 +1317,23 @@ namespace bbtk
     //-------------------
     // Computes output directory from filename to pass it to 
     // BlackBoxDescriptor::InsertHtmlHelp
-    std::string dir;
+               std::string dir;
 
-    std::string::size_type slash_position = filename.find_last_of("/\\");
+               std::string::size_type slash_position = filename.find_last_of("/\\");
 
 
-       if (slash_position != std::string::npos) {
-      if (slash_position == 0)
-         slash_position = 1;  
-      dir = filename.substr(0,slash_position);
-    }
+               if (slash_position != std::string::npos) {
+                       if (slash_position == 0)
+                        slash_position = 1;  
+                       dir = filename.substr(0,slash_position);
+               }
 
-    for (i=mBlackBoxMap.begin();
-        i!=mBlackBoxMap.end();
-        ++i) 
-      {
-       i->second->InsertHtmlHelp(s,detail,level,dir,relative_link);
-      }    
+               for (i=mDescriptorMap.begin();
+                i!=mDescriptorMap.end();
+                ++i) 
+               {
+                       i->second->InsertHtmlHelp(s,detail,level,dir,relative_link);
+               }    
 
     //----------------------
     // Footer 
@@ -1338,7 +1353,7 @@ namespace bbtk
     //----------------------
 
     // End
-    bbtkDebugDecTab("Kernel",9);
+    bbtkDebugDecTab("kernel",9);
   }
   //==========================================================================
   
@@ -1353,7 +1368,7 @@ namespace bbtk
   std::string Package::GetObjectInfo() const 
   {
     std::stringstream i;
-    i << "  - "<<mBlackBoxMap.size() << " boxes" << std::endl;
+    i << "  - "<<mDescriptorMap.size() << " boxes" << std::endl;
     if (mDynamicLibraryHandler) 
       {
        i<< "  - Loaded from dynamic library"<<std::endl;
@@ -1384,18 +1399,29 @@ namespace bbtk
     size_t s = Superclass::GetObjectRecursiveSize();
     s += Package::GetObjectInternalSize();
     
-    BlackBoxMapType::const_iterator i;
-    for (i = mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i )
+    DescriptorMapType::const_iterator i;
+    for (i = mDescriptorMap.begin(); i!=mDescriptorMap.end(); ++i )
       {
        s += i->second->GetObjectRecursiveSize();
       }
     return s;
   }
   //==========================================================================
-  
+  void  Package::GetBoxesInside(NodeTreeC& tree, int cont) 
+  {
+               DescriptorMapType::const_iterator i;
+               std::cout<<"*********a********"<<std::endl;
+               for (i=mDescriptorMap.begin(); i!=mDescriptorMap.end(); ++i) 
+               {
+                       i->second->GetBoxesInside(tree, cont);
+                       std::cout<<"*****************"<<std::endl;
+               }    
+  }
+       //==========================================================================
   //==========================================================================
   std::set<Package::WeakPointer> 
   Package::mReleasedDynamicallyLoadedPackages;
   //==========================================================================
+
 }