CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/CondCore/DBCommon/interface/SequenceManager.h

Go to the documentation of this file.
00001 #ifndef CondCore_DBCommon_SequenceManager_h
00002 #define CondCore_DBCommon_SequenceManager_h
00003 
00004 #include <string>
00005 #include <map>
00006 #include "CondCore/DBCommon/interface/DbSession.h"
00007 //
00008 // Package:     DBCommon
00009 // Class  :     SequenceManager
00010 // 
00014 //
00015 // Author:      Zhen Xie
00016 //
00017 namespace coral{
00018   class ISchema;
00019   class AttributeList;  
00020 }
00021 namespace cond {  
00022   class CoralTransaction;
00023   class SequenceManager {
00024   public:
00026     SequenceManager(cond::DbSession& coraldb,
00027                     const std::string& sequenceTableName);
00028 
00030     ~SequenceManager();
00031 
00033     unsigned long long incrementId( const std::string& reftableName );
00034 
00036     void updateId( const std::string& reftableName, 
00037                    unsigned long long lastId );
00038 
00040     void clear();
00041     
00043     bool existSequencesTable();
00044 
00046     void createSequencesTable();
00047     
00048   private:
00049 
00051     bool lockEntry( coral::ISchema& schema,
00052                     const std::string& reftableName,
00053                     unsigned long long& lastId );
00054     void init();
00055     private:
00057       cond::DbSession m_coraldb;
00058 
00060       std::string m_sequenceTableName;
00061 
00063       std::map< std::string, unsigned long long > m_tableToId;
00064       
00066       bool m_sequenceTableExists;
00067 
00069       std::string m_whereClause;
00070 
00072       coral::AttributeList* m_whereData;
00073 
00075       std::string m_setClause;
00076       bool m_started;
00077     };
00078 }//ns cond
00079 #endif