CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
stor::XHTMLMaker Class Reference

#include <XHTMLMaker.h>

Public Types

typedef std::map< std::string,
std::string > 
AttrMap
 
typedef xercesc::DOMElement Node
 

Public Member Functions

void addBool (Node *parent, const bool &)
 
void addDouble (Node *parent, const double &value, const unsigned int &precision=2)
 
void addHex (Node *parent, const unsigned long &)
 
void addInt (Node *parent, const int &)
 
void addInt (Node *parent, const unsigned int &)
 
void addInt (Node *parent, const long &)
 
void addInt (Node *parent, const unsigned long &)
 
void addInt (Node *parent, const long long &)
 
void addInt (Node *parent, const unsigned long long &)
 
NodeaddNode (const std::string &name, Node *parent, const AttrMap &attrs)
 
NodeaddNode (const std::string &name, const AttrMap &attrs)
 
NodeaddNode (const std::string &name, Node *parent)
 
NodeaddNode (const std::string &name)
 
void addText (Node *parent, const std::string &)
 
NodegetHead () const
 
void out ()
 
void out (const std::string &dest)
 
void out (std::string &dest)
 
void out (std::ostream &dest)
 
Nodestart (const std::string &title)
 
 XHTMLMaker ()
 
 ~XHTMLMaker ()
 

Private Member Functions

void setWriterFeatures_ ()
 

Private Attributes

xercesc::DOMDocument * doc_
 
Nodehead_
 
bool pageStarted_
 
xercesc::DOMDocumentType * typ_
 
xercesc::DOMWriter * writer_
 

Detailed Description

Helper class to build XHTML pages

Author:
mommsen
Revision:
1.12
Date:
2011/07/07 09:22:44

Definition at line 27 of file XHTMLMaker.h.

Member Typedef Documentation

typedef std::map<std::string,std::string> stor::XHTMLMaker::AttrMap

Definition at line 36 of file XHTMLMaker.h.

typedef xercesc::DOMElement stor::XHTMLMaker::Node

Typedefs

Definition at line 35 of file XHTMLMaker.h.

Constructor & Destructor Documentation

XHTMLMaker::XHTMLMaker ( )

Constructor

Definition at line 37 of file XHTMLMaker.cc.

References dtNoiseDBValidation_cfg::cerr, fetchall_from_DQM_v2::release, s_id, and BeamSplash_cfg::version.

38 {
39  XMLCh* xls = xs_("ls");
40  DOMImplementation* imp =
41  DOMImplementationRegistry::getDOMImplementation(xls);
42 
43  XMLCh* xhtml_s =xs_("html") ;
44  XMLCh* p_id = xs_( "-//W3C//DTD XHTML 1.0 Strict//EN" );
45  XMLCh* s_id = xs_( "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" );
46 
47  typ_ = imp->createDocumentType( xhtml_s, p_id, s_id );
48 
49  XMLCh* ns_uri = xs_( "http://www.w3.org/1999/xhtml" );
50 
51  doc_ = imp->createDocument( ns_uri, xhtml_s, typ_ );
52 
53 
54  if( !doc_ )
55  {
56  std::cerr << "Cannot create document" << std::endl;
57  return;
58  }
59 
60  XMLCh* encoding = xs_("utf-8");
61  doc_->setEncoding(encoding);
62  //doc_->setStandalone( true );
63  XMLCh* version = xs_("1.0");
64  doc_->setVersion(version);
65 
66  pageStarted_ = false;
67 
68  writer_ =
69  ( (DOMImplementationLS*)imp )->createDOMWriter();
70 
71  XMLString::release(&xls);
72  XMLString::release(&xhtml_s);
73  XMLString::release(&p_id);
74  XMLString::release(&s_id);
75  XMLString::release(&ns_uri);
76  XMLString::release(&encoding);
77  XMLString::release(&version);
78 
79  if( !writer_ )
80  {
81  std::cerr << "Cannot create DOM writer" << std::endl;
82  return;
83  }
84 }
xercesc::DOMDocument * doc_
Definition: XHTMLMaker.h:166
xercesc::DOMDocumentType * typ_
Definition: XHTMLMaker.h:168
static const edm::ProductID s_id
Definition: EventBase.cc:23
xercesc::DOMWriter * writer_
Definition: XHTMLMaker.h:167
XHTMLMaker::~XHTMLMaker ( )

Destructor

Definition at line 90 of file XHTMLMaker.cc.

91 {
92  delete doc_;
93  delete writer_;
94  delete typ_;
95 }
xercesc::DOMDocument * doc_
Definition: XHTMLMaker.h:166
xercesc::DOMDocumentType * typ_
Definition: XHTMLMaker.h:168
xercesc::DOMWriter * writer_
Definition: XHTMLMaker.h:167

Member Function Documentation

void XHTMLMaker::addBool ( Node parent,
const bool &  value 
)

Add a boolean

Definition at line 264 of file XHTMLMaker.cc.

265 {
266  addText( parent, value ? "True" : "False" );
267 }
list parent
Definition: dbtoconf.py:74
void addText(Node *parent, const std::string &)
Definition: XHTMLMaker.cc:173
void XHTMLMaker::addDouble ( Node parent,
const double &  value,
const unsigned int &  precision = 2 
)
void XHTMLMaker::addHex ( Node parent,
const unsigned long &  value 
)

Add an unsigned long in hex format

Definition at line 244 of file XHTMLMaker.cc.

References relativeConstraints::value.

Referenced by stor::SMWebPageHelper::addDOMforFiles().

245 {
246  ostringstream tmpString;
247  tmpString << "0x" << std::hex << value;
248  addText( parent, tmpString.str() );
249 }
list parent
Definition: dbtoconf.py:74
void addText(Node *parent, const std::string &)
Definition: XHTMLMaker.cc:173
void XHTMLMaker::addInt ( Node parent,
const int &  value 
)
void XHTMLMaker::addInt ( Node parent,
const unsigned int &  value 
)

Add an unsigned int

Definition at line 194 of file XHTMLMaker.cc.

References relativeConstraints::value.

195 {
196  ostringstream tmpString;
197  tmpString << value;
198  addText( parent, tmpString.str() );
199 }
list parent
Definition: dbtoconf.py:74
void addText(Node *parent, const std::string &)
Definition: XHTMLMaker.cc:173
void XHTMLMaker::addInt ( Node parent,
const long &  value 
)

Add a long

Definition at line 204 of file XHTMLMaker.cc.

References relativeConstraints::value.

205 {
206  ostringstream tmpString;
207  tmpString << value;
208  addText( parent, tmpString.str() );
209 }
list parent
Definition: dbtoconf.py:74
void addText(Node *parent, const std::string &)
Definition: XHTMLMaker.cc:173
void XHTMLMaker::addInt ( Node parent,
const unsigned long &  value 
)

Add an unsigned long

Definition at line 214 of file XHTMLMaker.cc.

References relativeConstraints::value.

215 {
216  ostringstream tmpString;
217  tmpString << value;
218  addText( parent, tmpString.str() );
219 }
list parent
Definition: dbtoconf.py:74
void addText(Node *parent, const std::string &)
Definition: XHTMLMaker.cc:173
void XHTMLMaker::addInt ( Node parent,
const long long &  value 
)

Add a long long

Definition at line 224 of file XHTMLMaker.cc.

References relativeConstraints::value.

225 {
226  ostringstream tmpString;
227  tmpString << value;
228  addText( parent, tmpString.str() );
229 }
list parent
Definition: dbtoconf.py:74
void addText(Node *parent, const std::string &)
Definition: XHTMLMaker.cc:173
void XHTMLMaker::addInt ( Node parent,
const unsigned long long &  value 
)

Add an unsigned long long

Definition at line 234 of file XHTMLMaker.cc.

References relativeConstraints::value.

235 {
236  ostringstream tmpString;
237  tmpString << value;
238  addText( parent, tmpString.str() );
239 }
list parent
Definition: dbtoconf.py:74
void addText(Node *parent, const std::string &)
Definition: XHTMLMaker.cc:173
XHTMLMaker::Node * XHTMLMaker::addNode ( const std::string &  name,
XHTMLMaker::Node parent,
const AttrMap attrs 
)

Add child

Definition at line 146 of file XHTMLMaker.cc.

References i, and fetchall_from_DQM_v2::release.

Referenced by stor::SMWebPageHelper::addDOMforConfigString(), smproxy::SMPSWebPageHelper::addDOMforConnectionInfo(), smproxy::SMPSWebPageHelper::addDOMforEventServers(), stor::SMWebPageHelper::addDOMforFiles(), stor::SMWebPageHelper::addDOMforFragmentMonitor(), smproxy::SMPSWebPageHelper::addDOMforHyperLinks(), stor::SMWebPageHelper::addDOMforHyperLinks(), stor::SMWebPageHelper::addDOMforResourceUsage(), stor::SMWebPageHelper::addDOMforRunMonitor(), smproxy::SMPSWebPageHelper::addDOMforSMhost(), stor::SMWebPageHelper::addDOMforStoredData(), stor::SMWebPageHelper::addDOMforSummaryInformation(), smproxy::SMPSWebPageHelper::addDOMforThroughputPerEventType(), stor::SMWebPageHelper::addDOMforThroughputStatistics(), stor::SMWebPageHelper::addFilterUnitList(), stor::SMWebPageHelper::addFragmentStats(), addNode(), stor::SMWebPageHelper::addOutputModuleStatistics(), stor::SMWebPageHelper::addOutputModuleSummary(), stor::SMWebPageHelper::addResourceBrokerDetails(), stor::SMWebPageHelper::addResourceBrokerList(), stor::SMWebPageHelper::addRowForBandwidth(), smproxy::SMPSWebPageHelper::addRowForEventServer(), smproxy::SMPSWebPageHelper::addRowForEventType(), stor::SMWebPageHelper::addRowForFramesReceived(), stor::SMWebPageHelper::addRowForLatency(), stor::SMWebPageHelper::addRowForMaxBandwidth(), stor::SMWebPageHelper::addRowForMinBandwidth(), stor::SMWebPageHelper::addRowForRate(), stor::SMWebPageHelper::addRowForThroughputStatistics(), stor::SMWebPageHelper::addRowForTotalVolume(), stor::SMWebPageHelper::addRowsForSataBeast(), stor::SMWebPageHelper::addRowsForThroughputUsage(), stor::SMWebPageHelper::addRowsForWorkers(), smproxy::SMPSWebPageHelper::addSummaryRowForEventServer(), smproxy::SMPSWebPageHelper::addSummaryRowForThroughput(), stor::SMWebPageHelper::addTableForDiskUsages(), stor::SMWebPageHelper::addTableForResourceUsages(), smproxy::SMPSWebPageHelper::dataRetrieverWebPage(), smproxy::SMPSWebPageHelper::defaultWebPage(), stor::SMWebPageHelper::listStreamRecordsStats(), stor::SMWebPageHelper::resourceBrokerOverview(), and stor::SMWebPageHelper::storedDataWebPage().

149 {
150  XMLCh* xname = xs_(name);
151  Node* el = doc_->createElement(xname);
152  XMLString::release(&xname);
153  parent->appendChild( el );
154 
155  for( AttrMap::const_iterator i = attrs.begin(); i != attrs.end();
156  ++i )
157  {
158  XMLCh* xfirst = xs_(i->first);
159  XMLCh* xsecond = xs_(i->second);
160  el->setAttribute(xfirst, xsecond);
161  XMLString::release(&xfirst);
162  XMLString::release(&xsecond);
163  }
164 
165  return el;
166 
167 }
int i
Definition: DBlmapReader.cc:9
list parent
Definition: dbtoconf.py:74
xercesc::DOMDocument * doc_
Definition: XHTMLMaker.h:166
xercesc::DOMElement Node
Definition: XHTMLMaker.h:35
Node* stor::XHTMLMaker::addNode ( const std::string &  name,
const AttrMap attrs 
)
inline

Add child to top level

Definition at line 71 of file XHTMLMaker.h.

References addNode().

72  {
73  return addNode( name, (Node*)0, attrs );
74  }
Node * addNode(const std::string &name, Node *parent, const AttrMap &attrs)
Definition: XHTMLMaker.cc:146
xercesc::DOMElement Node
Definition: XHTMLMaker.h:35
Node* stor::XHTMLMaker::addNode ( const std::string &  name,
Node parent 
)
inline

Add child without attributes

Definition at line 79 of file XHTMLMaker.h.

References addNode(), and relativeConstraints::empty.

80  {
81  AttrMap empty;
82  return addNode( name, parent, empty );
83  }
Node * addNode(const std::string &name, Node *parent, const AttrMap &attrs)
Definition: XHTMLMaker.cc:146
list parent
Definition: dbtoconf.py:74
std::map< std::string, std::string > AttrMap
Definition: XHTMLMaker.h:36
Node* stor::XHTMLMaker::addNode ( const std::string &  name)
inline

Add child to top without attributes

Definition at line 88 of file XHTMLMaker.h.

References addNode().

89  {
90  return addNode( name, (Node*)0 );
91  }
Node * addNode(const std::string &name, Node *parent, const AttrMap &attrs)
Definition: XHTMLMaker.cc:146
xercesc::DOMElement Node
Definition: XHTMLMaker.h:35
void XHTMLMaker::addText ( Node parent,
const std::string &  data 
)

Add text

Definition at line 173 of file XHTMLMaker.cc.

References fetchall_from_DQM_v2::release.

Referenced by stor::SMWebPageHelper::addDOMforConfigString(), smproxy::SMPSWebPageHelper::addDOMforConnectionInfo(), smproxy::SMPSWebPageHelper::addDOMforEventServers(), stor::SMWebPageHelper::addDOMforFiles(), stor::SMWebPageHelper::addDOMforFragmentMonitor(), smproxy::SMPSWebPageHelper::addDOMforHyperLinks(), stor::SMWebPageHelper::addDOMforHyperLinks(), stor::SMWebPageHelper::addDOMforRunMonitor(), smproxy::SMPSWebPageHelper::addDOMforSMhost(), stor::SMWebPageHelper::addDOMforStoredData(), stor::SMWebPageHelper::addDOMforSummaryInformation(), smproxy::SMPSWebPageHelper::addDOMforThroughputPerEventType(), stor::SMWebPageHelper::addDOMforThroughputStatistics(), stor::SMWebPageHelper::addFilterUnitList(), stor::SMWebPageHelper::addFragmentStats(), stor::SMWebPageHelper::addOutputModuleStatistics(), stor::SMWebPageHelper::addOutputModuleSummary(), stor::SMWebPageHelper::addResourceBrokerDetails(), stor::SMWebPageHelper::addResourceBrokerList(), stor::SMWebPageHelper::addRowForBandwidth(), smproxy::SMPSWebPageHelper::addRowForEventServer(), smproxy::SMPSWebPageHelper::addRowForEventType(), stor::SMWebPageHelper::addRowForFramesReceived(), stor::SMWebPageHelper::addRowForLatency(), stor::SMWebPageHelper::addRowForMaxBandwidth(), stor::SMWebPageHelper::addRowForMinBandwidth(), stor::SMWebPageHelper::addRowForRate(), stor::SMWebPageHelper::addRowForThroughputStatistics(), stor::SMWebPageHelper::addRowForTotalVolume(), stor::SMWebPageHelper::addRowsForSataBeast(), stor::SMWebPageHelper::addRowsForThroughputUsage(), stor::SMWebPageHelper::addRowsForWorkers(), smproxy::SMPSWebPageHelper::addSummaryRowForThroughput(), stor::SMWebPageHelper::addTableForDiskUsages(), stor::SMWebPageHelper::addTableForResourceUsages(), and stor::SMWebPageHelper::listStreamRecordsStats().

174 {
175  XMLCh* xdata = xs_(data);
176  DOMText* txt = doc_->createTextNode(xdata);
177  XMLString::release(&xdata);
178  parent->appendChild( txt );
179 }
list parent
Definition: dbtoconf.py:74
xercesc::DOMDocument * doc_
Definition: XHTMLMaker.h:166
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
Node* stor::XHTMLMaker::getHead ( ) const
inline

Useful for css and javascript

Definition at line 56 of file XHTMLMaker.h.

References head_.

56 { return head_; }
void XHTMLMaker::out ( )
void XHTMLMaker::out ( const std::string &  dest)

Dump the page to a local file

Definition at line 315 of file XHTMLMaker.cc.

References fetchall_from_DQM_v2::release.

316 {
318  XMLCh* xfilename = xs_(filename);
319  XMLFormatTarget* ftar = new LocalFileFormatTarget(xfilename);
320  writer_->writeNode( ftar, *doc_ );
321  XMLString::release(&xfilename);
322  delete ftar;
323 }
xercesc::DOMDocument * doc_
Definition: XHTMLMaker.h:166
xercesc::DOMWriter * writer_
Definition: XHTMLMaker.h:167
tuple filename
Definition: lut2db_cfg.py:20
void setWriterFeatures_()
Definition: XHTMLMaker.cc:273
void XHTMLMaker::out ( std::string &  dest)

Dump the page to a string

Definition at line 328 of file XHTMLMaker.cc.

References dbtoconf::out.

329 {
330  std::ostringstream stream;
331  out( stream );
332  dest = stream.str();
333 }
void XHTMLMaker::out ( std::ostream &  dest)

Dump the page into an output stream

Definition at line 338 of file XHTMLMaker.cc.

339 {
341  MemBufFormatTarget* ftar = new MemBufFormatTarget();
342  writer_->writeNode( ftar, *doc_ );
343  dest << ftar->getRawBuffer();
344  delete ftar;
345 }
xercesc::DOMDocument * doc_
Definition: XHTMLMaker.h:166
xercesc::DOMWriter * writer_
Definition: XHTMLMaker.h:167
void setWriterFeatures_()
Definition: XHTMLMaker.cc:273
void XHTMLMaker::setWriterFeatures_ ( )
private

Set DOMWriter features

Definition at line 273 of file XHTMLMaker.cc.

274 {
275 
276  //writer_->setNewLine( (const XMLCh*)( L"\n" ) );
277 
278  if( writer_->canSetFeature( XMLUni::fgDOMWRTSplitCdataSections, true ) )
279  {
280  writer_->setFeature( XMLUni::fgDOMWRTSplitCdataSections, true );
281  }
282 
283  if( writer_->canSetFeature( XMLUni::fgDOMWRTDiscardDefaultContent, true ) )
284  {
285  writer_->setFeature( XMLUni::fgDOMWRTDiscardDefaultContent, true );
286  }
287 
288  if( writer_->canSetFeature( XMLUni::fgDOMWRTFormatPrettyPrint, true ) )
289  {
290  writer_->setFeature( XMLUni::fgDOMWRTFormatPrettyPrint, true );
291  }
292 
293  if( writer_->canSetFeature( XMLUni::fgDOMWRTBOM, true ) )
294  {
295  writer_->setFeature( XMLUni::fgDOMWRTBOM, true );
296  }
297 
298 }
xercesc::DOMWriter * writer_
Definition: XHTMLMaker.h:167
XHTMLMaker::Node * XHTMLMaker::start ( const std::string &  title)

Initialize page and return body element

Definition at line 101 of file XHTMLMaker.cc.

References dtNoiseDBValidation_cfg::cerr, h, and fetchall_from_DQM_v2::release.

Referenced by progressbar.ProgressBar::__next__(), Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

102 {
103 
104  if( pageStarted_ )
105  {
106  std::cerr << "Page already started" << std::endl;
107  return (Node*)0;
108  }
109 
110  pageStarted_ = true;
111 
112  // Root element:
113  Node* el_xhtml = doc_->getDocumentElement();
114 
115  // Head:
116  XMLCh* h = xs_("head");
117  head_ = doc_->createElement(h);
118  XMLString::release(&h);
119  el_xhtml->appendChild( head_ );
120 
121 
122  // Title:
123  XMLCh* xtitle = xs_("title");
124  Node* el_title = doc_->createElement(xtitle);
125  XMLString::release(&xtitle);
126  head_->appendChild( el_title );
127  xtitle = xs_(title);
128  DOMText* txt_title = doc_->createTextNode(xtitle);
129  XMLString::release(&xtitle);
130  el_title->appendChild( txt_title );
131 
132  // Body:
133  XMLCh* xbody = xs_("body");
134  Node* el_body = doc_->createElement(xbody);
135  XMLString::release(&xbody);
136  el_xhtml->appendChild( el_body );
137 
138  return el_body;
139 
140 }
xercesc::DOMDocument * doc_
Definition: XHTMLMaker.h:166
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
xercesc::DOMElement Node
Definition: XHTMLMaker.h:35

Member Data Documentation

xercesc::DOMDocument* stor::XHTMLMaker::doc_
private

Definition at line 166 of file XHTMLMaker.h.

Node* stor::XHTMLMaker::head_
private

Definition at line 170 of file XHTMLMaker.h.

Referenced by getHead().

bool stor::XHTMLMaker::pageStarted_
private

Definition at line 172 of file XHTMLMaker.h.

xercesc::DOMDocumentType* stor::XHTMLMaker::typ_
private

Definition at line 168 of file XHTMLMaker.h.

xercesc::DOMWriter* stor::XHTMLMaker::writer_
private

Definition at line 167 of file XHTMLMaker.h.