PageRenderTime 40ms CodeModel.GetById 16ms app.highlight 20ms RepoModel.GetById 1ms app.codeStats 0ms

/DetectorDescription/RegressionTest/interface/DDHtmlFormatter.h

https://github.com/aivanov-cern/cmssw
C Header | 189 lines | 127 code | 54 blank | 8 comment | 0 complexity | 81879ec316dbadd6c518ff1ed84efb33 MD5 | raw file
  1#ifndef DDHtmlFormatter_h
  2#define DDHtmlFormatter_h
  3
  4#include <iostream>
  5#include <string>
  6#include <sstream>
  7#include <map>
  8#include <set>
  9#include <vector>
 10
 11#include "DetectorDescription/RegressionTest/interface/DDErrorDetection.h"
 12
 13class DDHtmlFormatter;
 14
 15std::ostream & operator<<(std::ostream & o, const DDHtmlFormatter & f);
 16
 17class DDHtmlFormatter
 18{
 19public:
 20 
 21  typedef std::map<std::string,std::set<std::string> > ns_type;
 22 
 23  explicit DDHtmlFormatter() { }
 24  DDHtmlFormatter(const DDHtmlFormatter & f) : os_(f.os_.str()) { }
 25 
 26  DDHtmlFormatter header(const std::string & text, const std::string & style="../../style.css");
 27  DDHtmlFormatter footer();
 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
 56private:
 57
 58  DDHtmlFormatter& operator= ( const DDHtmlFormatter& );
 59};
 60
 61
 62
 63
 64
 65
 66/** 
 67    Generates HTML for DD-namespaces 
 68*/
 69class DDNsGenerator 
 70{
 71 
 72public:
 73  DDNsGenerator(std::ostream & os, 
 74		const std::string & title, 
 75		const std::string & target, 
 76		const ns_type & n, 
 77		const std::string & text="") 
 78    : os_(os), title_(title), text_(text), target_(target), n_(n){ }
 79 
 80  void doit();
 81
 82private:
 83
 84  std::ostream & os_;  
 85  std::string title_, text_, target_; 
 86  const ns_type & n_;
 87}; 
 88
 89class DDFrameGenerator
 90{
 91public:
 92  DDFrameGenerator(std::ostream & os,
 93                   const std::string & title,
 94                   const std::string & n1 = "_ns", //frame names
 95		   const std::string & n2 = "_list",
 96		   const std::string & n3 = "_details",
 97		   const std::string & u1 = "ns.html", //url to be displayed in each frame
 98		   const std::string & u2 = "list.html",
 99		   const std::string & u3 = "details.html")
100    : t_(title), n1_(n1), n2_(n2), n3_(n3), u1_(u1), u2_(u2), u3_(u3), os_(os) { }
101   
102  void doit();   
103
104private:
105  std::string t_, n1_, n2_, n3_, u1_, u2_, u3_;
106  std::ostream & os_;
107};  		     		     
108	
109// =============================================================================================================
110// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
111
112class DDHtmlDetails
113{
114public:
115  DDHtmlDetails(const std::string & cat, const std::string & txt);
116  virtual bool details(std::ostream & os, const DDName &) = 0;	
117  virtual ns_type & names() = 0;
118  virtual ~DDHtmlDetails(){};
119  const std::string & category() { return cat_; }
120  const std::string & text() {return txt_; }
121protected:  
122  mutable ns_type names_;  
123  std::string cat_, txt_;
124  DDHtmlFormatter f_;
125};		
126
127
128class DDHtmlLpDetails : public DDHtmlDetails
129{
130public: 
131  DDHtmlLpDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
132  bool details(std::ostream & os, const DDName &);
133  ns_type & names();
134  
135};
136
137class DDHtmlMaDetails : public DDHtmlDetails
138{
139public: 
140  DDHtmlMaDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
141  bool details(std::ostream & os, const DDName &);
142  ns_type & names();
143  
144};
145
146class DDHtmlSoDetails : public DDHtmlDetails
147{
148public: 
149  DDHtmlSoDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
150  bool details(std::ostream & os, const DDName &);
151  ns_type & names();
152  
153};
154
155class DDHtmlRoDetails : public DDHtmlDetails
156{
157public: 
158  DDHtmlRoDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
159  bool details(std::ostream & os, const DDName &);
160  ns_type & names();
161  
162};
163
164class DDHtmlSpDetails : public DDHtmlDetails
165{
166public: 
167  DDHtmlSpDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
168  bool details(std::ostream & os, const DDName &);
169  ns_type & names();
170  
171};
172
173
174// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
175// =============================================================================================================
176	
177void dd_to_html(DDHtmlDetails & det);
178			 	         
179void dd_html_frameset(std::ostream & os);
180
181void dd_html_menu_frameset(std::ostream & os);
182
183void dd_html_menu(std::ostream & os);
184
185void dd_html_ro();
186
187
188
189#endif