Program: bbtk
Module: $RCSfile: bbtkPackage.cxx,v $
Language: C++
- Date: $Date: 2009/05/28 14:22:10 $
- Version: $Revision: 1.29 $
+ Date: $Date: 2009/06/08 14:50:04 $
+ Version: $Revision: 1.30 $
=========================================================================*/
/* ---------------------------------------------------------------------
//==========================================================================
- 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"
+ 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;
+ 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,
+ // 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
- }
+ <<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
+ }
//==========================================================================
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 / "
// 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);
}
#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
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 ("
<<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 / "
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 ("
<<packname<<"')"
<<std::endl);
- if (!pack.lock()->GetBlackBoxMap().empty())
+ if (!pack.lock()->GetDescriptorMap().empty())
{
bbtkDebugMessage("package",5," Package not empty ... abort"
return;
/*
bbtkGlobalError("Package::UnLoadDynamicLibrary('"<<packname<<") : "
- <<"BlackBoxMap not empty "
+ <<"DescriptorMap not empty "
<<BBTK_INTERNAL_ERROR_MESSAGE);
*/
{
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);
return BlackBox::Pointer();
//==========================================================================
/// 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),"");
//==========================================================================
//===================================================================
- 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<<">");
+ 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);
}
//==========================================================================
- /// 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 ||
//==========================================================================
/// 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 )
//==========================================================================
//==========================================================================
- /// 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);
bbtkError("The package <"<<GetName()<<"> does not contains the black box <"<<name<<">");
//==========================================================================
/// 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);
return false;
s << "<p><TABLE cellspacing=0 cellpadding=3>\n";
- BlackBoxMapType::const_iterator i;
- for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i)
+ DescriptorMapType::const_iterator i;
+ for (i=mDescriptorMap.begin(); i!=mDescriptorMap.end(); ++i)
{
if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD)
continue;
s << "<p><b> Adaptors : </b>\n";
s << "<ul>\n";
- // BlackBoxMapType::const_iterator i;
+ // DescriptorMapType::const_iterator i;
s << "<p><TABLE cellspacing=0 cellpadding=3>\n";
- for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end();++i)
+ for (i=mDescriptorMap.begin(); i!=mDescriptorMap.end();++i)
{
if ( i->second->GetKind() == BlackBoxDescriptor::STANDARD)
continue;
dir = filename.substr(0,slash_position);
}
- for (i=mBlackBoxMap.begin();
- i!=mBlackBoxMap.end();
+ for (i=mDescriptorMap.begin();
+ i!=mDescriptorMap.end();
++i)
{
i->second->InsertHtmlHelp(s,detail,level,dir,relative_link);
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();
}