CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PopCon.h
Go to the documentation of this file.
1 
2 #ifndef POPCON_POPCON_H
3 #define POPCON_POPCON_H
4 //
5 // Author: Vincenzo Innocente
6 // Original Author: Marcin BOGUSZ
7 //
8 
9 
12 
14 
16 
18 
19 #include <boost/bind.hpp>
20 #include <algorithm>
21 #include <vector>
22 #include <string>
23 
24 
25 #include<iostream>
26 
27 
28 namespace popcon {
29 
30 
31  /* Populator of the Condition DB
32  *
33  */
34  class PopCon {
35  public:
37  //typedef cond::Summary Summary;
38 
40 
41  virtual ~PopCon();
42 
43  template<typename Source>
44  void write(Source const & source);
45 
46  template<typename T>
47  void writeOne(T * payload, Time_t time);
48 
49 
50 
51 
52  private:
54  void finalize(Time_t lastTill);
55 
56 
57  private:
58 
60 
62 
64 
66 
67  int m_authSys;
68 
70 
72 
74 
76 
78 
80 
82 
83  bool m_close;
85 
86 
87  };
88 
89 
90  template<typename T>
91  void PopCon::writeOne(T * payload, Time_t time) {
92  m_dbService->writeOne(payload, time, m_record, m_LoggingOn);
93  }
94 
95 
96  template<typename Container>
98  typename Container::const_iterator it;
99  for (it = payloads.begin(); it != payloads.end(); it++)
100  edm::LogInfo ("PopCon")<< "Since " << (*it).time << std::endl;
101  }
102 
103 
104  template<typename Container>
106  if (payloads.empty()) return "Nothing to transfer;";
107  std::ostringstream s;
108  // when only 1 payload is transferred;
109  if ( payloads.size()==1)
110  s <<"Since " << (*payloads.begin()).time << "; " ;
111  else{
112  // when more than one payload are transferred;
113  s << "first payload Since " << (*payloads.begin()).time << ","
114  << "last payload Since " << (*payloads.rbegin()).time << ";" ;
115  }
116  return s.str();
117  }
118 
119 
120 
121 
122 
123  template<typename Source>
124  void PopCon::write(Source const & source) {
125  typedef typename Source::value_type value_type;
126  typedef typename Source::Container Container;
127 
128  std::pair<Container const *, std::string const> ret = source(initialize(),
130  Container const & payloads = *ret.first;
131 
132  if(m_LoggingOn)
133  m_dbService->setLogHeaderForRecord(m_record,source.id(),"PopCon v4.0; " +
134  displayIovHelper(payloads) + ret.second);
135  //m_dbService->setLogHeaderForRecord(m_record,source.id(),"PopCon v4.0; " +
136  // cond::userInfo() + displayIovHelper(payloads) + ret.second);
137 
138  displayHelper(payloads);
139 
140  std::for_each(payloads.begin(),payloads.end(),
141  boost::bind(&popcon::PopCon::writeOne<value_type>,this,
142  boost::bind(&Container::value_type::payload,_1),
143  boost::bind(&Container::value_type::time,_1)
144  )
145  );
146 
147 
148  finalize(payloads.empty() ? Time_t(0): payloads.back().time);
149  }
150 
151 }
152 
153 #endif // POPCON_POPCON_H
154 
155 
tuple ret
prodAgent to be discontinued
cond::LogDBEntry_t m_logDBEntry
Definition: PopCon.h:81
void finalize(Time_t lastTill)
Definition: PopCon.cc:85
Time_t m_lastTill
Definition: PopCon.h:84
bool m_close
Definition: PopCon.h:83
cond::Time_t Time_t
Definition: PopCon.h:36
std::string m_tag
Definition: PopCon.h:77
std::string m_record
Definition: PopCon.h:69
void write(Source const &source)
Definition: PopCon.h:124
cond::persistency::Session m_targetSession
Definition: PopCon.h:61
unsigned long long Time_t
Definition: Time.h:16
void writeOne(T *payload, Time_t time)
Definition: PopCon.h:91
void displayHelper(Container const &payloads)
Definition: PopCon.h:97
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
std::string m_targetConnectionString
Definition: PopCon.h:63
cond::TagInfo_t m_tagInfo
Definition: PopCon.h:79
PopCon(const edm::ParameterSet &pset)
Definition: PopCon.cc:10
void setLogHeaderForRecord(const std::string &recordName, const std::string &provenance, const std::string &usertext)
bool m_IsDestDbCheckedInQueryLog
Definition: PopCon.h:75
int m_authSys
Definition: PopCon.h:67
cond::persistency::Session initialize()
Definition: PopCon.cc:36
std::string m_authPath
Definition: PopCon.h:65
virtual ~PopCon()
Definition: PopCon.cc:29
const std::string displayIovHelper(Container const &payloads)
Definition: PopCon.h:105
long double T
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
std::string m_payload_name
Definition: PopCon.h:71
static std::string const source
Definition: EdmProvDump.cc:43
edm::Service< cond::service::PoolDBOutputService > m_dbService
Definition: PopCon.h:59
bool m_LoggingOn
Definition: PopCon.h:73