CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PopConSourceHandler.h
Go to the documentation of this file.
1 #ifndef PopConSourceHandler_H
2 #define PopConSourceHandler_H
3 
6 
7 #include <algorithm>
8 #include <functional>
9 #include <memory>
10 #include <string>
11 #include <vector>
12 
13 namespace cond {
14  class Summary;
15 }
16 
18 
19 namespace popcon {
20 
29  template <class T>
31  public:
32  typedef T value_type;
33  typedef PopConSourceHandler<T> self;
35 
36  typedef std::map<Time_t, std::shared_ptr<T> > Container;
37  typedef std::unique_ptr<T> Ref;
38 
39  PopConSourceHandler() : m_tagInfo(nullptr), m_logDBEntry(nullptr) {}
40 
41  virtual ~PopConSourceHandler() {}
42 
43  cond::TagInfo_t const& tagInfo() const { return *m_tagInfo; }
44 
45  // return last paylod of the tag
47 
48  // return last successful log entry for the tag in question
49  cond::LogDBEntry_t const& logDBEntry() const { return *m_logDBEntry; }
50 
51  // FIX ME
53  cond::TagInfo_t const& tagInfo,
56  m_tagInfo = &tagInfo;
58  }
59 
60  // this is the only mandatory interface
61  std::pair<Container const*, std::string const> operator()(const cond::persistency::Session& session,
62  cond::TagInfo_t const& tagInfo,
63  cond::LogDBEntry_t const& logDBEntry) const {
64  const_cast<self*>(this)->initialize(session, tagInfo, logDBEntry);
65  return std::pair<Container const*, std::string const>(&(const_cast<self*>(this)->returnData()), userTextLog());
66  }
67 
68  Container const& returnData() {
69  getNewObjects();
70  for (auto item : m_to_transfer) {
71  std::shared_ptr<T> payload(item.first);
72  m_iovs.insert(std::make_pair(item.second, payload));
73  }
74  return m_iovs;
75  }
76 
77  std::string const& userTextLog() const { return m_userTextLog; }
78 
79  //Implement to fill m_to_transfer vector and m_userTextLog
80  //use getOfflineInfo to get the contents of offline DB
81  virtual void getNewObjects() = 0;
82 
83  // return a string identifing the source
84  virtual std::string id() const = 0;
85 
86  protected:
88 
89  private:
91 
93 
95 
96  protected:
97  //vector of payload objects and iovinfo to be transferred
98  //class looses ownership of payload object
99  std::vector<std::pair<T*, Time_t> > m_to_transfer;
100 
102 
104  };
105 } // namespace popcon
106 #endif
cond::persistency::Session & dbSession() const
std::string const & userTextLog() const
virtual void getNewObjects()=0
Iov_t lastInterval
Definition: Types.h:73
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:213
cond::LogDBEntry_t const * m_logDBEntry
unsigned long long Time_t
Definition: Time.h:14
std::vector< std::pair< T *, Time_t > > m_to_transfer
cond::LogDBEntry_t const & logDBEntry() const
void initialize(const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
Hash payloadId
Definition: Types.h:55
Container const & returnData()
std::map< Time_t, std::shared_ptr< T > > Container
cond::TagInfo_t const * m_tagInfo
virtual std::string id() const =0
std::pair< Container const *, std::string const > operator()(const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
cond::persistency::Session m_session
long double T
cond::TagInfo_t const & tagInfo() const