#include <WebInterface.h>
Public Member Functions | |
void | add (std::string, WebElement *) |
Adds widgets to the page. | |
void | Configure (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception) |
Answers connection configuration requests. | |
void | ContentsOpen (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception) |
Answers ContentViewer requests. | |
virtual void | Default (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception) |
Answers requests by sending the webpage of the application. | |
void | DrawGif (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception) |
Answers viewer requests. | |
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. | |
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. | |
void | printNavigatorXML (std::string directory, xgi::Output *out) |
Outputs the subdirectories and files of "directory". Called by any of the above three. | |
void | sendMessage (std::string the_title, std::string the_text, MessageType the_type) |
Adds messages to the message dispatcher. | |
WebInterface (std::string _exeURL, std::string _appURL) | |
virtual | ~WebInterface () |
Protected Attributes | |
DQMStore * | dqmStore_ |
WebPage * | page_p |
Private Attributes | |
std::string | appURL |
std::multimap< std::string, std::string > | conf_map |
std::string | exeURL |
MessageDispatcher | msg_dispatcher |
Definition at line 21 of file WebInterface.h.
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.
virtual WebInterface::~WebInterface | ( | ) | [inline, virtual] |
Definition at line 40 of file WebInterface.h.
{ }
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.
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(), matplotRender::reader, and AlCaHLTBitMon_QueryRunRegistry::string.
{ CgiReader reader(in); reader.read_form(conf_map); std::string host = get_from_multimap(conf_map, "Hostname"); std::string port = get_from_multimap(conf_map, "Port"); std::string clientname = get_from_multimap(conf_map, "Clientname"); }
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(), matplotRender::reader, and AlCaHLTBitMon_QueryRunRegistry::string.
{ std::multimap<std::string, std::string> nav_map; CgiReader reader(in); reader.read_form(nav_map); std::string to_open = get_from_multimap(nav_map, "Open"); std::string current = get_from_multimap(nav_map, "Current"); // if the user does not want to go to the top directory... if (to_open != "top") { // ...and if the current directory is not the top... if (current != "top") { // ...and if we don't want to go one directory up... if (to_open != "..") { // ...then we need to add the current directory at the beginning of the to_open string to_open = current + "/" + to_open; } } } std::cout << "will try to open " << to_open << std::endl; if (dqmStore_) { if (to_open == "top") { dqmStore_->cd(); } else if (to_open == "..") { dqmStore_->goUp(); } else { dqmStore_->setCurrentFolder(to_open); } printContentViewerXML(dqmStore_->pwd(), out); } else { std::cout << "no DQMStore object, subscription to " << to_open << " failed!" << std::endl; } }
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().
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(), AlCaHLTBitMon_QueryRunRegistry::string, and pileupCalc::upper.
{ std::multimap<std::string, std::string> view_multimap; ME_MAP view_map; CgiReader cgi_reader(in); cgi_reader.read_form(view_multimap); std::string current = get_from_multimap(view_multimap, "Current"); if (dqmStore_) { std::cout << "The DQMStore pointer is empty!" << std::endl; return; } ContentReader con_reader(dqmStore_); std::multimap<std::string,std::string>::iterator lower = view_multimap.lower_bound("View"); std::multimap<std::string,std::string>::iterator upper = view_multimap.upper_bound("View"); std::multimap<std::string,std::string>::iterator it; for (it = lower; it != upper; it++) { std::string name = it->second; MonitorElement *pointer = con_reader.give_ME(name); if (pointer != 0) { view_map.add(name, pointer); std::cout << "ADDING " << name << " TO view_map!!!" << std::endl; } } // Print the ME_map into a file std::string id = get_from_multimap(view_multimap, "DisplayFrameName"); std::cout << "will try to print " << id << std::endl; // And return the URL of the file: out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml"); *out << "<?xml version=\"1.0\" ?>" << std::endl; *out << "<fileURL>" << std::endl; *out << getContextURL() + "/temporary/" + id + ".gif" << std::endl; *out << "</fileURL>" << std::endl; }
std::string WebInterface::get_from_multimap | ( | std::multimap< std::string, std::string > & | mymap, |
std::string | key | ||
) |
Definition at line 21 of file WebInterface.cc.
{ std::multimap<std::string, std::string>::iterator it; it = mymap.find(key); if (it != mymap.end()) { return (it->second); } return ""; }
std::string WebInterface::getApplicationURL | ( | ) | [inline] |
std::string WebInterface::getContextURL | ( | ) | [inline] |
virtual void WebInterface::handleCustomRequest | ( | xgi::Input * | in, |
xgi::Output * | out | ||
) | throw (xgi::exception::Exception) [inline, virtual] |
Definition at line 50 of file WebInterface.h.
{ };
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.
{ handleStandardRequest(in, out); handleCustomRequest(in, out); // dispatch any messages: if (msg_dispatcher.hasAnyMessages()) msg_dispatcher.dispatchMessages(out); }
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(), matplotRender::reader, and AlCaHLTBitMon_QueryRunRegistry::string.
{ std::multimap<std::string, std::string> request_multimap; CgiReader reader(in); reader.read_form(request_multimap); // get the string that identifies the request: std::string requestID = get_from_multimap(request_multimap, "RequestID"); if (requestID == "Configure") Configure(in, out); if (requestID == "Open") Open(in, out); // if (requestID == "Subscribe") Subscribe(in, out); // if (requestID == "Unsubscribe") Unsubscribe(in, out); if (requestID == "ContentsOpen") ContentsOpen(in, out); if (requestID == "Draw") DrawGif(in, out); }
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(), matplotRender::reader, and AlCaHLTBitMon_QueryRunRegistry::string.
{ std::multimap<std::string, std::string> nav_map; CgiReader reader(in); reader.read_form(nav_map); std::string to_open = get_from_multimap(nav_map, "Open"); std::string current = get_from_multimap(nav_map, "Current"); // if the user does not want to go to the top directory... if (to_open != "top") { // ...and if the current directory is not the top... if (current != "top") { // ...and if we don't want to go one directory up... if (to_open != "..") { // ...then we need to add the current directory at the beginning of the to_open string to_open = current + "/" + to_open; } } } std::cout << "will try to open " << to_open << std::endl; if (dqmStore_) { if (to_open == "top") { dqmStore_->setCurrentFolder("/"); } else if (to_open == "..") { dqmStore_->goUp(); } else { dqmStore_->setCurrentFolder(to_open); } printNavigatorXML(dqmStore_->pwd(), out); } else { std::cout << "no DQMStore object, subscription to " << to_open << " failed!" << std::endl; } }
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.
{ if (!(dqmStore_)) { std::cout << "NO GUI!!!" << std::endl; return; } out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml"); *out << "<?xml version=\"1.0\" ?>" << std::endl; *out << "<contentViewer>" << std::endl; *out << "<current>" << current << "</current>" << std::endl; ContentReader reader(dqmStore_); std::list<std::string>::iterator it; std::list<std::string> open_l; reader.give_subdirs(current, open_l, "SuperUser"); for (it = open_l.begin(); it != open_l.end(); it++) *out << "<open>" << *it << "</open>" << std::endl; std::list<std::string> view_l; reader.give_files(current, view_l, true); for (it = view_l.begin(); it != view_l.end(); it++) *out << "<view>" << *it << "</view>" << std::endl; *out << "</contentViewer>" << std::endl; }
void WebInterface::printMap | ( | ME_MAP | view_map, |
std::string | id | ||
) |
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.
{ if (!dqmStore_) { std::cout << "NO GUI!!!" << std::endl; return; } out->getHTTPResponseHeader().addHeader("Content-Type", "text/xml"); *out << "<?xml version=\"1.0\" ?>" << std::endl; *out << "<navigator>" << std::endl; *out << "<current>" << current << "</current>" << std::endl; ContentReader reader(dqmStore_); std::list<std::string>::iterator it; std::list<std::string> open_l; reader.give_subdirs(current, open_l, "SuperUser"); for (it = open_l.begin(); it != open_l.end(); it++) *out << "<open>" << *it << "</open>" << std::endl; std::list<std::string> subscribe_l; reader.give_files(current, subscribe_l, false); for (it = subscribe_l.begin(); it != subscribe_l.end(); it++) *out << "<subscribe>" << *it << "</subscribe>" << std::endl; std::list<std::string> unsubscribe_l; reader.give_files(current, unsubscribe_l, true); for (it = unsubscribe_l.begin(); it != unsubscribe_l.end(); it++) *out << "<unsubscribe>" << *it << "</unsubscribe>" << std::endl; *out << "</navigator>" << std::endl; std::cout << "<?xml version=\"1.0\" ?>" << std::endl; std::cout << "<navigator>" << std::endl; std::cout << "<current>" << current << "</current>" << std::endl; for (it = open_l.begin(); it != open_l.end(); it++) std::cout << "<open>" << *it << "</open>" << std::endl; for (it = subscribe_l.begin(); it != subscribe_l.end(); it++) std::cout << "<subscribe>" << *it << "</subscribe>" << std::endl; for (it = unsubscribe_l.begin(); it != unsubscribe_l.end(); it++) std::cout << "<unsubscribe>" << *it << "</unsubscribe>" << std::endl; std::cout << "</navigator>" << std::endl; }
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.
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().
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().