CMS 3D CMS Logo

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

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