Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:50

0001 #ifndef LMFSEQDAT_H
0002 #define LMFSEQDAT_H
0003 
0004 /*
0005  Last updated by  Giovanni.Organtini@roma1.infn.it 2010
0006  */
0007 
0008 #include <map>
0009 
0010 #include "OnlineDB/EcalCondDB/interface/LMFUnique.h"
0011 #include "OnlineDB/EcalCondDB/interface/LMFColor.h"
0012 #include "OnlineDB/EcalCondDB/interface/RunIOV.h"
0013 
0014 class LMFSeqDat : public LMFUnique {
0015 public:
0016   friend class EcalCondDBInterface;
0017 
0018   LMFSeqDat();
0019   LMFSeqDat(oracle::occi::Environment *env, oracle::occi::Connection *conn);
0020   LMFSeqDat(EcalDBConnection *c);
0021   ~LMFSeqDat() override;
0022 
0023   // Methods for user data
0024   LMFSeqDat &setRunIOV(const RunIOV &iov);
0025   LMFSeqDat &setSequenceNumber(int n) {
0026     setInt("seq_num", n);
0027     return *this;
0028   }
0029   LMFSeqDat &setSequenceStart(const Tm &start) {
0030     setString("seq_start", start.str());
0031     return *this;
0032   }
0033   LMFSeqDat &setSequenceStop(const Tm &end) {
0034     setString("seq_stop", end.str());
0035     return *this;
0036   }
0037   LMFSeqDat &setVersions(int vmin, int vmax) {
0038     setVmin(vmin);
0039     setVmax(vmax);
0040     return *this;
0041   }
0042 
0043   RunIOV getRunIOV() const;
0044   int getSequenceNumber() const { return getInt("seq_num"); }
0045   Tm getSequenceStart() const {
0046     Tm t;
0047     t.setToString(getString("seq_start"));
0048     return t;
0049   }
0050   Tm getSequenceStop() const;
0051   int getVmin() const { return getInt("vmin"); }
0052   int getVmax() const { return getInt("vmax"); }
0053 
0054   bool isValid() const override;
0055   // Operators
0056   bool operator==(const LMFSeqDat &m) const {
0057     return (getSequenceNumber() == m.getSequenceNumber() && getRunIOV() == m.getRunIOV() &&
0058             getSequenceStart() == m.getSequenceStart() && getSequenceStop() == m.getSequenceStop() &&
0059             getVmin() == m.getVmin() && getVmax() == m.getVmax());
0060   }
0061 
0062   bool operator!=(const LMFSeqDat &m) const { return !(*this == m); }
0063   std::map<int, LMFSeqDat> fetchByRunIOV(RunIOV &iov);
0064   std::map<int, LMFSeqDat> fetchByRunIOV(RunIOV &iov, const LMFColor &col);
0065   LMFSeqDat fetchByRunIOV(RunIOV &iov, int seq_num) { return fetchByRunIOV(iov)[seq_num]; }
0066   std::map<int, LMFSeqDat> fetchByRunNumber(int runno);
0067   LMFSeqDat fetchByRunNumber(int runno, int seq_num) { return fetchByRunNumber(runno)[seq_num]; }
0068   LMFSeqDat fetchByRunNumber(int runno, const Tm &taken_at);
0069   LMFSeqDat fetchByRunNumber(int runno, std::string taken_at);
0070   LMFSeqDat fetchLast();
0071   RunIOV fetchLastRun();
0072 
0073 private:
0074   RunIOV m_runIOV;
0075 
0076   void setVmin(int v) { setInt("vmin", v); }
0077   void setVmax(int v) { setInt("vmax", v); }
0078   std::string fetchIdSql(Statement *stmt) override;
0079   std::string setByIDSql(Statement *stmt, int id) override;
0080   std::string writeDBSql(Statement *stmt) override;
0081   void getParameters(ResultSet *rset) override;
0082 
0083   void fetchParentIDs() noexcept(false) override;
0084   std::map<int, LMFSeqDat> fetchByRunIOV(const std::vector<std::string> &par,
0085                                          std::string sql,
0086                                          std::string method) noexcept(false);
0087   std::map<int, LMFSeqDat> fetchByRunIOV(int par, std::string sql, std::string method) noexcept(false);
0088   std::map<int, LMFSeqDat> fetchByRunIOV(std::string sql, std::string method) noexcept(false);
0089 };
0090 
0091 #endif