Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:25

0001 #ifndef CondCore_CondDB_RunInfoSchema_h
0002 #define CondCore_CondDB_RunInfoSchema_h
0003 
0004 #include "DbCore.h"
0005 #include "IDbSchema.h"
0006 //
0007 #include <boost/date_time/posix_time/posix_time.hpp>
0008 
0009 namespace cond {
0010 
0011   namespace persistency {
0012 
0013     conddb_table(RUN_INFO) {
0014       conddb_column(RUN_NUMBER, cond::Time_t);
0015       conddb_column(START_TIME, boost::posix_time::ptime);
0016       conddb_column(END_TIME, boost::posix_time::ptime);
0017 
0018       struct MAX_RUN_NUMBER {
0019         typedef cond::Time_t type;
0020         static constexpr size_t size = 0;
0021         static std::string tableName() { return RUN_NUMBER::tableName(); }
0022         static std::string fullyQualifiedName() { return "MAX(" + RUN_NUMBER::fullyQualifiedName() + ")"; }
0023       };
0024 
0025       struct MIN_RUN_NUMBER {
0026         typedef cond::Time_t type;
0027         static constexpr size_t size = 0;
0028         static std::string tableName() { return RUN_NUMBER::tableName(); }
0029         static std::string fullyQualifiedName() { return "MIN(" + RUN_NUMBER::fullyQualifiedName() + ")"; }
0030       };
0031 
0032       struct MIN_START_TIME {
0033         typedef boost::posix_time::ptime type;
0034         static constexpr size_t size = 0;
0035         static std::string tableName() { return START_TIME::tableName(); }
0036         static std::string fullyQualifiedName() { return "MIN(" + START_TIME::fullyQualifiedName() + ")"; }
0037       };
0038 
0039       class Table : public IRunInfoTable {
0040       public:
0041         explicit Table(coral::ISchema& schema);
0042         ~Table() override {}
0043         bool exists() override;
0044         void create() override;
0045         bool select(cond::Time_t runNumber, boost::posix_time::ptime& start, boost::posix_time::ptime& end) override;
0046         cond::Time_t getLastInserted(boost::posix_time::ptime& start, boost::posix_time::ptime& end) override;
0047         bool getInclusiveRunRange(
0048             cond::Time_t lower,
0049             cond::Time_t upper,
0050             std::vector<std::tuple<cond::Time_t, boost::posix_time::ptime, boost::posix_time::ptime> >& runData)
0051             override;
0052         bool getInclusiveTimeRange(
0053             const boost::posix_time::ptime& lower,
0054             const boost::posix_time::ptime& upper,
0055             std::vector<std::tuple<cond::Time_t, boost::posix_time::ptime, boost::posix_time::ptime> >& runData)
0056             override;
0057         void insertOne(cond::Time_t runNumber,
0058                        const boost::posix_time::ptime& start,
0059                        const boost::posix_time::ptime& end) override;
0060         void insert(const std::vector<std::tuple<cond::Time_t, boost::posix_time::ptime, boost::posix_time::ptime> >&
0061                         runs) override;
0062         void updateEnd(cond::Time_t runNumber, const boost::posix_time::ptime& end) override;
0063 
0064       private:
0065         coral::ISchema& m_schema;
0066       };
0067     }
0068 
0069     class RunInfoSchema : public IRunInfoSchema {
0070     public:
0071       explicit RunInfoSchema(coral::ISchema& schema);
0072       ~RunInfoSchema() override {}
0073       bool exists() override;
0074       bool create() override;
0075       IRunInfoTable& runInfoTable() override;
0076 
0077     private:
0078       RUN_INFO::Table m_runInfoTable;
0079     };
0080 
0081   }  // namespace persistency
0082 }  // namespace cond
0083 #endif