CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SequenceManager.h
Go to the documentation of this file.
1 #ifndef CondCore_DBCommon_SequenceManager_h
2 #define CondCore_DBCommon_SequenceManager_h
3 
4 #include <string>
5 #include <map>
7 //
8 // Package: DBCommon
9 // Class : SequenceManager
10 //
14 //
15 // Author: Zhen Xie
16 //
17 namespace coral{
18  class ISchema;
19  class AttributeList;
20 }
21 namespace cond {
22  class CoralTransaction;
24  public:
27  const std::string& sequenceTableName);
28 
31 
33  unsigned long long incrementId( const std::string& reftableName );
34 
36  void updateId( const std::string& reftableName,
37  unsigned long long lastId );
38 
40  void clear();
41 
43  bool existSequencesTable();
44 
46  void createSequencesTable();
47 
48  private:
49 
51  bool lockEntry( coral::ISchema& schema,
52  const std::string& reftableName,
53  unsigned long long& lastId );
54  void init();
55  private:
58 
61 
63  std::map< std::string, unsigned long long > m_tableToId;
64 
67 
70 
72  coral::AttributeList* m_whereData;
73 
76  bool m_started;
77  };
78 }//ns cond
79 #endif
std::map< std::string, unsigned long long > m_tableToId
Map of ids used.
std::string m_whereClause
The where clause pinning a sequence entry.
bool m_sequenceTableExists
Flag indicating whether the sequence table exists.
~SequenceManager()
Destructor.
bool existSequencesTable()
Whether sequence table exists.
std::string m_sequenceTableName
Sequence table name.
void createSequencesTable()
Creates the table holding the sequences.
bool lockEntry(coral::ISchema &schema, const std::string &reftableName, unsigned long long &lastId)
Locks the id entry in the ref table and returns the lastId value.
SequenceManager(cond::DbSession &coraldb, const std::string &sequenceTableName)
Constructor.
std::string m_setClause
The set clause for updating a sequence entry.
void clear()
Clears the internal state.
cond::DbSession m_coraldb
The coraldb in use.
coral::AttributeList * m_whereData
The data for the where clause.
unsigned long long incrementId(const std::string &reftableName)
Increments and returns a new valid oid for a table.
void updateId(const std::string &reftableName, unsigned long long lastId)
Updates the last used id.