CMS 3D CMS Logo

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

#include <WebInterface.h>

Public Member Functions

void add (std::string, WebElement *)
 Adds widgets to the page. More...
 
void Configure (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 Answers connection configuration requests. More...
 
void ContentsOpen (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 Answers ContentViewer requests. More...
 
virtual void Default (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 Answers requests by sending the webpage of the application. More...
 
void DrawGif (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 Answers viewer requests. More...
 
std::string get_from_multimap (std::multimap< std::string, std::string > &mymap, std::string key)
 
std::string getApplicationURL ()
 
std::string getContextURL ()
 
virtual void handleCustomRequest (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 
void handleRequest (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 
void handleStandardRequest (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 
void Open (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 Answer navigator requests. More...
 
void printContentViewerXML (std::string current, xgi::Output *out)
 
void printMap (ME_MAP view_map, std::string id)
 
void printMessagesXML (xgi::Output *out)
 Answers Messages requests. More...
 
void printNavigatorXML (std::string directory, xgi::Output *out)
 Outputs the subdirectories and files of "directory". Called by any of the above three. More...
 
void sendMessage (std::string the_title, std::string the_text, MessageType the_type)
 Adds messages to the message dispatcher. More...
 
 WebInterface (std::string _exeURL, std::string _appURL)
 
virtual ~WebInterface ()
 

Protected Attributes

DQMStoredqmStore_
 
WebPagepage_p
 

Private Attributes

std::string appURL
 
std::multimap< std::string,
std::string > 
conf_map
 
std::string exeURL
 
MessageDispatcher msg_dispatcher
 

Detailed Description

Definition at line 21 of file WebInterface.h.

Constructor & Destructor Documentation

WebInterface::WebInterface ( std::string  _exeURL,
std::string  _appURL 
)

Definition at line 9 of file WebInterface.cc.

References appURL, gather_cfg::cout, dqmStore_, exeURL, and cppFunctionSkipper::operator.

10 {
11  exeURL = _exeURL;
12  appURL = _appURL;
13 
14  std::cout << "created a WebInterface for the DQMClient, the url = " << appURL << std::endl;
15  std::cout << "within context = " << exeURL << std::endl;
16 
18 }
std::string appURL
Definition: WebInterface.h:27
DQMStore * dqmStore_
Definition: WebInterface.h:34
tuple cout
Definition: gather_cfg.py:121
std::string exeURL
Definition: WebInterface.h:26
virtual WebInterface::~WebInterface ( )
inlinevirtual

Definition at line 40 of file WebInterface.h.

41  {
42  }

Member Function Documentation

void WebInterface::add ( std::string  name,
WebElement element_p 
)

Adds widgets to the page.

Definition at line 50 of file WebInterface.cc.

References WebPage::add(), and page_p.

51 {
52  page_p->add(name, element_p);
53 }
void add(std::string, WebElement *)
Definition: WebPage.cc:8
WebPage * page_p
Definition: WebInterface.h:35
void WebInterface::Configure ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)

Answers connection configuration requests.

Definition at line 72 of file WebInterface.cc.

References get_from_multimap(), query::host, recoMuon::in, query::port, CgiReader::read_form(), and matplotRender::reader.

73 {
75  reader.read_form(conf_map);
76 
77  std::string host = get_from_multimap(conf_map, "Hostname");
78  std::string port = get_from_multimap(conf_map, "Port");
79  std::string clientname = get_from_multimap(conf_map, "Clientname");
80 
81 }
int port
Definition: query.py:115
string host
Definition: query.py:114
std::string get_from_multimap(std::multimap< std::string, std::string > &mymap, std::string key)
Definition: WebInterface.cc:21
std::multimap< std::string, std::string > conf_map
Definition: WebInterface.h:28
void WebInterface::ContentsOpen ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)

Answers ContentViewer requests.

Definition at line 190 of file WebInterface.cc.

References gather_cfg::cout, cond::rpcobimon::current, get_from_multimap(), recoMuon::in, dbtoconf::out, CgiReader::read_form(), and matplotRender::reader.

191 {
192  std::multimap<std::string, std::string> nav_map;
193 
195  reader.read_form(nav_map);
196 
197  std::string to_open = get_from_multimap(nav_map, "Open");
198  std::string current = get_from_multimap(nav_map, "Current");
199 
200  // if the user does not want to go to the top directory...
201  if (to_open != "top")
202  {
203  // ...and if the current directory is not the top...
204  if (current != "top")
205  {
206  // ...and if we don't want to go one directory up...
207  if (to_open != "..")
208  {
209  // ...then we need to add the current directory at the beginning of the to_open string
210  to_open = current + "/" + to_open;
211  }
212  }
213  }
214 
215 
216  std::cout << "will try to open " << to_open << std::endl;
217  if (dqmStore_)
218  {
219  if (to_open == "top")
220  {
221  dqmStore_->cd();
222  }
223  else if (to_open == "..")
224  {
225  dqmStore_->goUp();
226  }
227  else
228  {
229  dqmStore_->setCurrentFolder(to_open);
230  }
232  }
233  else
234  {
235  std::cout << "no DQMStore object, subscription to " << to_open << " failed!" << std::endl;
236  }
237 }
void printContentViewerXML(std::string current, xgi::Output *out)
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:406
tuple out
Definition: dbtoconf.py:99
DQMStore * dqmStore_
Definition: WebInterface.h:34
std::string get_from_multimap(std::multimap< std::string, std::string > &mymap, std::string key)
Definition: WebInterface.cc:21
void goUp(void)
equivalent to &quot;cd ..&quot;
Definition: DQMStore.cc:440
tuple cout
Definition: gather_cfg.py:121
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
const std::string & pwd(void) const
Definition: DQMStore.cc:401
void WebInterface::Default ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
virtual

Answers requests by sending the webpage of the application.

Definition at line 41 of file WebInterface.cc.

References dbtoconf::out, CgiWriter::output_finish(), CgiWriter::output_head(), and CgiWriter::output_preamble().

42 {
43  CgiWriter writer(out, getContextURL());
44  writer.output_preamble();
45  writer.output_head();
47  writer.output_finish();
48 }
WebPage * page_p
Definition: WebInterface.h:35
std::string getContextURL()
Definition: WebInterface.h:44
tuple out
Definition: dbtoconf.py:99
void printHTML(xgi::Output *out)
Definition: WebPage.cc:27
void WebInterface::DrawGif ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)

Answers viewer requests.

Definition at line 273 of file WebInterface.cc.

References ME_MAP::add(), gather_cfg::cout, cond::rpcobimon::current, get_from_multimap(), ContentReader::give_ME(), recoMuon::in, mergeVDriftHistosByStation::name, dbtoconf::out, CgiReader::read_form(), and pileupCalc::upper.

274 {
275  std::multimap<std::string, std::string> view_multimap;
276  ME_MAP view_map;
277 
278  CgiReader cgi_reader(in);
279  cgi_reader.read_form(view_multimap);
280 
281  std::string current = get_from_multimap(view_multimap, "Current");
282 
283 
284  if (dqmStore_)
285  {
286  std::cout << "The DQMStore pointer is empty!" << std::endl;
287  return;
288  }
289 
290  ContentReader con_reader(dqmStore_);
291  std::multimap<std::string,std::string>::iterator lower = view_multimap.lower_bound("View");
292  std::multimap<std::string,std::string>::iterator upper = view_multimap.upper_bound("View");
293  std::multimap<std::string,std::string>::iterator it;
294  for (it = lower; it != upper; it++)
295  {
296  std::string name = it->second;
297  MonitorElement *pointer = con_reader.give_ME(name);
298  if (pointer != 0)
299  {
300  view_map.add(name, pointer);
301  std::cout << "ADDING " << name << " TO view_map!!!" << std::endl;
302  }
303  }
304 
305  // Print the ME_map into a file
306  std::string id = get_from_multimap(view_multimap, "DisplayFrameName");
307  std::cout << "will try to print " << id << std::endl;
308 
309  // And return the URL of the file:
310  out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
311  *out << "<?xml version=\"1.0\" ?>" << std::endl;
312  *out << "<fileURL>" << std::endl;
313  *out << getContextURL() + "/temporary/" + id + ".gif" << std::endl;
314  *out << "</fileURL>" << std::endl;
315 
316 }
void add(std::string name, MonitorElement *me_p)
add the ME named &quot;name&quot; to the map
Definition: ME_MAP.cc:9
std::string getContextURL()
Definition: WebInterface.h:44
tuple out
Definition: dbtoconf.py:99
Definition: ME_MAP.h:11
DQMStore * dqmStore_
Definition: WebInterface.h:34
std::string get_from_multimap(std::multimap< std::string, std::string > &mymap, std::string key)
Definition: WebInterface.cc:21
tuple cout
Definition: gather_cfg.py:121
std::string WebInterface::get_from_multimap ( std::multimap< std::string, std::string > &  mymap,
std::string  key 
)

Definition at line 21 of file WebInterface.cc.

22 {
23  std::multimap<std::string, std::string>::iterator it;
24  it = mymap.find(key);
25  if (it != mymap.end())
26  {
27  return (it->second);
28  }
29  return "";
30 }
list key
Definition: combine.py:13
std::string WebInterface::getApplicationURL ( )
inline

Definition at line 45 of file WebInterface.h.

References appURL.

45 { return appURL; }
std::string appURL
Definition: WebInterface.h:27
std::string WebInterface::getContextURL ( )
inline

Definition at line 44 of file WebInterface.h.

References exeURL.

44 { return exeURL; }
std::string exeURL
Definition: WebInterface.h:26
virtual void WebInterface::handleCustomRequest ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
inlinevirtual

Definition at line 50 of file WebInterface.h.

51  {
52  };
void WebInterface::handleRequest ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)

Definition at line 32 of file WebInterface.cc.

References recoMuon::in, and dbtoconf::out.

33 {
36 
37  // dispatch any messages:
39 }
virtual void handleCustomRequest(xgi::Input *in, xgi::Output *out)
Definition: WebInterface.h:50
void dispatchMessages(xgi::Output *out)
tuple out
Definition: dbtoconf.py:99
void handleStandardRequest(xgi::Input *in, xgi::Output *out)
Definition: WebInterface.cc:55
MessageDispatcher msg_dispatcher
Definition: WebInterface.h:30
void WebInterface::handleStandardRequest ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)

Definition at line 55 of file WebInterface.cc.

References get_from_multimap(), recoMuon::in, dbtoconf::out, CgiReader::read_form(), and matplotRender::reader.

56 {
57  std::multimap<std::string, std::string> request_multimap;
59  reader.read_form(request_multimap);
60 
61  // get the string that identifies the request:
62  std::string requestID = get_from_multimap(request_multimap, "RequestID");
63 
64  if (requestID == "Configure") Configure(in, out);
65  if (requestID == "Open") Open(in, out);
66 // if (requestID == "Subscribe") Subscribe(in, out);
67 // if (requestID == "Unsubscribe") Unsubscribe(in, out);
68  if (requestID == "ContentsOpen") ContentsOpen(in, out);
69  if (requestID == "Draw") DrawGif(in, out);
70 }
void Open(xgi::Input *in, xgi::Output *out)
Answer navigator requests.
Definition: WebInterface.cc:83
void DrawGif(xgi::Input *in, xgi::Output *out)
Answers viewer requests.
tuple out
Definition: dbtoconf.py:99
std::string get_from_multimap(std::multimap< std::string, std::string > &mymap, std::string key)
Definition: WebInterface.cc:21
void Configure(xgi::Input *in, xgi::Output *out)
Answers connection configuration requests.
Definition: WebInterface.cc:72
void ContentsOpen(xgi::Input *in, xgi::Output *out)
Answers ContentViewer requests.
void WebInterface::Open ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)

Answer navigator requests.

Definition at line 83 of file WebInterface.cc.

References gather_cfg::cout, cond::rpcobimon::current, get_from_multimap(), recoMuon::in, dbtoconf::out, CgiReader::read_form(), and matplotRender::reader.

84 {
85  std::multimap<std::string, std::string> nav_map;
86 
88  reader.read_form(nav_map);
89 
90  std::string to_open = get_from_multimap(nav_map, "Open");
91  std::string current = get_from_multimap(nav_map, "Current");
92 
93  // if the user does not want to go to the top directory...
94  if (to_open != "top")
95  {
96  // ...and if the current directory is not the top...
97  if (current != "top")
98  {
99  // ...and if we don't want to go one directory up...
100  if (to_open != "..")
101  {
102  // ...then we need to add the current directory at the beginning of the to_open string
103  to_open = current + "/" + to_open;
104  }
105  }
106  }
107 
108 
109  std::cout << "will try to open " << to_open << std::endl;
110  if (dqmStore_)
111  {
112  if (to_open == "top")
113  {
115  }
116  else if (to_open == "..")
117  {
118  dqmStore_->goUp();
119  }
120  else
121  {
122  dqmStore_->setCurrentFolder(to_open);
123  }
125  }
126  else
127  {
128  std::cout << "no DQMStore object, subscription to " << to_open << " failed!" << std::endl;
129  }
130 
131 }
tuple out
Definition: dbtoconf.py:99
DQMStore * dqmStore_
Definition: WebInterface.h:34
std::string get_from_multimap(std::multimap< std::string, std::string > &mymap, std::string key)
Definition: WebInterface.cc:21
void goUp(void)
equivalent to &quot;cd ..&quot;
Definition: DQMStore.cc:440
tuple cout
Definition: gather_cfg.py:121
void printNavigatorXML(std::string directory, xgi::Output *out)
Outputs the subdirectories and files of &quot;directory&quot;. Called by any of the above three.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
const std::string & pwd(void) const
Definition: DQMStore.cc:401
void WebInterface::printContentViewerXML ( std::string  current,
xgi::Output out 
)

Definition at line 239 of file WebInterface.cc.

References gather_cfg::cout, dqmStore_, ContentReader::give_files(), ContentReader::give_subdirs(), and matplotRender::reader.

240 {
241  if (!(dqmStore_))
242  {
243  std::cout << "NO GUI!!!" << std::endl;
244  return;
245  }
246 
247  out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
248 
249  *out << "<?xml version=\"1.0\" ?>" << std::endl;
250 
251  *out << "<contentViewer>" << std::endl;
252 
253  *out << "<current>" << current << "</current>" << std::endl;
254 
256 
257  std::list<std::string>::iterator it;
258 
259  std::list<std::string> open_l;
260  reader.give_subdirs(current, open_l, "SuperUser");
261  for (it = open_l.begin(); it != open_l.end(); it++)
262  *out << "<open>" << *it << "</open>" << std::endl;
263 
264  std::list<std::string> view_l;
265  reader.give_files(current, view_l, true);
266  for (it = view_l.begin(); it != view_l.end(); it++)
267  *out << "<view>" << *it << "</view>" << std::endl;
268 
269  *out << "</contentViewer>" << std::endl;
270 }
tuple out
Definition: dbtoconf.py:99
DQMStore * dqmStore_
Definition: WebInterface.h:34
tuple cout
Definition: gather_cfg.py:121
void WebInterface::printMap ( ME_MAP  view_map,
std::string  id 
)

Definition at line 318 of file WebInterface.cc.

References ME_MAP::print().

319 {
320  view_map.print(id);
321 }
void print(std::string name)
print the map into a gif named &quot;name&quot;
Definition: ME_MAP.cc:23
void WebInterface::printMessagesXML ( xgi::Output out)

Answers Messages requests.

void WebInterface::printNavigatorXML ( std::string  directory,
xgi::Output out 
)

Outputs the subdirectories and files of "directory". Called by any of the above three.

Definition at line 133 of file WebInterface.cc.

References gather_cfg::cout, dqmStore_, ContentReader::give_files(), ContentReader::give_subdirs(), and matplotRender::reader.

134 {
135  if (!dqmStore_)
136  {
137  std::cout << "NO GUI!!!" << std::endl;
138  return;
139  }
140 
141  out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml");
142 
143  *out << "<?xml version=\"1.0\" ?>" << std::endl;
144 
145  *out << "<navigator>" << std::endl;
146 
147  *out << "<current>" << current << "</current>" << std::endl;
148 
150 
151  std::list<std::string>::iterator it;
152 
153  std::list<std::string> open_l;
154  reader.give_subdirs(current, open_l, "SuperUser");
155  for (it = open_l.begin(); it != open_l.end(); it++)
156  *out << "<open>" << *it << "</open>" << std::endl;
157 
158  std::list<std::string> subscribe_l;
159  reader.give_files(current, subscribe_l, false);
160  for (it = subscribe_l.begin(); it != subscribe_l.end(); it++)
161  *out << "<subscribe>" << *it << "</subscribe>" << std::endl;
162 
163  std::list<std::string> unsubscribe_l;
164  reader.give_files(current, unsubscribe_l, true);
165  for (it = unsubscribe_l.begin(); it != unsubscribe_l.end(); it++)
166  *out << "<unsubscribe>" << *it << "</unsubscribe>" << std::endl;
167 
168  *out << "</navigator>" << std::endl;
169 
170 
171  std::cout << "<?xml version=\"1.0\" ?>" << std::endl;
172 
173  std::cout << "<navigator>" << std::endl;
174 
175  std::cout << "<current>" << current << "</current>" << std::endl;
176 
177  for (it = open_l.begin(); it != open_l.end(); it++)
178  std::cout << "<open>" << *it << "</open>" << std::endl;
179 
180  for (it = subscribe_l.begin(); it != subscribe_l.end(); it++)
181  std::cout << "<subscribe>" << *it << "</subscribe>" << std::endl;
182 
183  for (it = unsubscribe_l.begin(); it != unsubscribe_l.end(); it++)
184  std::cout << "<unsubscribe>" << *it << "</unsubscribe>" << std::endl;
185 
186  std::cout << "</navigator>" << std::endl;
187 
188 }
tuple out
Definition: dbtoconf.py:99
DQMStore * dqmStore_
Definition: WebInterface.h:34
tuple cout
Definition: gather_cfg.py:121
void WebInterface::sendMessage ( std::string  the_title,
std::string  the_text,
MessageType  the_type 
)

Adds messages to the message dispatcher.

Definition at line 323 of file WebInterface.cc.

References MessageDispatcher::add(), lumiQueryAPI::msg, and msg_dispatcher.

324 {
325  Message * msg = new Message(title, text, type);
326  msg_dispatcher.add(msg);
327 }
type
Definition: HCALResponse.h:22
tuple text
Definition: runonSM.py:42
void add(Message *new_message)
MessageDispatcher msg_dispatcher
Definition: WebInterface.h:30

Member Data Documentation

std::string WebInterface::appURL
private

Definition at line 27 of file WebInterface.h.

Referenced by getApplicationURL(), and WebInterface().

std::multimap<std::string, std::string> WebInterface::conf_map
private

Definition at line 28 of file WebInterface.h.

DQMStore* WebInterface::dqmStore_
protected

Definition at line 34 of file WebInterface.h.

Referenced by printContentViewerXML(), printNavigatorXML(), and WebInterface().

std::string WebInterface::exeURL
private

Definition at line 26 of file WebInterface.h.

Referenced by getContextURL(), and WebInterface().

MessageDispatcher WebInterface::msg_dispatcher
private

Definition at line 30 of file WebInterface.h.

Referenced by sendMessage().

WebPage* WebInterface::page_p
protected

Definition at line 35 of file WebInterface.h.

Referenced by add().