CMS 3D CMS Logo

DDHtmlFormatter.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_REGRESSION_TEST_DD_HTML_FORMATTER_H
2 #define DETECTOR_DESCRIPTION_REGRESSION_TEST_DD_HTML_FORMATTER_H
3 
4 #include <iostream>
5 #include <string>
6 #include <sstream>
7 #include <map>
8 #include <set>
9 #include <vector>
10 
12 
13 class DDHtmlFormatter;
14 
15 std::ostream & operator<<(std::ostream & o, const DDHtmlFormatter & f);
16 
18 {
19 public:
20 
21  typedef std::map<std::string,std::set<std::string> > ns_type;
22 
23  explicit DDHtmlFormatter() { }
25 
26  DDHtmlFormatter header(const std::string & text, const std::string & style="../../style.css");
28 
29  DDHtmlFormatter br() { pre(); os_ << "<br>" << std::endl; return *this; }
30  DDHtmlFormatter p(const std::string & content) { pre(); os_ << "<p>" << std::endl << content << std::endl << "</p>" << std::endl; return *this; }
31 
32  DDHtmlFormatter ul() { pre(); os_ << "<ul>" << std::endl; return *this;}
33  DDHtmlFormatter li(const std::string & content) { pre(); os_ << "<li>" << content << "</li>" << std::endl; return *this;}
34  DDHtmlFormatter ulEnd() { pre(); os_ << "</ul>" << std::endl; return *this;}
35 
36  DDHtmlFormatter h1(const std::string & content) { pre(); os_ << "<h1>" << content << "</h1>" << std::endl; return *this;}
37  DDHtmlFormatter h2(const std::string & content) { pre(); os_ << "<h2>" << content << "</h2>" << std::endl; return *this;}
38  DDHtmlFormatter h3(const std::string & content) { pre(); os_ << "<h3>" << content << "</h3>" << std::endl; return *this;}
39 
40  DDHtmlFormatter link(const std::string & url, const std::string & text, const std::string & target="_self");
41  std::string lnk(const std::string & url, const std::string & text, const std::string & target="_self");
42 
43  DDHtmlFormatter table(int border=0){ pre(); os_ << "<table border=\"" << border << "\">" << std::endl; return *this;}
44  DDHtmlFormatter tableEnd() { pre(); os_ << "</table>" << std::endl; return *this;}
45  DDHtmlFormatter tr() { pre(); os_ << " <tr>" << std::endl; return *this;}
46  DDHtmlFormatter trEnd() { pre(); os_ << " </tr>" << std::endl; return *this;}
47  DDHtmlFormatter td(const std::string & content) { pre(); os_ << " <td>" << content << std::endl << " </td>" << std::endl; return *this;}
48 
49  DDHtmlFormatter color(int red, int green, int blue){return *this;};
50 
51  void pre() { os_.str(""); }
52 
53  // std::string operator<<(std::string o) { o << os_; }
54  mutable std::stringstream os_;
55 
56  DDHtmlFormatter& operator= ( const DDHtmlFormatter& ) = delete;
57 };
58 
63 {
64 public:
65  DDNsGenerator(std::ostream & os,
66  const std::string & title,
67  const std::string & target,
68  const ns_type & n,
69  const std::string & text="")
70  : os_(os), title_(title), text_(text), target_(target), n_(n){ }
71 
72  void doit();
73 
74 private:
75 
76  std::ostream & os_;
77  std::string title_, text_, target_;
78  const ns_type & n_;
79 };
80 
82 {
83 public:
84  DDFrameGenerator(std::ostream & os,
85  const std::string & title,
86  const std::string & n1 = "_ns", //frame names
87  const std::string & n2 = "_list",
88  const std::string & n3 = "_details",
89  const std::string & u1 = "ns.html", //url to be displayed in each frame
90  const std::string & u2 = "list.html",
91  const std::string & u3 = "details.html")
92  : t_(title), n1_(n1), n2_(n2), n3_(n3), u1_(u1), u2_(u2), u3_(u3), os_(os) { }
93 
94  void doit();
95 
96 private:
97  std::string t_, n1_, n2_, n3_, u1_, u2_, u3_;
98  std::ostream & os_;
99 };
100 
102 {
103 public:
104  DDHtmlDetails(const std::string & cat, const std::string & txt);
105  virtual bool details(std::ostream & os, const DDName &) = 0;
106  virtual ns_type & names() = 0;
107  virtual ~DDHtmlDetails(){};
108  const std::string & category() { return cat_; }
109  const std::string & text() {return txt_; }
110 protected:
111  mutable ns_type names_;
114 };
115 
116 
118 {
119 public:
120  DDHtmlLpDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
121  bool details(std::ostream & os, const DDName &) override;
122  ns_type & names() override;
123 
124 };
125 
127 {
128 public:
129  DDHtmlMaDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
130  bool details(std::ostream & os, const DDName &) override;
131  ns_type & names() override;
132 
133 };
134 
136 {
137 public:
138  DDHtmlSoDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
139  bool details(std::ostream & os, const DDName &) override;
140  ns_type & names() override;
141 
142 };
143 
145 {
146 public:
147  DDHtmlRoDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
148  bool details(std::ostream & os, const DDName &) override;
149  ns_type & names() override;
150 
151 };
152 
154 {
155 public:
156  DDHtmlSpDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
157  bool details(std::ostream & os, const DDName &) override;
158  ns_type & names() override;
159 
160 };
161 
162 void dd_to_html(DDHtmlDetails & det);
163 
164 void dd_html_frameset(std::ostream & os);
165 
166 void dd_html_menu_frameset(std::ostream & os);
167 
168 void dd_html_menu(std::ostream & os);
169 
170 void dd_html_ro();
171 
172 #endif
void dd_html_frameset(std::ostream &os)
DDHtmlFormatter li(const std::string &content)
static const HistoName names[]
DDHtmlSpDetails(const std::string &cat, const std::string &txt)
DDHtmlSoDetails(const std::string &cat, const std::string &txt)
DDHtmlFormatter br()
DDHtmlFormatter h3(const std::string &content)
std::ostream & os_
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDHtmlRoDetails(const std::string &cat, const std::string &txt)
std::string title_
DDHtmlFormatter & operator=(const DDHtmlFormatter &)=delete
DDFrameGenerator(std::ostream &os, const std::string &title, const std::string &n1="_ns", const std::string &n2="_list", const std::string &n3="_details", const std::string &u1="ns.html", const std::string &u2="list.html", const std::string &u3="details.html")
virtual ~DDHtmlDetails()
DDHtmlMaDetails(const std::string &cat, const std::string &txt)
DDHtmlFormatter h1(const std::string &content)
DDHtmlFormatter td(const std::string &content)
DDHtmlFormatter color(int red, int green, int blue)
DDHtmlFormatter f_
def cat(path)
Definition: eostools.py:400
DDHtmlFormatter p(const std::string &content)
void dd_html_ro()
void dd_html_menu(std::ostream &os)
Definition: style.py:1
DDHtmlFormatter h2(const std::string &content)
std::ostream & os_
double f[11][100]
DDNsGenerator(std::ostream &os, const std::string &title, const std::string &target, const ns_type &n, const std::string &text="")
DDHtmlFormatter ulEnd()
DDHtmlFormatter table(int border=0)
void dd_to_html(DDHtmlDetails &det)
std::map< std::string, std::set< std::string > > ns_type
const ns_type & n_
DDHtmlFormatter tableEnd()
def green(string)
std::string txt_
void dd_html_menu_frameset(std::ostream &os)
const std::string & text()
std::ostream & operator<<(std::ostream &o, const DDHtmlFormatter &f)
DDHtmlFormatter tr()
DDHtmlFormatter(const DDHtmlFormatter &f)
DDHtmlFormatter header(const std::string &text, const std::string &style="../../style.css")
const std::string & category()
DDHtmlLpDetails(const std::string &cat, const std::string &txt)
std::string lnk(const std::string &url, const std::string &text, const std::string &target="_self")
DDHtmlFormatter trEnd()
std::stringstream os_
DDHtmlFormatter ul()
#define str(s)
DDHtmlFormatter link(const std::string &url, const std::string &text, const std::string &target="_self")
DDHtmlFormatter footer()
std::map< std::string, std::set< std::string > > ns_type