]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkPackage.cxx
Bug #1754
[bbtk.git] / kernel / src / bbtkPackage.cxx
index 66465e9813e2bb200a50e611848ad8c3d3e2cc88..1aa5a1c19a980ec2ddb61372af3d3fdc79501850 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkPackage.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/09/12 14:52:25 $
-  Version:   $Revision: 1.35 $
+  Date:      $Date: 2012/11/14 07:12:00 $
+  Version:   $Revision: 1.36 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -349,11 +349,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);
@@ -366,8 +363,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;
       }
@@ -376,15 +373,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);
@@ -396,12 +391,13 @@ namespace bbtk
     // 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;
        
@@ -414,8 +410,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);
@@ -430,8 +426,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);
@@ -447,8 +443,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();
@@ -461,16 +457,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;
@@ -479,15 +473,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
@@ -497,8 +491,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;
@@ -511,8 +505,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;
@@ -677,7 +671,6 @@ namespace bbtk
   }
   //==========================================================================
 
-//ups4 EED borrame
        bool Package::ifBoxExist( std::string type)     
     {
                bool ok=false;