Program: bbtk
Module: $RCSfile: bbtkPackage.cxx,v $
Language: C++
- Date: $Date: 2008/01/22 15:02:00 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/02/18 10:41:02 $
+ Version: $Revision: 1.9 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See doc/license.txt or
mVersion(version),
mBBTKVersion(BBTKVersion)
{
- std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_doc_tmp();
+ 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;
if (c != '/' && c !='\\') url = url + "/";
- url = url + "doc_tmp/" + name + "/index.html";
+ url = url + "temp_dir/" + name + "/index.html";
SetDocURL(url);
SetDocRelativeURL("Relative url not set");
// std::cout << " url=["<<url<<"]"<<std::endl;
// std::cout << "relurl=["<<relurl<<"]"<<std::endl;
- bbtkDebugMessage("Core",7,"Package::Package(\""<<name<<"\")"<<bbtkendl);
+ bbtkDebugMessage("Kernel",7,"Package::Package(\""<<name<<"\")"<<bbtkendl);
}
//==========================================================================
/// Dtor
Package::~Package()
{
- bbtkDebugMessageInc("Core",7,"Package::~Package(\""<<mName<<"\")"<<bbtkendl);
+ bbtkDebugMessageInc("Kernel",7,"Package::~Package(\""<<mName<<"\")"<<bbtkendl);
BlackBoxMapType::const_iterator i;
for (i=mBlackBoxMap.begin();
- i!=mBlackBoxMap.end();
- ++i)
- {
- delete i->second;
- }
+ i!=mBlackBoxMap.end();
+ ++i)
+ {
+ delete i->second;
+ }
// Adaptors are also stored in the black box map : hence already deleted
/*
AdaptorMapType::const_iterator j;
for (j=mAdaptorMap.begin();
- j!=mAdaptorMap.end();
- ++j)
+ j!=mAdaptorMap.end();
+ ++j)
{
- delete j->second;
- }
+ delete j->second;
+ }
*/
- bbtkDebugDecTab("Core",7);
+ bbtkDebugDecTab("Kernel",7);
}
//==========================================================================
BlackBox* Package::NewBlackBox(const std::string& type,
const std::string& name) const
{
- bbtkDebugMessageInc("Core",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())
- {
- bbtkDebugDecTab("Core",8);
- return 0;
- }
+ {
+ bbtkDebugDecTab("Kernel",8);
+ return 0;
+ }
BlackBox* bb =i->second->CreateInstance(name);
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
return bb;
}
TypeInfo typeout,
const std::string& name) const
{
- bbtkDebugMessageInc("Core",8,"Package<"<<GetName()<<
+ bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
">::NewAdaptor(<"
<<TypeName(typein)<<">,<"
<<TypeName(typeout)<<">,\""
AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
if (i == mAdaptorMap.end())
{
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
return 0;
}
BlackBox* bb =i->second->CreateInstance(name);
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
return bb;
}
/// Registers a black box descriptor in the package
bool Package::RegisterBlackBox(BlackBoxDescriptor* d)
{
- bbtkDebugMessageInc("Core",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\")"<<std::endl);
+ bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\")"<<std::endl);
mBlackBoxMap[d->GetTypeName()] = d;
d->SetPackage(this);
// If it is a default adaptor, also register it in the adaptors map
- if ( d->GetCategory() == BlackBoxDescriptor::DEFAULT_ADAPTOR)
+ if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR)
{
TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo();
TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
if (i == mAdaptorMap.end())
{
- bbtkDebugMessage("Core",8,"The box is an adaptor, inserting it in adaptors map ..."<<std::endl);
+ bbtkDebugMessage("Kernel",8,"The box is an adaptor, inserting it in adaptors map ..."<<std::endl);
mAdaptorMap[key] = d;
}
// If already an adaptor registered : error
<<"> as default adaptor but there is already a default adaptor registered (<"
<<i->second->GetTypeName()<<">)");
}
-
-
}
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
return true;
}
/// UnRegisters a black box descriptor from the package
void Package::UnRegisterBlackBox(const std::string& name)
{
- bbtkDebugMessageInc("Core",8,"Package<"<<GetName()<<">::UnRegisterBlackBox(\""<<name<<"\")"<<std::endl);
+ bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::UnRegisterBlackBox(\""<<name<<"\")"<<std::endl);
// Looking into the bb map
BlackBoxMapType::iterator i = mBlackBoxMap.find(name);
if (i == mBlackBoxMap.end())
- {
- bbtkDebugDecTab("Core",8);
- bbtkError("UnRegister : The package <"<<GetName()<<"> does not contains the black box <"<<name<<">");
- }
+ {
+ bbtkDebugDecTab("Kernel",8);
+ bbtkError("UnRegister : The package <"<<GetName()<<"> does not contains the black box <"<<name<<">");
+ }
mBlackBoxMap.erase(i);
// Is it also in the adaptors map ?
/*
AdaptorMapType::iterator j = mAdaptorMap.find(name);
if (j != mAdaptorMap.end())
{
- mAdaptorMap.erase(j);
+ mAdaptorMap.erase(j);
}
*/
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
}
//==========================================================================
/// Changes the name of a black box type
void Package::ChangeBlackBoxName( const std::string& oldname, const std::string& newname )
{
- bbtkDebugMessageInc("Core",8,"Package<"<<GetName()<<">::ChangeBlackBoxName(\""<<oldname<<"\",\""<<newname<<"\")"<<std::endl);
+ bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::ChangeBlackBoxName(\""<<oldname<<"\",\""<<newname<<"\")"<<std::endl);
// Looking into the bb map
BlackBoxMapType::iterator i = mBlackBoxMap.find(oldname);
if (i == mBlackBoxMap.end())
{
- bbtkDebugDecTab("Core",8);
- bbtkError("ChangeBlackBoxName : The package <"<<GetName()<<"> does not contains the black box <"<<oldname<<">");
+ bbtkDebugDecTab("Kernel",8);
+ bbtkError("ChangeBlackBoxName : The package <"<<GetName()<<"> does not contains the black box <"<<oldname<<">");
}
i->second->SetTypeName(newname);
mBlackBoxMap[newname] = i->second;
mBlackBoxMap.erase(i);
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
}
//==========================================================================
/// Registers an adaptor descriptor in the package
bool Package::RegisterAdaptor(BlackBoxDescriptor* d)
{
- bbtkDebugMessage("Core",8,"Package<"<<GetName()<<">::RegisterAdaptor(\""<<d->GetTypeName()<<"\")"<<std::endl);
+ bbtkDebugMessage("Kernel",8,"Package<"<<GetName()<<">::RegisterAdaptor(\""<<d->GetTypeName()<<"\")"<<std::endl);
TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo();
TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
{
unsigned int lmax = 0;
std::vector<std::string> names;
- std::vector<std::string> categs;
+ std::vector<std::string> kinds;
std::vector<std::string> descrs;
BlackBoxMapType::const_iterator i;
++i)
{
if ( adaptors ||
- ( i->second->GetCategory() == BlackBoxDescriptor::STANDARD) )
+ ( i->second->GetKind() == BlackBoxDescriptor::STANDARD) )
{
std::string name(" ");
name += i->second->GetTypeName();
names.push_back(name);
- std::string categ;
- if ( i->second->GetCategory() == BlackBoxDescriptor::ADAPTOR )
+ std::string kind;
+ if ( i->second->GetKind() == BlackBoxDescriptor::ADAPTOR )
{
- categ = std::string("[A]");
+ kind = std::string("[A]");
}
- else if ( i->second->GetCategory() ==
+ else if ( i->second->GetKind() ==
BlackBoxDescriptor::DEFAULT_ADAPTOR )
{
- categ = std::string("[DA]");
+ kind = std::string("[DA]");
}
- categs.push_back(categ);
+ kinds.push_back(kind);
- unsigned int l = name.size()+categ.size();
+ unsigned int l = name.size()+kind.size();
if (l>lmax) lmax = l;
std::string descr;
std::string offs;
offs.append(lmax+3,' ');
std::vector<std::string>::iterator ni,ci,di;
- for (ni = names.begin(), ci = categs.begin(), di = descrs.begin();
+ for (ni = names.begin(), ci = kinds.begin(), di = descrs.begin();
ni != names.end(); ++ni, ++ci, ++di)
{
std::string space;
else
bbtkMessage("Help",1,d << std::endl);
// d = d.substr(dmax,d.size());
- // }
+ // }
}
}
i!=mBlackBoxMap.end();
++i)
{
- if ( i->second->GetCategory() != BlackBoxDescriptor::STANDARD )
+ if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD )
{
bbtkMessage("Help",1,
" "<<i->second->GetTypeName());
- if ( i->second->GetCategory() ==
+ if ( i->second->GetKind() ==
BlackBoxDescriptor::DEFAULT_ADAPTOR )
{
bbtkMessage("Help",1,
{
bbtkMessage("Help",1,
" : "<<i->second->GetDescription());
-
+
}
bbtkMessage("Help",1,std::endl);
}
{
bbtkMessage("Help",1,
" : "<<i->second->GetDescription());
-
+
}
bbtkMessage("Help",1,std::endl);
}
/// Prints help on a black box
void Package::HelpBlackBox(const std::string& name, bool full) const
{
- bbtkDebugMessageInc("Core",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
+ bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
<<name<<"\")"<<bbtkendl);
BlackBoxMapType::const_iterator i = mBlackBoxMap.find(name);
if (i == mBlackBoxMap.end())
{
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
bbtkError("The package <"<<GetName()<<"> does not contains the black box <"<<name<<">");
}
// bbtkMessage("Help",1,"["<<GetName()<<"] ");
i->second->GetHelp(full);
- bbtkDebugDecTab("Core",8);
+ bbtkDebugDecTab("Kernel",8);
}
//==========================================================================
/// Returns true iff the package contains the box of name boxname
bool Package::ContainsBlackBox(const std::string& name) const
{
- bbtkDebugMessageInc("Core",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
+ bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
<<name<<"\")"<<bbtkendl);
BlackBoxMapType::const_iterator i = mBlackBoxMap.find(name);
if (i == mBlackBoxMap.end())
- {
- bbtkDebugDecTab("Core",8);
- return false;
- }
- bbtkDebugDecTab("Core",8);
+ {
+ bbtkDebugDecTab("Kernel",8);
+ return false;
+ }
+ bbtkDebugDecTab("Kernel",8);
return true;
}
//==========================================================================
//==========================================================================
void Package::CreateHtmlPage(const std::string& filename,
const std::string& caller,
- const std::string& source,
+ const std::string& source,
const std::string& custom_header,
const std::string& custom_title,
int detail,
int level,
bool relative_link ) const
{
- bbtkDebugMessageInc("Core",9,"Package<"<<GetName()<<">::CreateHtmlPage(\""
+ bbtkDebugMessageInc("Kernel",9,"Package<"<<GetName()<<">::CreateHtmlPage(\""
<<filename<<"\")"<<bbtkendl);
//---------------------
std::ofstream s;
s.open(filename.c_str());
if (!s.good())
- {
- bbtkError("Package "<<GetName()<<" : CreateHtmlPage : could not open file '"<<filename<<"'");
- }
+ {
+ bbtkError("Package "<<GetName()<<" : CreateHtmlPage : could not open file '"<<filename<<"'");
+ }
//----------------------
// Html head
<< GetDescription() << "</TD></TR>\n";
s << "<TR><TD style='vertical-align: top;'><b> Author(s) </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> "
<< GetAuthor() << "</TD></TR>\n";
- s << "<TR><TD style='vertical-align: top;'><b> Version </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> "
+ s << "<TR><TD style='vertical-align: top;'><b> Author(s) </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> "
+ << GetCategory() << "</TD></TR>\n";
+ s << "<TR><TD style='vertical-align: top;'><b> Version </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> "
<< GetVersion() << "</TD></TR>\n";
s << "<TR><TD style='vertical-align: top;'><b> bbtk Version </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> "
<< GetBBTKVersion() << "</TD></TR>\n";
BlackBoxMapType::const_iterator i;
for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i)
{
- if ( i->second->GetCategory() != BlackBoxDescriptor::STANDARD)
+ 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 << "<li><a name=\"toc_"<<name
+ s << " <a name=\"toc_"<<name
<<"\" href=\"#"<<name<<"\">"
<<name<<"</a>";
s << "</TD> ";
s << "</TABLE>\n";
- s << "</li></ul>\n";
+ s << "</ul>\n";
s << "</div>\n";
//-------------------
// 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->GetCategory() == BlackBoxDescriptor::STANDARD)
+ 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 << "<li><a name=\"toc_"<<name
+ s << " <a name=\"toc_"<<name
<<"\" href=\"#"<<name<<"\">"
<<name<<"</a>";
s << "</TD> ";
s << "</TR>\n";
}
s << "</TABLE>\n";
-
- s << "</li></ul>\n";
+
+ s << "</ul>\n";
s << "</div>\n";
}
// Computes output directory from filename to pass it to
// BlackBoxDescriptor::InsertHtmlHelp
std::string dir;
- std::string::size_type slash_position =
- filename.find_last_of(ConfigurationFile::GetInstance().Get_file_separator ());
- if (slash_position != std::string::npos) {
+
+ std::string::size_type slash_position = filename.find_last_of("/\\");
+
+
+ if (slash_position != std::string::npos) {
if (slash_position == 0)
- slash_position = 1;
+ slash_position = 1;
dir = filename.substr(0,slash_position);
}
ptm = gmtime ( &rawtime );
s << "<p><hr>\n";
- s << "Automatically generated by <b>"<<caller<<"</b> from <b>"
- <<source<<"</b> on "
+ s << "Automatically generated by <b>"<<caller<<"</b> "//from <b>"
+ // <<source<<"</b>
+ <<"on "
<< ptm->tm_mday << "/" << ptm->tm_mon << "/" << ptm->tm_year+1900
<< " - " << ptm->tm_hour << ":" << ptm->tm_min << " GMT\n";
s << "</body></html>\n";
//----------------------
// End
- bbtkDebugDecTab("Core",9);
+ bbtkDebugDecTab("Kernel",9);
}
//==========================================================================
}