CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DetectorDescription/RegressionTest/interface/DDHtmlFormatter.h

Go to the documentation of this file.
00001 #ifndef DDHtmlFormatter_h
00002 #define DDHtmlFormatter_h
00003 
00004 
00005 #include <iostream>
00006 #include <string>
00007 #include <sstream>
00008 #include <map>
00009 #include <set>
00010 #include <vector>
00011 
00012 #include "DetectorDescription/RegressionTest/interface/DDErrorDetection.h"
00013 
00014 
00015 class DDHtmlFormatter;
00016 
00017 std::ostream & operator<<(std::ostream & o, const DDHtmlFormatter & f);
00018 
00019 class DDHtmlFormatter
00020 {
00021 public:
00022  
00023  typedef std::map<std::string,std::set<std::string> > ns_type;
00024  
00025  explicit DDHtmlFormatter() { }
00026  DDHtmlFormatter(const DDHtmlFormatter & f) : os_(f.os_.str()) { }
00027  
00028  DDHtmlFormatter header(const std::string & text, const std::string & style="../../style.css");
00029  DDHtmlFormatter footer();
00030  
00031  DDHtmlFormatter br() { pre(); os_ << "<br>" << std::endl; return *this; }
00032  DDHtmlFormatter p(const std::string & content) { pre(); os_ << "<p>" << std::endl << content << std::endl << "</p>" << std::endl; return *this; }
00033  
00034  DDHtmlFormatter ul() { pre(); os_ << "<ul>" << std::endl; return *this;}
00035  DDHtmlFormatter li(const std::string & content) { pre(); os_ << "<li>" << content << "</li>" << std::endl; return *this;}
00036  DDHtmlFormatter ulEnd() { pre(); os_ << "</ul>" << std::endl; return *this;}
00037  
00038  DDHtmlFormatter h1(const std::string & content) { pre(); os_ << "<h1>" << content << "</h1>" << std::endl; return *this;}
00039  DDHtmlFormatter h2(const std::string & content) { pre(); os_ << "<h2>" << content << "</h2>" << std::endl; return *this;}
00040  DDHtmlFormatter h3(const std::string & content) { pre(); os_ << "<h3>" << content << "</h3>" << std::endl; return *this;}
00041  
00042  DDHtmlFormatter link(const std::string & url, const std::string & text, const std::string & target="_self");
00043  std::string           lnk(const std::string & url, const std::string & text, const std::string & target="_self");
00044  
00045  DDHtmlFormatter table(int border=0){ pre(); os_ << "<table border=\"" << border << "\">" << std::endl; return *this;}
00046  DDHtmlFormatter tableEnd() { pre(); os_ << "</table>" << std::endl; return *this;}
00047  DDHtmlFormatter tr() { pre(); os_ << " <tr>" << std::endl; return *this;}
00048  DDHtmlFormatter trEnd() { pre(); os_ << " </tr>" << std::endl; return *this;}
00049  DDHtmlFormatter td(const std::string & content) { pre(); os_ << "  <td>" << content << std::endl << "  </td>" << std::endl; return *this;}
00050  
00051  DDHtmlFormatter color(int red, int green, int blue){return *this;};
00052  
00053  void pre() { os_.str(""); }
00054  
00055 // std::string operator<<(std::string o) { o << os_; }
00056   mutable std::stringstream os_;
00057  
00058 };
00059 
00060 
00061 
00062 
00063 
00064 
00068 class DDNsGenerator 
00069 {
00070  
00071 public:
00072  DDNsGenerator(std::ostream & os, 
00073               const std::string & title, 
00074               const std::string & target, 
00075                const ns_type & n, 
00076                const std::string & text="") 
00077  : os_(os), title_(title), text_(text), target_(target), n_(n){ }
00078  
00079  void doit();
00080 
00081 private:
00082 
00083  std::ostream & os_;  
00084  std::string title_, text_, target_; 
00085  const ns_type & n_;
00086 }; 
00087 
00088 class DDFrameGenerator
00089 {
00090 public:
00091   DDFrameGenerator(std::ostream & os,
00092                    const std::string & title,
00093                    const std::string & n1 = "_ns", //frame names
00094                      const std::string & n2 = "_list",
00095                      const std::string & n3 = "_details",
00096                      const std::string & u1 = "ns.html", //url to be displayed in each frame
00097                      const std::string & u2 = "list.html",
00098                      const std::string & u3 = "details.html")
00099    : t_(title), n1_(n1), n2_(n2), n3_(n3), u1_(u1), u2_(u2), u3_(u3), os_(os) { }
00100    
00101   void doit();   
00102 
00103 private:
00104   std::string t_, n1_, n2_, n3_, u1_, u2_, u3_;
00105   std::ostream & os_;
00106 };                                   
00107         
00108 // =============================================================================================================
00109 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00110 
00111 class DDHtmlDetails
00112 {
00113 public:
00114   DDHtmlDetails(const std::string & cat, const std::string & txt);
00115   virtual bool details(std::ostream & os, const DDName &) = 0;  
00116   virtual ns_type & names() = 0;
00117   virtual ~DDHtmlDetails(){};
00118   const std::string & category() { return cat_; }
00119   const std::string & text() {return txt_; }
00120 protected:  
00121   mutable ns_type names_;  
00122   std::string cat_, txt_;
00123   DDHtmlFormatter f_;
00124 };              
00125 
00126 
00127 class DDHtmlLpDetails : public DDHtmlDetails
00128 {
00129 public: 
00130   DDHtmlLpDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
00131   bool details(std::ostream & os, const DDName &);
00132   ns_type & names();
00133   
00134 };
00135 
00136 class DDHtmlMaDetails : public DDHtmlDetails
00137 {
00138 public: 
00139   DDHtmlMaDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
00140   bool details(std::ostream & os, const DDName &);
00141   ns_type & names();
00142   
00143 };
00144 
00145 class DDHtmlSoDetails : public DDHtmlDetails
00146 {
00147 public: 
00148   DDHtmlSoDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
00149   bool details(std::ostream & os, const DDName &);
00150   ns_type & names();
00151   
00152 };
00153 
00154 class DDHtmlRoDetails : public DDHtmlDetails
00155 {
00156 public: 
00157   DDHtmlRoDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
00158   bool details(std::ostream & os, const DDName &);
00159   ns_type & names();
00160   
00161 };
00162 
00163 class DDHtmlSpDetails : public DDHtmlDetails
00164 {
00165 public: 
00166   DDHtmlSpDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
00167   bool details(std::ostream & os, const DDName &);
00168   ns_type & names();
00169   
00170 };
00171 
00172 
00173 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00174 // =============================================================================================================
00175         
00176 void dd_to_html(DDHtmlDetails & det);
00177                                          
00178 void dd_html_frameset(std::ostream & os);
00179 
00180 void dd_html_menu_frameset(std::ostream & os);
00181 
00182 void dd_html_menu(std::ostream & os);
00183 
00184 void dd_html_ro();
00185 
00186 
00187 
00188 #endif