CMS 3D CMS Logo

evf::ParameterSetRetriever Class Reference

#include <EventFilter/Utilities/interface/ParameterSetRetriever.h>

List of all members.

Public Member Functions

std::string getAsString () const
std::string getHostString (const std::string &in) const
 ParameterSetRetriever (const std::string &in)

Private Attributes

std::string pset

Static Private Attributes

static const std::string dbheading = "db:"
static const std::string fileheading = "file:"
static const std::string webheading = "https://"


Detailed Description

Definition at line 8 of file ParameterSetRetriever.h.


Constructor & Destructor Documentation

evf::ParameterSetRetriever::ParameterSetRetriever ( const std::string &  in  ) 

Definition at line 23 of file ParameterSetRetriever.cc.

References evf::SquidNet::check(), dbheading, error, fileheading, EgammaValidation_cff::filename, getHostString(), parsecf::pyparsing::line(), alivecheck_mergeAndRegister::msg, NULL, pset, webheading, and evf::write_data().

00024   {
00025     using std::string;
00026     using std::ostringstream; 
00027     using std::ifstream; 
00028 
00029 
00030 
00031     if (fileheading==in.substr(0,fileheading.size()))
00032       { 
00033         string filename=in.substr(fileheading.size());
00034         edm::LogInfo("psetRetriever")<<"filename is --> "<<filename<<" <--";
00035       
00036         string   line;
00037         ifstream configFile(filename.c_str());
00038         while(std::getline(configFile,line)) {
00039           pset+=line;
00040           pset+="\n";
00041         }
00042       }
00043     else if (webheading==in.substr(0,webheading.size()))
00044       {
00045         string hostname = getHostString(in);
00046         SquidNet sn(3128,"https://localhost:8000/RELEASE-NOTES.txt");    
00047         edm::LogInfo("psetRetriever")<<"Using cfg from " << in;
00048         CURL* han = curl_easy_init();
00049         if(han==0)
00050           {
00051             XCEPT_RAISE(evf::Exception,"could not create handle for web ParameterSet");     
00052           }
00053 
00054         struct curl_slist *headers=NULL; /* init to NULL is important */
00055         headers = curl_slist_append(headers, "Pragma:");
00056         curl_easy_setopt(han, CURLOPT_HTTPHEADER, headers);
00057         char error[CURL_ERROR_SIZE];
00058         if(sn.check())
00059           curl_easy_setopt(han, CURLOPT_PROXY, "localhost:3128");
00060 
00061         curl_easy_setopt(han, CURLOPT_URL, hostname.c_str());
00062         curl_easy_setopt(han, CURLOPT_VERBOSE);
00063         curl_easy_setopt(han, CURLOPT_NOSIGNAL);
00064         //      curl_easy_setopt(han, CURLOPT_TIMEOUT, 60.0L);
00065 
00066         curl_easy_setopt(han, CURLOPT_WRITEFUNCTION, &write_data);
00067         curl_easy_setopt(han, CURLOPT_WRITEDATA, &pset);
00068         curl_easy_setopt(han, CURLOPT_ERRORBUFFER, error);
00069         int success = curl_easy_perform(han);
00070         curl_slist_free_all(headers); /* free the header list */
00071         curl_easy_cleanup(han);
00072 
00073         if(success != 0)
00074           {
00075             ostringstream msg;
00076             msg <<  "could not get config from url " << in << " error #" 
00077                 << success << " " << error;
00078             XCEPT_RAISE(evf::Exception,msg.str().c_str());
00079           }
00080 
00081       }
00082     else if (dbheading==in.substr(0,dbheading.size()))
00083       {
00084         XCEPT_RAISE(evf::Exception,"db access for ParameterSet not yet implemented");
00085       } 
00086     else
00087       {
00088         edm::LogInfo("psetRetriever")<<"Using string cfg from RunControl or XML";
00089         pset = in;
00090       }
00091   }


Member Function Documentation

std::string evf::ParameterSetRetriever::getAsString (  )  const

Definition at line 95 of file ParameterSetRetriever.cc.

References pset.

Referenced by stor::StorageManager::configureAction(), and evf::FUEventProcessor::initEventProcessor().

00096   {
00097     return pset;
00098   }

std::string evf::ParameterSetRetriever::getHostString ( const std::string &  in  )  const

Definition at line 99 of file ParameterSetRetriever.cc.

References cmsBenchmark::host, path(), and webheading.

Referenced by ParameterSetRetriever().

00100   {
00101     using std::string;
00102     string innohttps = in.substr(webheading.size());
00103     string::size_type pos = innohttps.find(':',0);
00104     string host = innohttps.substr(0,pos);
00105     string path = innohttps.substr(pos);
00106     struct hostent *heb = gethostbyname(host.c_str());    
00107     struct hostent *he = gethostbyaddr(heb->h_addr_list[0], heb->h_length, heb->h_addrtype);
00108     string completehost = "https://";
00109     completehost += he->h_name;
00110     completehost += path;
00111     return completehost;
00112   }


Member Data Documentation

const std::string evf::ParameterSetRetriever::dbheading = "db:" [static, private]

Definition at line 17 of file ParameterSetRetriever.h.

Referenced by ParameterSetRetriever().

const std::string evf::ParameterSetRetriever::fileheading = "file:" [static, private]

Definition at line 16 of file ParameterSetRetriever.h.

Referenced by ParameterSetRetriever().

std::string evf::ParameterSetRetriever::pset [private]

Definition at line 15 of file ParameterSetRetriever.h.

Referenced by getAsString(), and ParameterSetRetriever().

const std::string evf::ParameterSetRetriever::webheading = "https://" [static, private]

Definition at line 18 of file ParameterSetRetriever.h.

Referenced by getHostString(), and ParameterSetRetriever().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:46:49 2009 for CMSSW by  doxygen 1.5.4