]> Creatis software - bbtk.git/blob - kernel/src/bbtkPackage.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkPackage.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkPackage.cxx,v $
5   Language:  C++
6   Date:      $Date: 2008/04/09 11:16:57 $
7   Version:   $Revision: 1.12 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See doc/license.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18 /**
19  *\file
20  *\brief Class bbtk::Package : registers black boxes descriptors and is able to create instances of the black boxes registered.
21  */
22 #include "bbtkPackage.h"
23 #include "bbtkMessageManager.h"
24 #include "bbtkConfigurationFile.h"
25 #include <fstream>
26 #include <time.h>
27 #include "bbtkUtilities.h"
28
29 namespace bbtk
30 {
31   //==========================================================================
32   /// Ctor with the name of the package
33   Package::Package(const std::string& name,
34                    const std::string& author,
35                    const std::string& description,
36                    const std::string& version,
37                    const std::string& BBTKVersion) 
38     :
39     mName(name),
40     mAuthor(author),
41     mDescription(description),
42     mVersion(version),
43     mBBTKVersion(BBTKVersion)
44   {
45     std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
46     char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1];
47     std::string url = default_doc_dir; 
48     if (c != '/' && c !='\\') url = url + "/";
49     url = url +  "temp_dir/" + name + "/index.html";    
50     
51     SetDocURL(url);
52     SetDocRelativeURL("Relative url not set");
53
54     /*
55     std::string relurl(BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH));
56     relurl += "/packages/"+name+"/bbdoc/index.html";
57     std::string url = ConfigurationFile::GetInstance().Get_url()
58       + relurl; 
59     SetDocURL(url);
60     SetDocRelativeURL(relurl);   
61     */
62
63     //    std::cout  << "   url=["<<url<<"]"<<std::endl;
64     //    std::cout  << "relurl=["<<relurl<<"]"<<std::endl;
65     bbtkDebugMessage("Kernel",7,"Package::Package(\""<<name<<"\")"<<bbtkendl);
66   }
67   //==========================================================================
68
69
70
71   //==========================================================================
72   /// Dtor
73   Package::~Package()
74   {
75     bbtkDebugMessageInc("Kernel",7,"Package::~Package(\""<<mName<<"\")"<<bbtkendl);
76     BlackBoxMapType::const_iterator i;
77     for (i=mBlackBoxMap.begin();
78          i!=mBlackBoxMap.end();
79        ++i) 
80      {
81        i->second->UnReference();
82      } 
83     // Adaptors are also stored in the black box map : hence already deleted
84     /*
85     AdaptorMapType::const_iterator j;
86     for (j=mAdaptorMap.begin();
87          j!=mAdaptorMap.end();
88        ++j) 
89       {
90          delete j->second;
91       }
92     */ 
93     bbtkDebugDecTab("Kernel",7);
94   }
95   //==========================================================================
96
97
98
99   //==========================================================================
100   /// Creates an instance of a black box of type <type> with name <name>
101   BlackBox* Package::NewBlackBox(const std::string& type, 
102                                     const std::string& name) const
103   {
104     bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::NewBlackBox(\""<<type<<"\",\""<<name<<"\")"<<bbtkendl);
105     
106     BlackBoxMapType::const_iterator i = mBlackBoxMap.find(type);
107     if (i == mBlackBoxMap.end())  
108     {
109            bbtkDebugDecTab("Kernel",8);
110            return 0;
111     }
112     BlackBox* bb =i->second->CreateInstance(name);
113     bbtkDebugDecTab("Kernel",8);
114     return bb;   
115
116   }
117   //==========================================================================
118
119
120
121   //==========================================================================
122   /// Creates an instance of an adaptor of input type <typein> and 
123   /// output type <typeout>  with name <name>
124   BlackBox* Package::NewAdaptor(const DataInfo& typein,
125                                 const DataInfo& typeout,
126                                 const std::string& name) const
127   {
128     bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
129                         ">::NewAdaptor("
130                         <<typein<<","
131                         <<typeout<<",\""
132                         <<name<<"\")"<<bbtkendl);
133
134     AdaptorKey key(typein,typeout,
135                    BlackBoxDescriptor::DEFAULT_ADAPTOR);
136     AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
137     if (i == mAdaptorMap.end())  
138       {
139         bbtkDebugDecTab("Kernel",8);
140         return 0;
141       }
142     BlackBox* bb =i->second->CreateInstance(name);
143     bbtkDebugDecTab("Kernel",8);
144     return bb;   
145
146   }
147   //==========================================================================
148
149   //==========================================================================
150   /// Creates an instance of an adaptor of input type <typein> and 
151   /// output type <typeout>  with name <name>
152   BlackBox* Package::NewWidgetAdaptor(const DataInfo& typein,
153                                       const DataInfo& typeout,
154                                       const std::string& name) const
155   {
156     bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
157                         ">::NewWidgetAdaptor("
158                         <<typein<<","
159                         <<typeout<<",\""
160                         <<name<<"\")"<<bbtkendl);
161
162     AdaptorKey key(typein,typeout,
163                    BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR);
164     AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
165     if (i == mAdaptorMap.end())  
166       {
167         bbtkDebugDecTab("Kernel",8);
168         return 0;
169       }
170     BlackBox* bb =i->second->CreateInstance(name);
171     bbtkDebugDecTab("Kernel",8);
172     return bb;   
173
174   }
175   //==========================================================================
176
177
178
179   //==========================================================================
180   /// Returns true is the package contains 
181   /// an adaptor of input type <typein> and 
182   /// output type <typeout>
183   /// If successfull then adaptor contains the black box type name
184   bool Package::FindWidgetAdaptor(const DataInfo& typein,
185                                   const DataInfo& typeout,
186                                   std::string& adaptor) const
187   {
188     bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
189                         ">::FindWidgetAdaptor("
190                         <<typein<<","
191                         <<typeout<<")"<<bbtkendl);
192    
193     AdaptorKey key(typein,typeout,
194                    BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR);
195     // First try to find a single widget adaptor
196     AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
197     if (i == mAdaptorMap.end())  
198       {
199         bbtkDebugDecTab("Kernel",8);
200         return false;
201       }
202     adaptor = i->second->GetTypeName();
203     bbtkDebugDecTab("Kernel",8);
204     return true;   
205
206   }
207   //==========================================================================
208
209
210
211   //==========================================================================
212   /// Returns true is the package contains 
213   /// an adaptor of input type <typein> and 
214   /// output type <typeout>
215   /// If successfull then adaptor contains the black box type name
216   bool Package::FindAdaptor(const DataInfo& typein,
217                             const DataInfo& typeout,
218                             std::string& adaptor) const
219   {
220     bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<
221                         ">::FindAdaptor("
222                         <<typein<<","
223                         <<typeout<<")"<<bbtkendl);
224     
225     AdaptorKey key(typein,typeout,
226                    BlackBoxDescriptor::DEFAULT_ADAPTOR);
227     AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
228     if (i == mAdaptorMap.end())  
229       {
230         bbtkDebugDecTab("Kernel",8);
231         return false;
232       }
233     adaptor = i->second->GetTypeName();
234     bbtkDebugDecTab("Kernel",8);
235     return true;   
236
237   }
238   //==========================================================================
239
240
241   //==========================================================================
242   /// Registers a black box descriptor in the package
243   bool Package::RegisterBlackBox(BlackBoxDescriptor* d) 
244   {
245     bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\")"<<std::endl);
246     
247     BlackBoxMapType::iterator i = mBlackBoxMap.find(d->GetTypeName());
248     if (i!=mBlackBoxMap.end())
249       {
250         bbtkWarning("Package<"<<GetName()<<"> : Trying to register box type <"
251                     <<d->GetTypeName()<<"> which is already in the package");
252         return false;
253       }
254
255     mBlackBoxMap[d->GetTypeName()] = d;
256     d->Reference();
257     d->SetPackage(this);
258     
259     // If it is a default adaptor, also register it in the adaptors map
260     if ( (d->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR) ||
261          (d->GetKind() == BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR) )
262       {
263         bbtkDebugMessage("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\") : The box is an adaptor, inserting it in adaptors map ..."<<std::endl);   
264         TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo();
265         TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
266         DataInfo infoin(typein,d->GetInputDescriptor("In")->GetNature());
267         DataInfo infoout(typeout,d->GetOutputDescriptor("Out")->GetNature());
268         bbtkDebugMessage("Kernel",9,"Adaptor "<<infoin<<" to "<<infoout 
269                          <<" - kind="<<d->GetKind()<<std::endl);  
270
271         AdaptorKey key(infoin,infoout,d->GetKind());
272
273         AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
274         if (i == mAdaptorMap.end())  
275           {
276             mAdaptorMap[key] = d;
277           }
278         // If already an adaptor registered : error
279         else 
280           {
281             if (i->second->GetTypeName() != d->GetTypeName()) 
282               {
283                 bbtkError("Package <"<<GetName()<<
284                           "> : trying to register black box <"
285                           <<d->GetTypeName()
286                           <<"> as default adaptor but there is already a default adaptor registered (<"
287                           <<i->second->GetTypeName()<<">)");
288               }
289           }
290       }
291     
292     bbtkDebugDecTab("Kernel",8);
293    
294     return true;
295   }
296   //==========================================================================
297   
298   //===================================================================
299   void Package::CheckBoxes() const
300   {
301     bbtkMessage("Debug",1,"****** Checking Package "<<(void*)this
302                 <<" ["<<GetName()<<"]"<<std::endl);
303     BlackBoxMapType::const_iterator i;
304     for (i=mBlackBoxMap.begin();
305          i!=mBlackBoxMap.end();
306          ++i) 
307       {
308         i->second->Check(true);
309       }
310     bbtkMessage("Debug",1,"****** Checking Package "<<(void*)this
311                 <<" ["<<GetName()<<"] ... OK"<<std::endl);
312   }
313   //===================================================================
314
315   //==========================================================================
316   /// UnRegisters a black box descriptor from the package
317   void Package::UnRegisterBlackBox(const std::string& name) 
318   {
319     bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::UnRegisterBlackBox(\""<<name<<"\")"<<std::endl);
320     // Looking into the bb map
321     BlackBoxMapType::iterator i = mBlackBoxMap.find(name);
322     if (i == mBlackBoxMap.end())  
323     {
324        bbtkDebugDecTab("Kernel",8);
325        bbtkError("UnRegister : The package <"<<GetName()<<"> does not contains the black box <"<<name<<">");
326      }
327     mBlackBoxMap.erase(i);
328
329     // Is it also in the adaptors map ?
330     /*
331     AdaptorMapType::iterator j = mAdaptorMap.find(name);
332     if (j != mAdaptorMap.end())  
333       {
334          mAdaptorMap.erase(j);
335       }
336     */    
337
338     i->second->UnReference();
339
340     bbtkDebugDecTab("Kernel",8);    
341   }
342   //==========================================================================
343
344   //==========================================================================
345   /// Changes the name of a black box type
346   void Package::ChangeBlackBoxName( const std::string& oldname, const std::string& newname )
347   { 
348     bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::ChangeBlackBoxName(\""<<oldname<<"\",\""<<newname<<"\")"<<std::endl);
349     // Looking into the bb map
350     BlackBoxMapType::iterator i = mBlackBoxMap.find(oldname);
351     if (i == mBlackBoxMap.end())  
352       {
353          bbtkDebugDecTab("Kernel",8);
354          bbtkError("ChangeBlackBoxName : The package <"<<GetName()<<"> does not contains the black box <"<<oldname<<">");
355       }
356
357     i->second->SetTypeName(newname);
358     mBlackBoxMap[newname] = i->second;
359     mBlackBoxMap.erase(i);
360
361     bbtkDebugDecTab("Kernel",8);    
362   }
363   //==========================================================================
364
365   /*
366
367   //==========================================================================
368   /// Registers an adaptor descriptor in the package
369   bool Package::RegisterAdaptor(BlackBoxDescriptor* d) 
370   {
371     bbtkDebugMessage("Kernel",8,"Package<"<<GetName()<<">::RegisterAdaptor(\""<<d->GetTypeName()<<"\")"<<std::endl);
372     
373     TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo();
374     TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
375     AdaptorKey key(typein,typeout);
376     
377     mAdaptorMap[key] = d;
378     return true;
379   }
380   //==========================================================================
381   */
382
383
384   //==========================================================================
385   /// Displays the list of black boxes of the package
386   void Package::PrintBlackBoxes(bool description, bool adaptors) const
387   {
388     unsigned int lmax = 0;
389     std::vector<std::string> names;
390     std::vector<std::string> kinds;
391     std::vector<std::string> descrs;
392
393     BlackBoxMapType::const_iterator i;
394     for (i=mBlackBoxMap.begin();
395          i!=mBlackBoxMap.end();
396          ++i) 
397       {
398         if ( adaptors || 
399              ( i->second->GetKind() == BlackBoxDescriptor::STANDARD) ) 
400           {
401             std::string name("  ");
402             name += i->second->GetTypeName();
403             names.push_back(name);
404
405             std::string kind;
406             if ( i->second->GetKind() == BlackBoxDescriptor::ADAPTOR )
407               {
408                 kind = std::string("[A]");
409               }
410             else if ( i->second->GetKind() == 
411                       BlackBoxDescriptor::DEFAULT_ADAPTOR )
412               {
413                 kind = std::string("[DA]");
414               }
415             kinds.push_back(kind);
416
417             unsigned int l = name.size()+kind.size();
418             if (l>lmax) lmax = l;
419
420             std::string descr;
421             if (description) 
422               {
423                 descr += " : ";
424                 descr += i->second->GetDescription();
425               } 
426             descrs.push_back(descr);
427           }
428       } 
429     
430
431     std::string offs;
432     offs.append(lmax+3,' ');
433     std::vector<std::string>::iterator ni,ci,di;
434     for (ni = names.begin(), ci = kinds.begin(), di = descrs.begin();
435          ni != names.end(); ++ni, ++ci, ++di)
436       {
437         std::string space;
438         space.append(lmax - ni->size() - ci->size(),' ');
439         bbtkMessage("Help",1,*ni << space << *ci );
440         std::string d(*di);
441         unsigned int dmax = 75 - lmax;
442         //      while (d.size() > dmax ) 
443         //  {
444         if (d.size()>dmax) 
445           bbtkMessage("Help",1,d.substr(0,dmax) << "..." << std::endl);
446         else 
447           bbtkMessage("Help",1,d << std::endl);
448         //    d = d.substr(dmax,d.size());
449         //  }
450       }
451
452   }
453   //==========================================================================
454
455   //==========================================================================
456   /// Displays the list of adaptors of the package
457   void Package::PrintAdaptors(bool description) const
458   {
459     BlackBoxMapType::const_iterator i;
460     for (i=mBlackBoxMap.begin();
461          i!=mBlackBoxMap.end();
462          ++i) 
463       {
464         if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD ) 
465           {
466             bbtkMessage("Help",1,
467                         "  "<<i->second->GetTypeName());
468             if ( i->second->GetKind() == 
469                  BlackBoxDescriptor::DEFAULT_ADAPTOR )
470               {
471                 bbtkMessage("Help",1,
472                             " [default]");
473               }  
474             if (description) 
475               {
476                 bbtkMessage("Help",1,
477                             " : "<<i->second->GetDescription());
478
479               } 
480             bbtkMessage("Help",1,std::endl);
481           }
482       } 
483     /*
484     AdaptorMapType::const_iterator i;
485     for (i=mAdaptorMap.begin();
486          i!=mAdaptorMap.end();
487          ++i) 
488       {
489         bbtkMessage("Help",1,
490                     "  "<<i->second->GetTypeName());
491         if (detail_level>0) 
492           {
493             bbtkMessage("Help",1,
494                         " : "<<i->second->GetDescription());
495   
496           } 
497         bbtkMessage("Help",1,std::endl);
498       }
499     */ 
500   }
501   //==========================================================================
502
503   //==========================================================================
504   /// Prints help on a black box
505   void Package::HelpBlackBox(const std::string& name, bool full) const
506   {
507     bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
508                         <<name<<"\")"<<bbtkendl);
509
510     BlackBoxMapType::const_iterator i = mBlackBoxMap.find(name);
511     if (i == mBlackBoxMap.end())  
512       {
513         bbtkDebugDecTab("Kernel",8);
514         bbtkError("The package <"<<GetName()<<"> does not contains the black box <"<<name<<">");
515       }
516     //    bbtkMessage("Help",1,"["<<GetName()<<"] ");
517     i->second->GetHelp(full);
518     bbtkDebugDecTab("Kernel",8);
519
520   }
521   //==========================================================================
522
523
524   //==========================================================================
525   /// Returns true iff the package contains the box of name boxname
526   bool Package::ContainsBlackBox(const std::string& name) const 
527   {
528     bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::HelpBlackBox(\""
529                         <<name<<"\")"<<bbtkendl);
530     
531     BlackBoxMapType::const_iterator i = mBlackBoxMap.find(name);
532     if (i == mBlackBoxMap.end())  
533     {
534       bbtkDebugDecTab("Kernel",8);
535       return false;
536     }
537     bbtkDebugDecTab("Kernel",8);
538     return true;
539   }
540   //==========================================================================
541
542
543  
544   //==========================================================================
545   void Package::CreateHtmlPage(const std::string& filename,
546                                const std::string& caller,
547                                const std::string& source,
548                                const std::string& custom_header,
549                                const std::string& custom_title,
550                                int detail, 
551                                int level,
552                                bool relative_link ) const
553   {
554     bbtkDebugMessageInc("Kernel",9,"Package<"<<GetName()<<">::CreateHtmlPage(\""
555                         <<filename<<"\")"<<bbtkendl);
556
557     //---------------------
558     // Open output file
559     std::ofstream s;
560     s.open(filename.c_str());
561     if (!s.good()) 
562     {
563        bbtkError("Package "<<GetName()<<" : CreateHtmlPage : could not open file '"<<filename<<"'");
564     }
565     
566     //----------------------
567     // Html head
568     std::string title = "BBTK Package "+GetName()+" "+GetVersion(); 
569
570     if (custom_title.length() != 0) title = custom_title;
571
572     s << "<html lang=\"en\">\n";
573     s << "<head>\n";
574     s << "<title>" << title << "</title>\n";
575     s << "<meta http-equiv=\"Content-Type\" content=\"text/html\">\n";
576     s << "<meta name=\"description\" content=\""<<title<<"\">\n";
577     s << "<meta name=\"generator\" content=\"\">\n";
578     s << "<link title=\"Top\" rel=\"top\" href=\"#Top\">\n";
579     //<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
580     s << "<meta http-equiv=\"Content-Style-Type\" content=\"text/css\"><style type=\"text/css\"><!--\n";
581     s << "pre.display { font-family:inherit }\n";
582     s << "pre.format  { font-family:inherit }\n";
583     s << "pre.smalldisplay { font-family:inherit; font-size:smaller }\n";
584     s << "pre.smallformat  { font-family:inherit; font-size:smaller }\n";
585     s << "pre.smallexample { font-size:smaller }\n";
586     s << "pre.smalllisp    { font-size:smaller }\n";
587     s << "span.sc    { font-variant:small-caps }\n";
588     s << "span.roman { font-family:serif; font-weight:normal; } \n";
589     s << "span.sansserif { font-family:sans-serif; font-weight:normal; }\n"; 
590     s << "--></style>\n";
591     s << "</head>\n";
592     //----------------------
593
594     //----------------------
595     // Html body
596     s << "<body>\n";
597     s << "<a name=\"Top\"></a>\n"; 
598     
599     //----------------------
600     // Header
601     if ( custom_header.length() != 0) 
602       {
603         if ( custom_header != "none" )
604           { 
605             std::ifstream in;
606             in.open(custom_header.c_str());    
607             if (!in.good()) 
608               {
609                 bbtkError("Could not open file \""<<custom_header<<"\"");
610               }
611             char buffer[512];
612             while (!in.eof()) 
613               {
614                 in.getline(buffer,512);
615                 std::string line(buffer);
616                 s << line;
617               }
618             in.close();
619             s << "<hr>\n";
620            
621             /*   
622             s << "<object data=\"" << custom_header 
623               << "\" type = \"text/html\"\"style=\"width: 1200px; height: 400px;\"> Warning: "
624               << custom_header <<" could not be embedded.</object>\n";
625             
626             s << "<hr>\n";
627             */
628           }
629       }
630
631     else 
632       {
633         s << "<h1 class=\"settitle\">"<<title<<"</h1>\n";
634         s << "<p><TABLE cellspacing=0  cellpadding=3>\n";
635         s << "<TR><TD style='vertical-align: top;'><b> Description </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> " 
636           << GetDescription() << "</TD></TR>\n";
637         s << "<TR><TD style='vertical-align: top;'><b> Author(s) </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'>  " 
638           << GetAuthor() << "</TD></TR>\n";
639         s << "<TR><TD style='vertical-align: top;'><b> Author(s) </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'>  " 
640           << GetCategory() << "</TD></TR>\n";
641         s << "<TR><TD style='vertical-align: top;'><b> Version </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> " 
642           << GetVersion() << "</TD></TR>\n";
643         s << "<TR><TD style='vertical-align: top;'><b> bbtk Version </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> " 
644           << GetBBTKVersion() << "</TD></TR>\n";
645         s << "</TABLE>\n";
646       }
647
648     //-------------------
649     // Table of contents
650     // Black boxes list
651     //  s << "<div class=\"contents\">\n";
652     s << "<p><b> Black Boxes : </b>\n";
653     s << "<ul>\n";
654
655     s << "<p><TABLE cellspacing=0  cellpadding=3>\n";
656
657     BlackBoxMapType::const_iterator i;
658     for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i) 
659       {
660         if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD) 
661           continue;
662         
663         std::string name = i->second->GetTypeName();
664         Utilities::html_format(name);
665         std::string descr = i->second->GetDescription();
666         Utilities::html_format(descr);
667
668         s << "<TR>";
669         s << "<TD style='vertical-align: top;'>";
670         s << "&nbsp;&nbsp;&nbsp;<a name=\"toc_"<<name
671           <<"\" href=\"#"<<name<<"\">"
672           <<name<<"</a>";
673         s << "</TD> ";
674         s << " <TD style='vertical-align: top;'>" << descr << " </TD>";
675         s << "</TR>\n";
676       }    
677     s << "</TABLE>\n";
678     
679     
680     s << "</ul>\n";
681     s << "</div>\n";
682     
683     //-------------------
684     // Adaptors list
685     if (mAdaptorMap.size()>0) 
686       {
687         //  s << "<div class=\"contents\">\n";
688         s << "<p><b> Adaptors : </b>\n";
689         s << "<ul>\n";
690
691         //    BlackBoxMapType::const_iterator i;
692         s << "<p><TABLE cellspacing=0  cellpadding=3>\n";
693         for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end();++i) 
694           {
695             if ( i->second->GetKind() == BlackBoxDescriptor::STANDARD) 
696               continue;
697     
698             std::string name = i->second->GetTypeName();
699             Utilities::html_format(name);
700             std::string descr = i->second->GetDescription();
701     
702             s << "<TR>";
703             s << "<TD style='vertical-align: top;'>";
704             s << "&nbsp;&nbsp;&nbsp;<a name=\"toc_"<<name
705               <<"\" href=\"#"<<name<<"\">"
706               <<name<<"</a>";
707             s << "</TD> ";
708             s << " <TD style='vertical-align: top;'>" << descr << " </TD>";
709             s << "</TR>\n";
710           }    
711         s << "</TABLE>\n";
712
713         s << "</ul>\n";
714         s << "</div>\n";
715       }
716     
717     
718     //  s << "<div class=\"node\">\n";
719
720     //    s << "<p><hr>\n";
721     //    s << "<a name=\"Top\"></a>\n";
722     //  s << "Top:&nbsp;<a rel=\"top\" accesskey=\"t\" href=\"#Top\">Top</a>\n";
723     // s << "Previous:&nbsp;<a rel="previous" accesskey="p" href="#dir">(dir)</a>,
724     // s << "Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
725     
726     //    s << "</div>\n";
727
728     //----------------------
729     // Boxes doc
730
731     //-------------------
732     // Computes output directory from filename to pass it to 
733     // BlackBoxDescriptor::InsertHtmlHelp
734     std::string dir;
735
736     std::string::size_type slash_position = filename.find_last_of("/\\");
737
738
739         if (slash_position != std::string::npos) {
740       if (slash_position == 0)
741          slash_position = 1;  
742       dir = filename.substr(0,slash_position);
743     }
744
745     for (i=mBlackBoxMap.begin();
746          i!=mBlackBoxMap.end();
747          ++i) 
748       {
749         i->second->InsertHtmlHelp(s,detail,level,dir,relative_link);
750       }    
751
752     //----------------------
753     // Footer 
754     time_t rawtime;
755     tm * ptm;
756     time ( &rawtime );
757     ptm = gmtime ( &rawtime );
758
759     s << "<p><hr>\n";
760     s << "Automatically generated by <b>"<<caller<<"</b> "//from <b>"
761       //      <<source<<"</b>
762       <<"on "
763       << ptm->tm_mday << "/" << ptm->tm_mon << "/" << ptm->tm_year+1900 
764       << " - " << ptm->tm_hour << ":" << ptm->tm_min << " GMT\n";
765     s << "</body></html>\n"; 
766     s.close();
767     //----------------------
768
769     // End
770     bbtkDebugDecTab("Kernel",9);
771   }
772   //==========================================================================
773 }
774