1 /*=========================================================================
3 Module: $RCSfile: bbtkFactory.cxx,v $
5 Date: $Date: 2008/10/17 08:18:13 $
6 Version: $Revision: 1.40 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 *\brief Class bbtk::Factory : can load and unload dynamic libraries containing
34 * black boxes packages and create instances of the black boxes registered
35 * in the packages loaded.
37 #include "bbtkFactory.h"
38 #include "bbtkMessageManager.h"
39 #include "bbtkConnection.h"
40 #include "bbtkConfigurationFile.h"
41 #include "bbtkUtilities.h"
43 #include <sys/stat.h> // for struct stat stFileInfo
46 #include <direct.h> // for getcwd
49 #include <cctype> // std::toupper
56 //===================================================================
58 Factory::Pointer Factory::New()
60 bbtkDebugMessage("Kernel",9,"Factory::New()"<<std::endl);
61 return MakePointer(new Factory());
63 //===================================================================
65 //===================================================================
70 bbtkDebugMessage("Kernel",7,"Factory::Factory()"<<std::endl);
72 //===================================================================
74 //===================================================================
78 bbtkDebugMessageInc("Kernel",7,"Factory::~Factory()"<<std::endl);
80 bbtkDebugDecTab("Kernel",7);
82 //===================================================================
86 //===================================================================
89 bbtkDebugMessageInc("Kernel",7,"Factory::Reset()"<<std::endl);
91 bbtkDebugDecTab("Kernel",7);
93 //===================================================================
96 // ===================================================================
97 bool Factory::DoLoadPackage(std::string libname,
102 Package::Pointer p = Package::CreateFromDynamicLibrary(libname,
107 //===================================================================
108 bbtkMessage("Output",2,p->GetName()<<" "
111 <<p->GetAuthor() << " Category(s) :"
114 bbtkMessage("Output",2,p->GetDescription()<<std::endl);
115 //===================================================================
116 p->AddFactory(GetThisPointer<Factory>());
117 mPackageMap[pkgname] = p;
124 //===================================================================
125 /// \brief Loads a package.
127 /// The name is the system-independant name of the package (the name of the instance of bbtk::Package).
128 /// Tries to open the dynamic library :
129 /// - "libbb<name>.so" for linux systems,
130 /// - "bb<name>.dll" for windows systems.
131 /// If it succeeds, then tries to load the symbols "<name>GetPackage" and "<name>DeletePackage".
132 /// "<name>GetPackage" is called to get the pointer on the bbtk::Package of the library
133 /// ("<name>DeletePackage" is not used, its presence is just checked before loading the package).
135 /// now, filename is only the last name (no longer the full name!)
136 /// it will be searched within *all* the paths given in bbtk_config.xml
140 void Factory::LoadPackage( const std::string& name )
142 // Note : in the following :
143 // name : the user supplied name
144 // - abreviated name e.g. pkg pkg.so libbpkg libbbpkg.so
145 // - relative full name e.g. ./libbbpkg.so ../../libbbpkg.so
146 // - absolute full name e.g. /home/usrname/proj/lib/libbbpkg.so
147 // same for Windows, with c:, d: ...
149 // lastname : string before the last / (if any), or user supplied name
151 bbtkDebugMessageInc("Kernel",7,"Factory::LoadPackage(\""<<name<<"\")"<<std::endl);
152 bbtkMessage("debug",1,"Factory::LoadPackage(\""<<name<<"\")"<<std::endl);
154 std::vector<std::string> package_paths;
155 std::string libname; // full path library name
156 std::string pkgname; // e.g. libbb<pkgname>.so
159 pkgname = Utilities::ExtractPackageName(name,upath);
161 bbtkMessage("debug",1,"Package name ["<<pkgname<<"]"<<std::endl);
162 bbtkMessage("debug",1,"Package path ["<<upath<<"]"<<std::endl);
164 // no loading package if already loaded
165 PackageMapType::iterator iUnload;
166 iUnload = mPackageMap.find(pkgname);
167 if (iUnload != mPackageMap.end())
169 bbtkMessage("Output",2,"["<< pkgname <<"] already loaded" << std::endl);
173 // =================================================
174 // The following structure was checked to work
175 // with any type of relative/absolute path.
176 // Please don't modify it without checking
177 // *all* the cases. JP
178 //==================================================
180 //std::cout << "upath [" << upath << "]" << std::endl;
183 bool foundFile = false;
185 // If path provided by user will be the first scanned :
186 // push it into vector of paths
187 if (upath.length()>0) // ------------------------------------- check user supplied location
189 if (name[0] != '.' && name[0] != '/' && name[1]!= ':')
191 bbtkError("Use absolute or relative path name! ["<<name<<"] is an illegal name");
195 // std::string path = Utilities::ExpandLibName(upath, false);
196 std::string path = Utilities::ExpandLibName(name,false); // keep last item, here.
201 Utilities::ExtractPackageName(path,p2);
202 //libname = Utilities::MakeLibnameFromPath(path, pkgname);
203 libname = Utilities::MakeLibnameFromPath(p2, pkgname); // remove last item
204 // Check if library exists
205 if ( !Utilities::FileExists(libname) )
207 // The following is *NOT* a debug time message :
208 // It's a user intended message.
209 // Please don't remove it.
210 bbtkMessage("Output",3," [" <<libname
211 <<"] : doesn't exist" <<std::endl);
215 ok = DoLoadPackage( libname, pkgname, path);
220 bbtkError("Path ["<<upath<<"] doesn't exist");
224 else // ----------------------------------------------------- iterate on the paths
228 package_paths = ConfigurationFile::GetInstance().Get_package_paths();
229 std::vector<std::string>::iterator i;
230 for (i=package_paths.begin();i!=package_paths.end();++i)
235 // we *really* want '.' to be the current working directory
238 char buf[2048]; // for getcwd
239 char * currentDir = getcwd(buf, 2048);
240 std::string cwd(currentDir);
244 libname = Utilities::MakeLibnameFromPath(path, pkgname);
246 bbtkMessage("debug",2,"-> Trying to load [" << libname << "]" <<std::endl);
248 // Check if library exists
249 if ( !Utilities::FileExists(libname) )
251 // The following is *NOT* a debug time message :
252 // It's a user intended message.
253 // Please don't remove it.
254 bbtkMessage("Output",3,
255 " [" <<libname <<"] : doesn't exist" <<std::endl);
256 continue; // try next path
260 // Try to Load the library
262 ok = DoLoadPackage( libname, pkgname, path);
265 bbtkMessage("debug",2," OK"<<std::endl);
267 break; // we stop iterating even if error : have to signal it to user
268 } //------------------ // end for ( package_paths.begin();i!=package_paths.end() )
272 if( !ok ) // nothing was loaded
276 bbtkError("Could not find package ["<<pkgname<< "]");
280 #if defined(__GNUC__)
281 bbtkError("Could not load package ["<< pkgname
283 << " Opening "<<libname<<" failed"
284 << " Reason: "<< dlerror());
285 #elif defined(_WIN32)
286 bbtkError("Could not load package ["<<pkgname
287 <<"] :"<< std::endl << " Error loading " <<libname);
289 // look how to get the error message on win
291 // it is the bordel !! (the bloody fucking bordel, you mean?)
292 // look : http://msdn2.microsoft.com/en-us/library/ms680582.aspx
296 bbtkMessage("Output",2,"[" << libname << "] loaded" << std::endl);
300 //===================================================================
301 /// \brief UnLoads a package.
303 /// The package must have been previously loaded by LoadPackage.
304 /// If the entry is found in the map, calls ClosePackage
305 void Factory::UnLoadPackage( const std::string& name )
307 bbtkDebugMessageInc("Kernel",7,"Factory::UnLoadPackage(\""
308 <<name<<"\")"<<std::endl);
310 PackageMapType::iterator i;
311 i = mPackageMap.find(name);
312 if (i == mPackageMap.end())
314 bbtkError("cannot unload package \""<<name
315 <<"\" : package not loaded !");
318 bbtkDebugDecTab("Kernel",7);
320 //===================================================================
323 //===================================================================
324 void Factory::CloseAllPackages()
326 bbtkDebugMessageInc("Kernel",7,"Factory::CloseAllPackages()"<<std::endl);
327 while (mPackageMap.begin() != mPackageMap.end())
329 PackageMapType::iterator i = mPackageMap.begin();
332 bbtkDebugDecTab("Kernel",7);
334 //===================================================================
336 //===================================================================
337 /// \brief Close the package referenced by the iterator
339 /// First removes the factory from the set of factories which use the package
340 /// If the set is empty then :
341 /// If it is a dynamically loaded package :
342 /// - Loads and calls the function "<name>DeletePackage" of the dynamic library (responsible for package desallocation)
343 /// - Closes the dynamic library
345 /// - deletes the package normally
347 /// Finally erases the package entry in the packages map
348 void Factory::ClosePackage(PackageMapType::iterator& i)
350 bbtkDebugMessageInc("Kernel",7,"Factory::ClosePackage(\""
351 <<i->second->GetName()
355 // Removes this from the set of factories which use the package
356 i->second->RemoveFactory(GetThisPointer<Factory>());
357 Package::WeakPointer p = i->second;
358 // remove the entry in the map
359 mPackageMap.erase(i);
360 // Release the package if not already destroyed
361 if (p.lock()) Package::Release(p);
364 bbtkDebugDecTab("Kernel",7);
366 //===================================================================
370 //===================================================================
371 /// Displays the list of packages loaded
372 void Factory::PrintPackages(bool details, bool adaptors) const
374 bbtkDebugMessageInc("Kernel",9,"Factory::PrintPackages"<<std::endl);
376 PackageMapType::const_iterator i;
377 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
379 bbtkMessage("Help",1, i->first << std::endl);
381 i->second->PrintBlackBoxes(false,adaptors);
385 bbtkDebugDecTab("Kernel",9);
387 //===================================================================
389 //===================================================================
390 /// Displays help on a package
391 void Factory::HelpPackage(const std::string& name, bool adaptors) const
393 bbtkDebugMessageInc("Kernel",9,"Factory::HelpPackage(\""<<name<<"\")"
396 PackageMapType::const_iterator i = mPackageMap.find(name);
397 if ( i != mPackageMap.end() )
399 bbtkMessage("Help",1, "Package "<<i->first<<" ");
401 if (i->second->GetVersion().length()>0)
402 bbtkMessageCont("Help",1,"v" <<i->second->GetVersion());
404 if (i->second->GetAuthor().length()>0)
405 bbtkMessageCont("Help",1,"- "<<i->second->GetAuthor());
407 if (i->second->GetCategory().length()>0)
408 bbtkMessageCont("Help",1,"- "<<i->second->GetCategory());
410 bbtkMessageCont("Help",1,std::endl);
411 bbtkIncTab("Help",1);
412 bbtkMessage("Help",1,i->second->GetDescription()<<std::endl);
413 if (i->second->GetNumberOfBlackBoxes()>0)
415 bbtkMessage("Help",1, "Black boxes : "<<std::endl);
416 i->second->PrintBlackBoxes(true,adaptors);
420 bbtkMessage("Help",1, "No black boxes"<<std::endl);
422 bbtkDecTab("Help",1);
426 bbtkDebugDecTab("Kernel",9);
427 bbtkError("package \""<<name<<"\" unknown");
430 bbtkDebugDecTab("Kernel",9);
432 //===================================================================
434 //===================================================================
435 /// Prints help on the black box of type <name>
436 /// Returns the package to which it belongs
437 void Factory::HelpBlackBox(const std::string& name,
438 std::string& package,
441 bbtkDebugMessageInc("Kernel",9,"Factory::HelpBlackBox(\""<<name<<"\")"
445 PackageMapType::const_iterator i;
446 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
448 if (i->second->ContainsBlackBox(name))
450 i->second->HelpBlackBox(name,full);
451 package = i->second->GetName();
456 bbtkDebugDecTab("Kernel",9);
459 bbtkError("No package of the factory contains any black box <"
463 //===================================================================
466 //===================================================================
467 /// Inserts a package in the factory
468 void Factory::InsertPackage( Package::Pointer p )
470 bbtkDebugMessageInc("Kernel",9,"Factory::InsertPackage(\""<<
471 p->GetName()<<"\")"<<std::endl);
473 p->AddFactory(GetThisPointer<Factory>());
474 mPackageMap[p->GetName()] = p;
476 bbtkDebugDecTab("Kernel",9);
478 //===================================================================
480 //===================================================================
481 /// Removes a package from the factory (and deletes it)
482 void Factory::RemovePackage( Package::Pointer p )
484 bbtkDebugMessageInc("Kernel",9,"Factory::RemovePackage(\""<<
485 p->GetName()<<"\")"<<std::endl);
487 PackageMapType::iterator i;
488 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
490 if (i->second == p) break;
493 if (i!=mPackageMap.end())
499 bbtkError("Factory::RemovePackage(\""<<
500 p->GetName()<<"\") : package absent from factory");
503 bbtkDebugDecTab("Kernel",9);
505 //===================================================================
508 //===================================================================
509 /// Creates an instance of a black box of type <type> with name <name>
510 BlackBox::Pointer Factory::NewBlackBox(const std::string& type,
511 const std::string& name) const
513 bbtkDebugMessageInc("Kernel",7,"Factory::NewBlackBox(\""
514 <<type<<"\",\""<<name<<"\")"<<std::endl);
517 PackageMapType::const_iterator i;
518 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
520 b = i->second->NewBlackBox(type,name);
525 bbtkError("black box type \""<<type<<"\" unknown");
528 bbtkDebugDecTab("Kernel",7);
531 //===================================================================
533 //===================================================================
534 /// Creates an instance of a black box of type <type> with name <name>
535 BlackBox::Pointer Factory::NewAdaptor(const DataInfo& typein,
536 const DataInfo& typeout,
537 const std::string& name) const
539 bbtkDebugMessageInc("Kernel",8,"Factory::NewAdaptor("
542 <<name<<"\")"<<bbtkendl);
546 PackageMapType::const_iterator i;
547 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
549 b = i->second->NewAdaptor(typein,typeout,name);
554 bbtkError("no "<<typein<<" to "<<typeout
555 <<" adaptor available");
558 bbtkDebugDecTab("Kernel",7);
561 //===================================================================
564 //===================================================================
565 /// Creates an instance of a black box of type <type> with name <name>
566 BlackBox::Pointer Factory::NewWidgetAdaptor(const DataInfo& typein,
567 const DataInfo& typeout,
568 const std::string& name) const
570 bbtkDebugMessageInc("Kernel",8,"Factory::NewWidgetAdaptor(<"
573 <<name<<"\")"<<bbtkendl);
577 PackageMapType::const_iterator i;
578 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
580 b = i->second->NewWidgetAdaptor(typein,
587 bbtkError("no "<<typein<<" to "<<typeout
588 <<"> widget adaptor available");
591 bbtkDebugDecTab("Kernel",7);
594 //===================================================================
596 //===================================================================
597 /// Creates an instance of a black box of type <type> with name <name>
598 bool Factory::FindAdaptor(const DataInfo& typein,
599 const DataInfo& typeout,
600 std::string& adaptor) const
602 bbtkDebugMessageInc("Kernel",8,"Factory::FindAdaptor(<"
604 <<typeout<<">)"<<bbtkendl);
607 PackageMapType::const_iterator i;
608 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
610 b = i->second->FindAdaptor(typein,
618 bbtkError("no "<<typein<<" to "<<typeout
619 <<"> widget adaptor available");
623 bbtkDebugDecTab("Kernel",7);
626 //===================================================================
628 //===================================================================
629 /// Creates an instance of a black box of type <type> with name <name>
630 bool Factory::FindWidgetAdaptor(const DataInfo& typein,
631 const DataInfo& typeout,
632 std::string& adaptor) const
634 bbtkDebugMessageInc("Kernel",8,"Factory::FindWidgetAdaptor(<"
636 <<typeout<<">)"<<bbtkendl);
639 PackageMapType::const_iterator i;
640 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
642 b = i->second->FindWidgetAdaptor(typein,
647 bbtkDebugDecTab("Kernel",7);
650 //===================================================================
652 //===================================================================
653 /// Creates an instance of a black box of type <type> with name <name>
654 bool Factory::FindWidgetAdaptor2(const DataInfo& typein,
655 const DataInfo& typeout,
657 std::string& adaptor) const
659 bbtkDebugMessageInc("Kernel",8,"Factory::FindWidgetAdaptor(<"
661 <<typeout<<">)"<<bbtkendl);
664 adaptor = widget = "";
665 PackageMapType::const_iterator i;
666 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
668 b = i->second->FindWidgetAdaptor(typein,
675 // Look for a widget adaptor with good nature out
676 bbtkMessage("Kernel",5,
677 "*** Looking for a two pieces widget adaptor for : "
678 << typein << "->"<<typeout<<std::endl);
679 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
681 Package::AdaptorMapType::const_iterator j;
682 for (j=i->second->GetAdaptorMap().begin();
683 j!=i->second->GetAdaptorMap().end();
686 if ( ( j->first.mKind ==
687 BlackBoxDescriptor::DEFAULT_GUI) &&
688 //(j->first.mTypeIn == typein) &&
689 (j->first.mTypeOut.GetNature() == typeout.GetNature() )
692 widget = j->second.lock()->GetTypeName();
693 bbtkMessage("Kernel",5,
694 "===> Found first part : "<<widget
695 << " "<<j->first.mTypeIn<<"->"
696 <<j->first.mTypeOut<<std::endl);
697 DataInfo ti( j->first.mTypeOut.GetType(), "");
698 DataInfo to( typeout.GetType(), "");
699 b = FindAdaptor( ti, to, adaptor );
702 bbtkMessage("Kernel",5,
703 "===> Found second part : "<<adaptor
709 bbtkMessage("Kernel",5,
710 "===> No second part found"<<std::endl);
717 bbtkDebugDecTab("Kernel",7);
720 //===================================================================
722 //===================================================================
723 /// Creates an instance of a connection
724 Connection::Pointer Factory::NewConnection(BlackBox::Pointer from,
725 const std::string& output,
726 BlackBox::Pointer to,
727 const std::string& input) const
729 bbtkDebugMessage("Kernel",7,"Factory::NewConnection(\""
730 <<from->bbGetName()<<"\",\""<<output<<"\",\""
731 <<to->bbGetName()<<"\",\""<<input
734 return Connection::New(from,output,to,input,
735 GetThisPointer<Factory>());
737 //===================================================================
741 //===================================================================
742 Package::Pointer Factory::GetPackage(const std::string& name) const
744 bbtkDebugMessageInc("Kernel",9,"Factory::GetPackage(\""<<name<<"\")"
747 PackageMapType::const_iterator i = mPackageMap.find(name);
748 if ( i != mPackageMap.end() )
750 bbtkDebugDecTab("Kernel",9);
755 bbtkDebugDecTab("Kernel",9);
756 bbtkError("package \""<<name<<"\" unknown");
759 bbtkDebugDecTab("Kernel",9);
761 //===================================================================
764 //===================================================================
765 void Factory::CheckPackages() const
767 bbtkMessage("debug",1,"****** Checking Factory "<<(void*)this
769 PackageMapType::const_iterator i;
770 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
772 i->second->CheckBoxes();
774 bbtkMessage("debug",1,"****** Checking Factory "<<(void*)this
775 <<" ... OK"<<std::endl);
777 //===================================================================
779 //===================================================================
780 void Factory::WriteDotFilePackagesList(FILE *ff)
783 bbtkDebugMessageInc("Kernel",9,"Factory::WriteDotFilePackagesList()"
787 fprintf( ff , "subgraph cluster_FACTORY {\n");
788 fprintf( ff , " label = \"PACKAGES\"%s\n", ";");
789 fprintf( ff , " style=filled%s\n",";");
790 fprintf( ff , " color=lightgrey%s\n",";");
791 fprintf( ff , " rankdir=TB%s\n",";");
794 PackageMapType::const_iterator i;
795 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
797 url=GetPackage(i->first)->GetDocURL();
798 fprintf(ff," %s [shape=ellipse, URL=\"%s\"]%s\n",i->first.c_str(),url.c_str(),";" );
800 fprintf( ff , "}\n\n");
801 bbtkDebugDecTab("Kernel",9);
803 //===================================================================
806 void Factory::ShowGraphTypes(const std::string& name) const
810 PackageMapType::const_iterator i;
811 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
813 if (i->second->ContainsBlackBox(name))
815 std::string separator = ConfigurationFile::GetInstance().Get_file_separator ();
817 // Don't pollute the file store with "temp_dir" directories ...
818 std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
819 std::string directory = "\"" + default_doc_dir + separator + "temp_dir" +separator + "\"";
820 std::string filename2 = default_doc_dir + separator + "temp_dir" + separator + "tmp.html";
823 std::string command("start \"Titre\" /D ");
825 std::string command("gnome-open ");
827 command=command + directory +" tmp.html";
829 ff=fopen(filename2.c_str(),"w");
831 fprintf(ff,"<html><head><title>TMP</title> <script type=\"text/javascript\"> <!--\n");
832 fprintf(ff," window.location=\"%s#%s\";\n" , i->second->GetDocURL().c_str(),name.c_str() );
833 fprintf(ff,"//--></script></head><body></body></html>\n");
836 //fprintf(ff, "<a href=\"%s#%s\">Link</a>\n", i->second->GetDocURL().c_str(),name.c_str() );
838 system( command.c_str() );
843 bbtkDebugDecTab("Kernel",9);
846 bbtkError("No package of the factory contains any black box <"
854 void Factory::CreateHtmlIndex(IndexEntryType type,
855 const std::string& filename)
857 bbtkDebugMessageInc("Kernel",9,"Factory::CreateHtmlIndex(\""
858 <<filename<<"\")"<<bbtkendl);
862 typedef std::map<std::string,
863 std::vector<BlackBoxDescriptor::Pointer> > IndexType;
865 // Builds the index map
866 PackageMapType::const_iterator i;
867 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
869 Package::Pointer pack = i->second;
870 if (pack->GetName()=="user") continue;
871 Package::BlackBoxMapType::const_iterator j;
872 for (j = pack->GetBlackBoxMap().begin();
873 j!= pack->GetBlackBoxMap().end();
878 if ( type==Adaptors )
880 if (j->second->GetKind() == BlackBoxDescriptor::STANDARD )
884 if (j->second->GetKind() != BlackBoxDescriptor::STANDARD )
887 std::vector<std::string> keys;
891 k += pack->GetName();
893 title = "Boxes by package";
895 else if ((type==Initials) || (type==Adaptors))
897 std::string init(" ");
898 init[0] = std::toupper(j->second->GetTypeName()[0]);
899 keys.push_back(init);
900 title = "Alphabetical list";
902 else if (type==Categories)
904 // Split the category string
905 std::string delimiters = ";,";
906 Utilities::SplitString(j->second->GetCategory(),
909 keys.push_back(" NONE");
910 title = "Boxes by category";
914 std::vector<std::string>::const_iterator k;
915 for (k=keys.begin(); k!=keys.end(); ++k )
917 IndexType::iterator p;
919 if (p != index.end())
921 p->second.push_back(j->second);
925 std::vector<BlackBoxDescriptor::Pointer> v;
926 v.push_back(j->second);
934 //---------------------
937 s.open(filename.c_str());
940 bbtkError("Factory::CreateHtmlIndex : could not open file '"
944 //----------------------
946 s << "<html lang=\"en\">\n";
948 s << "<title>"<<title<<"</title>\n";
949 s << "<meta http-equiv=\"Content-Type\" content=\"text/html\">\n";
950 s << "<meta name=\"description\" content=\""<<title<<"\">\n";
951 s << "<meta name=\"generator\" content=\"\">\n";
952 s << "<link title=\"Top\" rel=\"top\" href=\"#Top\">\n";
953 //<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
954 s << "<meta http-equiv=\"Content-Style-Type\" content=\"text/css\"><style type=\"text/css\"><!--\n";
955 s << "pre.display { font-family:inherit }\n";
956 s << "pre.format { font-family:inherit }\n";
957 s << "pre.smalldisplay { font-family:inherit; font-size:smaller }\n";
958 s << "pre.smallformat { font-family:inherit; font-size:smaller }\n";
959 s << "pre.smallexample { font-size:smaller }\n";
960 s << "pre.smalllisp { font-size:smaller }\n";
961 s << "span.sc { font-variant:small-caps }\n";
962 s << "span.roman { font-family:serif; font-weight:normal; } \n";
963 s << "span.sansserif { font-family:sans-serif; font-weight:normal; }\n";
964 s << "--></style>\n";
966 //----------------------
968 //----------------------
971 s << "<a name=\"Top\"></a>\n";
972 s << "<h1 class=\"settitle\">"<<title<<"</h1>\n";
974 IndexType::iterator ii;
975 for (ii=index.begin();ii!=index.end();++ii)
977 s << "<a href=\"#"<<ii->first<<"\">"<<ii->first<<"</a> ";
980 for (ii=index.begin();ii!=index.end();++ii)
983 s << "<p><a href=\"#Top\">Top</a>";
986 s << "<a name=\""<<ii->first<<"\"></a>\n";
987 s << "<p><a href=\""<<ii->first<<"/index.html\">"
988 << ii->first<<"</a>\n";
990 s << " - \n";
992 s << "<a name=\"doxygen\"></a>\n";
993 s << "<a href=..\\doxygen\\" << ii->first << "/main.html>(Doxygen documentation of the source)</a>\n";
997 s << "<a name=\""<<ii->first<<"\"></a>\n";
998 s << "<p><b>"<<ii->first<<"</b>\n";
1002 s << "<p><TABLE cellspacing=0 cellpadding=3>\n";
1004 std::vector<BlackBoxDescriptor::Pointer>::iterator di;
1005 for (di=ii->second.begin();di!=ii->second.end();++di)
1007 std::string pack = (*di)->GetPackage()->GetName();
1008 std::string name = (*di)->GetTypeName();
1009 Utilities::html_format(name);
1010 std::string descr = (*di)->GetDescription();
1011 Utilities::html_format(descr);
1013 s << "<TD style='vertical-align: top;'>";
1014 s << " <a href=\""<<pack
1015 <<"/index.html#"<<name<<"\">"
1016 <<pack<<"::"<<name<<"</a>";
1018 s << " <TD style='vertical-align: top;'>" << descr << " </TD>";
1025 //----------------------
1030 ptm = gmtime ( &rawtime );
1033 s << "Automatically generated by <b>bbtk</b> on "
1034 << ptm->tm_mday << "/" << ptm->tm_mon << "/" << ptm->tm_year+1900
1035 << " - " << ptm->tm_hour << ":" << ptm->tm_min << " GMT\n";
1036 s << "</body></html>\n";
1038 //----------------------
1041 bbtkDebugDecTab("Kernel",9);
1044 //==========================================================================
1045 std::string Factory::GetObjectName() const
1047 return std::string("Factory");
1049 //==========================================================================
1051 //==========================================================================
1052 std::string Factory::GetObjectInfo() const
1054 std::stringstream i;
1057 //==========================================================================
1059 //==========================================================================
1060 size_t Factory::GetObjectSize() const
1062 size_t s = Superclass::GetObjectSize();
1063 s += Factory::GetObjectInternalSize();
1066 //==========================================================================
1067 //==========================================================================
1068 size_t Factory::GetObjectInternalSize() const
1070 size_t s = sizeof(Factory);
1073 //==========================================================================
1074 //==========================================================================
1075 size_t Factory::GetObjectRecursiveSize() const
1077 size_t s = Superclass::GetObjectRecursiveSize();
1078 s += Factory::GetObjectInternalSize();
1080 PackageMapType::const_iterator i;
1081 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
1083 s += i->second->GetObjectRecursiveSize();
1087 //==========================================================================