Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-06-17 01:30:03

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 constexpr std::string_view tableName() { return RUN_NUMBER::tableName(); }
0022         static constexpr auto fullyQualifiedName_ =
0023             condcore_detail::addMax<RUN_NUMBER::fullyQualifiedName().size()>(RUN_NUMBER::fullyQualifiedName());
0024         static constexpr std::string_view fullyQualifiedName() { return std::string_view(fullyQualifiedName_.data()); }
0025       };
0026 
0027       struct MIN_RUN_NUMBER {
0028         typedef cond::Time_t type;
0029         static constexpr size_t size = 0;
0030         static constexpr std::string_view tableName() { return RUN_NUMBER::tableName(); }
0031         static constexpr auto fullyQualifiedName_ =
0032             condcore_detail::addMin<RUN_NUMBER::fullyQualifiedName().size()>(RUN_NUMBER::fullyQualifiedName());
0033         static constexpr std::string_view fullyQualifiedName() { return std::string_view(fullyQualifiedName_.data()); }
0034       };
0035 
0036       struct MIN_START_TIME {
0037         typedef boost::posix_time::ptime type;
0038         static constexpr size_t size = 0;
0039         static constexpr std::string_view tableName() { return START_TIME::tableName(); }
0040         static constexpr auto fullyQualifiedName_ =
0041             condcore_detail::addMin<START_TIME::fullyQualifiedName().size()>(START_TIME::fullyQualifiedName());
0042         static constexpr std::string_view fullyQualifiedName() { return std::string_view(fullyQualifiedName_.data()); }
0043       };
0044 
0045       class Table : public IRunInfoTable {
0046       public:
0047         explicit Table(coral::ISchema& schema);
0048         ~Table() override {}
0049         bool exists() override;
0050         void create() override;
0051         bool select(cond::Time_t runNumber, boost::posix_time::ptime& start, boost::posix_time::ptime& end) override;
0052         cond::Time_t getLastInserted(boost::posix_time::ptime& start, boost::posix_time::ptime& end) override;
0053         bool getInclusiveRunRange(
0054             cond::Time_t lower,
0055             cond::Time_t upper,
0056             std::vector<std::tuple<cond::Time_t, boost::posix_time::ptime, boost::posix_time::ptime> >& runData)
0057             override;
0058         bool getInclusiveTimeRange(
0059             const boost::posix_time::ptime& lower,
0060             const boost::posix_time::ptime& upper,
0061             std::vector<std::tuple<cond::Time_t, boost::posix_time::ptime, boost::posix_time::ptime> >& runData)
0062             override;
0063         void insertOne(cond::Time_t runNumber,
0064                        const boost::posix_time::ptime& start,
0065                        const boost::posix_time::ptime& end) override;
0066         void insert(const std::vector<std::tuple<cond::Time_t, boost::posix_time::ptime, boost::posix_time::ptime> >&
0067                         runs) override;
0068         void updateEnd(cond::Time_t runNumber, const boost::posix_time::ptime& end) override;
0069 
0070       private:
0071         coral::ISchema& m_schema;
0072       };
0073     }
0074 
0075     class RunInfoSchema : public IRunInfoSchema {
0076     public:
0077       explicit RunInfoSchema(coral::ISchema& schema);
0078       ~RunInfoSchema() override {}
0079       bool exists() override;
0080       bool create() override;
0081       IRunInfoTable& runInfoTable() override;
0082 
0083     private:
0084       RUN_INFO::Table m_runInfoTable;
0085     };
0086 
0087   }  // namespace persistency
0088 }  // namespace cond
0089 #endif