-/*=========================================================================
-
+/*
+ # ---------------------------------------------------------------------
+ #
+ # 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: 2008/05/06 13:45:12 $
- Version: $Revision: 1.17 $
-
- Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
- l'Image). All rights reserved. See doc/license.txt or
- http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
-
- This software is distributed WITHOUT ANY WARRANTY; without even
- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the above copyright notices for more information.
-
+ Date: $Date: 2012/11/16 08:49:01 $
+ Version: $Revision: 1.37 $
=========================================================================*/
+
+
+
/**
*\file
*\brief Class bbtk::Package : registers black boxes descriptors and is able to create instances of the black boxes registered.
*/
#include "bbtkPackage.h"
+#include "bbtkComplexBlackBoxDescriptor.h"
#include "bbtkMessageManager.h"
#include "bbtkConfigurationFile.h"
#include <fstream>
Package::Pointer Package::New(const std::string& name,
const std::string& author,
const std::string& description,
- const std::string& version,
- const std::string& BBTKVersion)
+ const std::string& version)
{
bbtkDebugMessage("object",1,"##> Package::New('"<<name<<"',...)"
<<bbtkendl);
Package::Pointer p = MakePointer(new Package(name,
author,
description,
- version,
- BBTKVersion));
+ version));
bbtkDebugMessage("object",2,"<## Package::New('"<<name<<"',...)"
<<bbtkendl);
return p;
Package::Package(const std::string& name,
const std::string& author,
const std::string& description,
- const std::string& version,
- const std::string& BBTKVersion)
+ const std::string& version)
:
mDynamicLibraryHandler(0),
mName(name),
mDescription(description),
mVersion(version)
{
- bbtkDebugMessage("object",2,"==> Package::Package('"<<name<<"',...)"
+
+ 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;
/// Dtor
Package::~Package()
{
- bbtkDebugMessage("object",2,"==> Package::~Package(\""<<mName<<"\")"<<bbtkendl);
- bbtkDebugMessage("object",2,"<== Package::~Package(\""<<mName<<"\")"<<bbtkendl);
+ bbtkDebugMessage("object",2,"==> ~Package(\""<<mName<<"\")"<<bbtkendl);
}
//==========================================================================
const std::string& descname)
{
// Try to release descriptor
- bbtkDebugMessage("package",3,"--- Trying to release descriptor '"
- <<descname<<"'"<<bbtkendl);
std::string packname = pack.lock()->GetName();
-
- Package::BlackBoxMapType::iterator desc =
- pack.lock()->GetBlackBoxMap().find(descname);
- if (desc == pack.lock()->GetBlackBoxMap().end())
+
+ 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",3,
+ bbtkDebugMessage("package",5,
" Descriptor has already been released"
- <<bbtkendl);
+ <<bbtkendl);
return;
- }
+ }
// bbtkDebugMessage("package",3,
// " Trying unreferencing it ... "<<std::endl);
BlackBoxDescriptor::WeakPointer pdesc = desc->second;
// if it is dead : remove it
if (pdesc.expired())
{
- bbtkDebugMessage("package",2," '"<<packname<<"::"<<descname<<"' Descriptor expired"<<bbtkendl);
+ bbtkDebugMessage("package",2," ==> '"<<packname<<"::"<<descname<<"' Descriptor expired"<<bbtkendl);
if (pack.expired())
{
bbtkDebugMessage("package",2,
- " ... and caused its package death"
+ " ... and caused its package death"
<<bbtkendl);
return;
- }
- desc = pack.lock()->GetBlackBoxMap().find(descname);
- if (desc != pack.lock()->GetBlackBoxMap().end())
- pack.lock()->GetBlackBoxMap().erase(desc);
- }
- else
- {
- bbtkDebugMessage("package",3," ... Descriptor still alive ("
- <<pdesc.use_count()<<" refs)"
- <<bbtkendl);
- pack.lock()->GetBlackBoxMap()[descname] = pdesc.lock();
- }
+ } // 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
}
//==========================================================================
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",2," "<<nrefs<<" refs / "
+ bbtkDebugMessage("package",5," "<<nrefs<<" refs / "
<<ndesc<<" descr / dyn="
<<dyn<<std::endl);
// and descallocated (reset) by PACKAGENAMEDeletePackage())
if (nrefs == ndesc + dyn)
{
- bbtkDebugMessage("package",2,
+ bbtkDebugMessage("package",5,
" -> No more external ref : checking descriptors"
<<bbtkendl);
// We must take care that removing refs on descriptors
// 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);
// Is package still alive ?
if (pack.expired())
{
- bbtkDebugMessage("package",2,"--- Package::Release('"<<
+ bbtkDebugMessage("package",1,"--- Package::Release('"<<
packname
<<"') : package expired during release : bailing out"<<bbtkendl);
break;
}
-
- PackageReleaseBlackBoxDescriptorInternal(pack,*descname);
-
+
+#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();
-
-
-
}
- bbtkDebugMessage("package",1,"<== Package::Release('"<<
+#ifdef BBTK_COMPILE_DEBUG_MESSAGES
+
+ bbtkDebugMessage("package",2,"<== Package::Release('"<<
packname<<"')"<<bbtkendl);
+
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 ("
}
else
{
- bbtkDebugMessage("package",1," ... Package has been released"
+ bbtkDebugMessage("package",1," ... Package has been released"
<<std::endl);
}
+#endif
}
//==========================================================================
<<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",3," "<<nrefs<<" refs / "
+ bbtkDebugMessage("package",5," "<<nrefs<<" refs / "
<<ndesc<<" descr / dynamically loaded = "
<<dyn<<std::endl);
// and descallocated (reset) by PACKAGENAMEDeletePackage())
if (nrefs == ndesc + dyn)
{
- PackageReleaseBlackBoxDescriptorInternal(pack,dname);
+#if defined(MACOSX)
+ //
+ if (dyn==0)
+ PackageReleaseBlackBoxDescriptorInternal(pack,dname);
+#else
+ PackageReleaseBlackBoxDescriptorInternal(pack,dname);
+#endif
}
// If the package is released and dynamically loaded
// then put it in the static list mReleasedDynamicallyLoadedPackages
UnLoadDynamicLibrary(pack,false);
- bbtkDebugMessage("package",3,"<== Package::ReleaseBlackBoxDescriptor('"<<
+ bbtkDebugMessage("package",4,"<== Package::ReleaseBlackBoxDescriptor('"<<
packname<<"','"<<dname<<"'): refs="
<<descr.use_count()<<bbtkendl);
/*
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 ("
/// 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);
// Open shared lib
void *handler;
- handler = dlopen(libname.c_str(),
- BBTK_RTLD_TIME | BBTK_RTLD_SCOPE );
+ handler = dlopen(libname.c_str(), BBTK_RTLD_TIME | BBTK_RTLD_SCOPE );
+//EED handler = dlopen(libname.c_str(), RTLD_LAZY | RTLD_LOCAL );
+
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();
+ bbtkMessage("package",2,
+ "Windows Error: [" << dwErrorCode <<"]"
+ << 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)(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;
p->SetDocURL(doc);
p->SetDocRelativeURL(reldoc);
- bbtkDebugMessage("package",1,"<== Package::CreateFromDynamicLibrary("
+ bbtkDebugMessage("package",2,"<== Package::CreateFromDynamicLibrary("
<<libname<<") .. OK"<<std::endl);
return p;
}
{
if (pack.expired() || (!pack.lock()->mDynamicLibraryHandler))
return;
-
-
+
std::string packname = pack.lock()->GetName();
- bbtkDebugMessage("package",3,"==> Package::UnLoadDynamicLibrary('"
+ bbtkDebugMessage("package",5,"==> Package::UnLoadDynamicLibrary('"
<<packname<<"')"
<<std::endl);
-
- if (!pack.lock()->GetBlackBoxMap().empty())
+
+ if (!pack.lock()->GetDescriptorMap().empty())
{
-
- bbtkDebugMessage("package",3," Package not empty ... abort"
+
+ 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)
if (doit)
{
UnLoad(pack);
- bbtkDebugMessage("package",3," ... dynamic library closed"
+ bbtkDebugMessage("package",5,"==> dynamic library for package '"
+ <<packname<<"' closed"
<<std::endl);
}
else
{
mReleasedDynamicallyLoadedPackages.insert(pack);
- bbtkDebugMessage("package",3,
- " ... package put in the 'to unload' list"
+ bbtkDebugMessage("package",1,"==> package '"<<packname
+ <<"' put in the 'to unload' list"
<<std::endl);
-
}
- bbtkDebugMessage("package",3,"<== Package::UnLoadDynamicLibrary('"
+ bbtkDebugMessage("package",5,"<== Package::UnLoadDynamicLibrary('"
<<packname<<"')"
- <<std::endl);
-
+ <<std::endl);
}
//==========================================================================
/// see UnLoadDynamicLibrary and ReleaseBlackBoxDescriptor
void Package::UnLoadReleasedDynamicallyLoadedPackages()
{
- bbtkDebugMessage("package",2,"==> Package::UnLoadReleasedDynamicallyLoadedPackages()"<<std::endl);
+ bbtkDebugMessage("package",5,"==> Package::UnLoadReleasedDynamicallyLoadedPackages()"<<std::endl);
std::set<Package::WeakPointer>::iterator i;
- for (i=mReleasedDynamicallyLoadedPackages.begin();
- i!=mReleasedDynamicallyLoadedPackages.end();
- ++i)
- {
- if (!i->expired()) UnLoad(*i);
- }
- bbtkDebugMessage("package",2,"<== Package::UnLoadReleasedDynamicallyLoadedPackages()"<<std::endl);
+
+//JCP- 21-04-09
+ if(mReleasedDynamicallyLoadedPackages.size()>0){
+ for (i=mReleasedDynamicallyLoadedPackages.begin();
+ i!=mReleasedDynamicallyLoadedPackages.end();
+ ++i)
+ {
+ if (!i->expired()) UnLoad(*i);
+ }
+ }
+//JCP- 21-04-09
+ bbtkDebugMessage("package",5,"<== Package::UnLoadReleasedDynamicallyLoadedPackages()"<<std::endl);
}
//==========================================================================
void Package::UnLoad(Package::WeakPointer pack)
{
std::string packname = pack.lock()->GetName();
- bbtkDebugMessage("package",2,"==> Package::UnLoad("<<packname<<")"<<std::endl);
+ bbtkDebugMessage("package",6,"==> Package::UnLoad("<<packname<<")"<<std::endl);
Package* p = pack.lock().get();
// closes the dl handler
#if defined(__GNUC__)
- dlclose(h);
+ if (dlclose(h)!=0)
+ {
+ printf("EED Package::UnLoad ERROR %s\n", packname.c_str() );
+ bbtkWarning("Failed to close dynamic library for package '"<<packname
+ <<"'"<<std::endl);
+ }
+
#elif defined(_WIN32)
FreeLibrary(h);
#endif
- bbtkDebugMessage("package",2," ... dynamic library unloaded"<<std::endl);
+ bbtkDebugMessage("package",1,"==> dynamic library for package '"
+ <<packname<<"' closed"
+ <<std::endl);
+ bbtkDebugMessage("package",6," ... dynamic library unloaded"<<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,
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;
}
const DataInfo& typeout,
const std::string& name) const
{
- bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
+ bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<
">::NewAdaptor("
<<typein<<","
<<typeout<<",\""
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;
}
const DataInfo& typeout,
const std::string& name) const
{
- bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
+ bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<
">::NewWidgetAdaptor("
<<typein<<","
<<typeout<<",\""
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;
}
const DataInfo& typeout,
std::string& adaptor) const
{
- bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
+ bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<
">::FindWidgetAdaptor("
<<typein<<","
<<typeout<<")"<<bbtkendl);
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;
}
const DataInfo& typeout,
std::string& adaptor) const
{
- bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
+ bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<
">::FindAdaptor("
<<typein<<","
<<typeout<<")"<<bbtkendl);
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;
}
//==========================================================================
/// 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();
// 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),"");
}
- 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);
//==========================================================================
/// 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 ||
{
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());
// }
}
//==========================================================================
/// 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);
}
}
/*
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);
}
//==========================================================================
//==========================================================================
/// 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;
}
//==========================================================================
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;
<< 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";
- 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 << " <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 << " <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";
+//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 << "</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();
-
- 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=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
//----------------------
// End
- bbtkDebugDecTab("Kernel",9);
+ bbtkDebugDecTab("kernel",9);
}
//==========================================================================
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;
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;
//==========================================================================
+
}