00001 #ifndef CondCore_DBCommon_SequenceManager_h 00002 #define CondCore_DBCommon_SequenceManager_h 00003 00004 #include <string> 00005 #include <map> 00006 // 00007 // Package: DBCommon 00008 // Class : SequenceManager 00009 // 00013 // 00014 // Author: Zhen Xie 00015 // 00016 namespace coral{ 00017 class ISchema; 00018 class AttributeList; 00019 } 00020 namespace cond { 00021 class CoralTransaction; 00022 class SequenceManager { 00023 public: 00025 SequenceManager(cond::CoralTransaction& coraldb, 00026 const std::string& sequenceTableName); 00027 00029 ~SequenceManager(); 00030 00032 unsigned long long incrementId( const std::string& reftableName ); 00033 00035 void updateId( const std::string& reftableName, 00036 unsigned long long lastId ); 00037 00039 void clear(); 00040 00042 bool existSequencesTable(); 00043 00045 void createSequencesTable(); 00046 00047 private: 00048 00050 bool lockEntry( coral::ISchema& schema, 00051 const std::string& reftableName, 00052 unsigned long long& lastId ); 00053 void init(); 00054 private: 00056 cond::CoralTransaction& m_coraldb; 00057 00059 std::string m_sequenceTableName; 00060 00062 std::map< std::string, unsigned long long > m_tableToId; 00063 00065 bool m_sequenceTableExists; 00066 00068 std::string m_whereClause; 00069 00071 coral::AttributeList* m_whereData; 00072 00074 std::string m_setClause; 00075 bool m_started; 00076 }; 00077 }//ns cond 00078 #endif