+/*
+ # ---------------------------------------------------------------------
+ #
+ # 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/06/08 14:50:04 $
- Version: $Revision: 1.30 $
+ 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
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;
{
bbtkDebugMessage("package",5,
" Descriptor has already been released"
- <<bbtkendl);
+ <<bbtkendl);
return;
}
// bbtkDebugMessage("package",3,
if (pack.expired())
{
bbtkDebugMessage("package",2,
- " ... and caused its package death"
+ " ... and caused its package death"
<<bbtkendl);
return;
} // pack.expired
<<"') : package expired during release : bailing out"<<bbtkendl);
break;
}
-
+
#if defined(MACOSX)
BlackBoxDescriptor::Pointer desc = pack.lock()->mDescriptorMap[*descname];
if ( (dyn==0) || (boost::dynamic_pointer_cast<ComplexBlackBoxDescriptor>(desc)) )
+ {
PackageReleaseBlackBoxDescriptorInternal(pack,*descname);
+ }
#else
PackageReleaseBlackBoxDescriptorInternal(pack,*descname);
#endif
UnLoadDynamicLibrary(pack);
// Unload orphan dl packages
Package::UnLoadReleasedDynamicallyLoadedPackages();
-
-
-
}
#ifdef BBTK_COMPILE_DEBUG_MESSAGES
/// 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);
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;
}
// 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);
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;
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);
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);
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();
// 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;
// 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
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;
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;
{
if (pack.expired() || (!pack.lock()->mDynamicLibraryHandler))
return;
-
-
+
std::string packname = pack.lock()->GetName();
bbtkDebugMessage("package",5,"==> Package::UnLoadDynamicLibrary('"
<<packname<<"')"
<<std::endl);
-
+
if (!pack.lock()->GetDescriptorMap().empty())
{
-
+
bbtkDebugMessage("package",5," Package not empty ... abort"
<<std::endl);
return;
<<"DescriptorMap not empty "
<<BBTK_INTERNAL_ERROR_MESSAGE);
*/
-
}
if (pack.use_count()!=1)
bbtkDebugMessage("package",1,"==> package '"<<packname
<<"' put in the 'to unload' list"
<<std::endl);
-
}
bbtkDebugMessage("package",5,"<== Package::UnLoadDynamicLibrary('"
<<packname<<"')"
- <<std::endl);
-
+ <<std::endl);
}
//==========================================================================
}
//==========================================================================
+ 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,
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;
<< 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
s << "<p><TABLE cellspacing=0 cellpadding=3>\n";
DescriptorMapType::const_iterator i;
- for (i=mDescriptorMap.begin(); i!=mDescriptorMap.end(); ++i)
- {
- if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD)
- continue;
+//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 << " <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";
-
- //-------------------
- // Adaptors list
- if (mAdaptorMap.size()>0)
- {
- // s << "<div class=\"contents\">\n";
- s << "<p><b> Adaptors : </b>\n";
- s << "<ul>\n";
-
- // 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;
+ 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 << " <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();
+ //-------------------
+ // 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 << " <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 << " <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";
//-------------------
// 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=mDescriptorMap.begin();
- i!=mDescriptorMap.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
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;
//==========================================================================
+
}