Program: bbtk
Module: $RCSfile: bbtkPackage.cxx,v $
Language: C++
- Date: $Date: 2009/05/28 08:12:06 $
- Version: $Revision: 1.26 $
+ Date: $Date: 2009/05/28 08:26:59 $
+ Version: $Revision: 1.27 $
=========================================================================*/
/* ---------------------------------------------------------------------
//==========================================================================
- 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;
- }
- // 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())
+ void PackageReleaseBlackBoxDescriptorInternal(Package::WeakPointer pack,
+ const std::string& descname)
{
- bbtkDebugMessage("package",2,
- " ... and caused its package death"
- <<bbtkendl);
- return;
+ // 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;
+ }
+ // 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
}
- desc = pack.lock()->GetBlackBoxMap().find(descname);
- if (desc != pack.lock()->GetBlackBoxMap().end())
- pack.lock()->GetBlackBoxMap().erase(desc);
- }
- else
- {
- bbtkDebugMessage("package",5," ... Descriptor still alive ("
- <<pdesc.use_count()<<" refs)"
- <<bbtkendl);
- pack.lock()->GetBlackBoxMap()[descname] = pdesc.lock();
- }
- }
//==========================================================================
break;
}
- PackageReleaseBlackBoxDescriptorInternal(pack,*descname);
-
+#if defined(MACOSX)
+ if (dyn==0) PackageReleaseBlackBoxDescriptorInternal(pack,*descname);
+#else
+ PackageReleaseBlackBoxDescriptorInternal(pack,*descname);
+#endif
+
}
//
// 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
// 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,
// 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
Program: bbtk
Module: $RCSfile: bbtkPackage.h,v $
Language: C++
- Date: $Date: 2009/05/19 10:19:23 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2009/05/28 08:26:59 $
+ Version: $Revision: 1.14 $
=========================================================================*/
/* ---------------------------------------------------------------------
bbtk::Package::Pointer \
BBTK_CDECL NAME ## GetPackage() \
{ \
- if (!NAME ## GetPackagePointer()) \
- NAME ## GetPackagePointer() = \
- bbtk::Package::New(#NAME, \
+ if (!NAME ## GetPackagePointer()) { \
+ NAME ## GetPackagePointer() = \
+ bbtk::Package::New(#NAME, \
AUTHOR, \
DESCRIPTION, \
VERSION \
); \
- bbtk::Object::InsertInPackageList( NAME ## GetPackagePointer() ); \
+ bbtk::Object::InsertInPackageList( NAME ## GetPackagePointer() ); \
+ } \
return NAME ## GetPackagePointer(); \
} \
BBTK_PACKAGE_EXPORT const std::string& \