Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:55:09

0001 #ifndef DETECTOR_DESCRIPTION_REGRESSION_TEST_DD_HTML_FORMATTER_H
0002 #define DETECTOR_DESCRIPTION_REGRESSION_TEST_DD_HTML_FORMATTER_H
0003 
0004 #include <iostream>
0005 #include <string>
0006 #include <sstream>
0007 #include <map>
0008 #include <set>
0009 #include <vector>
0010 
0011 #include "DetectorDescription/RegressionTest/interface/DDErrorDetection.h"
0012 
0013 class DDHtmlFormatter;
0014 
0015 std::ostream &operator<<(std::ostream &o, const DDHtmlFormatter &f);
0016 
0017 class DDHtmlFormatter {
0018 public:
0019   typedef std::map<std::string, std::set<std::string> > ns_type;
0020 
0021   explicit DDHtmlFormatter() {}
0022   DDHtmlFormatter(const DDHtmlFormatter &f) : os_(f.os_.str()) {}
0023 
0024   DDHtmlFormatter header(const std::string &text, const std::string &style = "../../style.css");
0025   DDHtmlFormatter footer();
0026 
0027   DDHtmlFormatter br() {
0028     pre();
0029     os_ << "<br>" << std::endl;
0030     return *this;
0031   }
0032   DDHtmlFormatter p(const std::string &content) {
0033     pre();
0034     os_ << "<p>" << std::endl << content << std::endl << "</p>" << std::endl;
0035     return *this;
0036   }
0037 
0038   DDHtmlFormatter ul() {
0039     pre();
0040     os_ << "<ul>" << std::endl;
0041     return *this;
0042   }
0043   DDHtmlFormatter li(const std::string &content) {
0044     pre();
0045     os_ << "<li>" << content << "</li>" << std::endl;
0046     return *this;
0047   }
0048   DDHtmlFormatter ulEnd() {
0049     pre();
0050     os_ << "</ul>" << std::endl;
0051     return *this;
0052   }
0053 
0054   DDHtmlFormatter h1(const std::string &content) {
0055     pre();
0056     os_ << "<h1>" << content << "</h1>" << std::endl;
0057     return *this;
0058   }
0059   DDHtmlFormatter h2(const std::string &content) {
0060     pre();
0061     os_ << "<h2>" << content << "</h2>" << std::endl;
0062     return *this;
0063   }
0064   DDHtmlFormatter h3(const std::string &content) {
0065     pre();
0066     os_ << "<h3>" << content << "</h3>" << std::endl;
0067     return *this;
0068   }
0069 
0070   DDHtmlFormatter link(const std::string &url, const std::string &text, const std::string &target = "_self");
0071   std::string lnk(const std::string &url, const std::string &text, const std::string &target = "_self");
0072 
0073   DDHtmlFormatter table(int border = 0) {
0074     pre();
0075     os_ << "<table border=\"" << border << "\">" << std::endl;
0076     return *this;
0077   }
0078   DDHtmlFormatter tableEnd() {
0079     pre();
0080     os_ << "</table>" << std::endl;
0081     return *this;
0082   }
0083   DDHtmlFormatter tr() {
0084     pre();
0085     os_ << " <tr>" << std::endl;
0086     return *this;
0087   }
0088   DDHtmlFormatter trEnd() {
0089     pre();
0090     os_ << " </tr>" << std::endl;
0091     return *this;
0092   }
0093   DDHtmlFormatter td(const std::string &content) {
0094     pre();
0095     os_ << "  <td>" << content << std::endl << "  </td>" << std::endl;
0096     return *this;
0097   }
0098 
0099   DDHtmlFormatter color(int red, int green, int blue) { return *this; };
0100 
0101   void pre() { os_.str(""); }
0102 
0103   // std::string operator<<(std::string o) { o << os_; }
0104   mutable std::stringstream os_;
0105 
0106   DDHtmlFormatter &operator=(const DDHtmlFormatter &) = delete;
0107 };
0108 
0109 /** 
0110     Generates HTML for DD-namespaces 
0111 */
0112 class DDNsGenerator {
0113 public:
0114   DDNsGenerator(std::ostream &os,
0115                 const std::string &title,
0116                 const std::string &target,
0117                 const ns_type &n,
0118                 const std::string &text = "")
0119       : os_(os), title_(title), text_(text), target_(target), n_(n) {}
0120 
0121   void doit();
0122 
0123 private:
0124   std::ostream &os_;
0125   std::string title_, text_, target_;
0126   const ns_type &n_;
0127 };
0128 
0129 class DDFrameGenerator {
0130 public:
0131   DDFrameGenerator(std::ostream &os,
0132                    const std::string &title,
0133                    const std::string &n1 = "_ns",  //frame names
0134                    const std::string &n2 = "_list",
0135                    const std::string &n3 = "_details",
0136                    const std::string &u1 = "ns.html",  //url to be displayed in each frame
0137                    const std::string &u2 = "list.html",
0138                    const std::string &u3 = "details.html")
0139       : t_(title), n1_(n1), n2_(n2), n3_(n3), u1_(u1), u2_(u2), u3_(u3), os_(os) {}
0140 
0141   void doit();
0142 
0143 private:
0144   std::string t_, n1_, n2_, n3_, u1_, u2_, u3_;
0145   std::ostream &os_;
0146 };
0147 
0148 class DDHtmlDetails {
0149 public:
0150   DDHtmlDetails(const std::string &cat, const std::string &txt);
0151   virtual bool details(std::ostream &os, const DDName &) = 0;
0152   virtual ns_type &names() = 0;
0153   virtual ~DDHtmlDetails(){};
0154   const std::string &category() { return cat_; }
0155   const std::string &text() { return txt_; }
0156 
0157 protected:
0158   mutable ns_type names_;
0159   std::string cat_, txt_;
0160   DDHtmlFormatter f_;
0161 };
0162 
0163 class DDHtmlLpDetails : public DDHtmlDetails {
0164 public:
0165   DDHtmlLpDetails(const std::string &cat, const std::string &txt) : DDHtmlDetails(cat, txt) {}
0166   bool details(std::ostream &os, const DDName &) override;
0167   ns_type &names() override;
0168 };
0169 
0170 class DDHtmlMaDetails : public DDHtmlDetails {
0171 public:
0172   DDHtmlMaDetails(const std::string &cat, const std::string &txt) : DDHtmlDetails(cat, txt) {}
0173   bool details(std::ostream &os, const DDName &) override;
0174   ns_type &names() override;
0175 };
0176 
0177 class DDHtmlSoDetails : public DDHtmlDetails {
0178 public:
0179   DDHtmlSoDetails(const std::string &cat, const std::string &txt) : DDHtmlDetails(cat, txt) {}
0180   bool details(std::ostream &os, const DDName &) override;
0181   ns_type &names() override;
0182 };
0183 
0184 class DDHtmlRoDetails : public DDHtmlDetails {
0185 public:
0186   DDHtmlRoDetails(const std::string &cat, const std::string &txt) : DDHtmlDetails(cat, txt) {}
0187   bool details(std::ostream &os, const DDName &) override;
0188   ns_type &names() override;
0189 };
0190 
0191 class DDHtmlSpDetails : public DDHtmlDetails {
0192 public:
0193   DDHtmlSpDetails(const std::string &cat, const std::string &txt) : DDHtmlDetails(cat, txt) {}
0194   bool details(std::ostream &os, const DDName &) override;
0195   ns_type &names() override;
0196 };
0197 
0198 void dd_to_html(DDHtmlDetails &det);
0199 
0200 void dd_html_frameset(std::ostream &os);
0201 
0202 void dd_html_menu_frameset(std::ostream &os);
0203 
0204 void dd_html_menu(std::ostream &os);
0205 
0206 void dd_html_ro();
0207 
0208 #endif