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