ATLAS Offline Software
Loading...
Searching...
No Matches
CoraCoolSequence.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef CORACOOL_CORACOOLSEQUENCE_H
6#define CORACOOL_CORACOOLSEQUENCE_H
7// CoraCoolSequence.h
8// class to implement a sequence table to generate primary and foreign keys
9// using an auxillary table with SELECT ... FOR UPDATE semantics
10// table is called <dbname>_CORACOOLKEYS with one row per sequence
11// Richard Hawkings, started 24/10/06
12
13#include <string>
14
16 public:
17 // access a sequence - try to create required tables if create set
18 // assumes a database transaction is already active
19 CoraCoolSequence(const std::string& dbname, const std::string& seqname,
20 coral::ISessionProxy* proxy, bool create=false);
21
22 // fetch the next value in the sequence, reserving inc values
23 // assumes a database transaction is already active
24 // locks the corresponding table rows until the transaction is committed
25 int fetch(const int inc=1);
26
27 // query to find the current value (which is not yet used), but no increment
28 // must be followed by a fetch if this key value is actually used
29 bool querySeq(int& keyval,bool update=false,bool gettable=false);
30
31 // drop the current sequence from the table
32 // assumes a transaction is already active
33 // after this, the current sequence object is invalid and will not work
34 bool dropSeq();
35
36 private:
37 // hide default constructor
39
40 std::string m_dbname; // the parent COOL database instance
41 std::string m_seqname; // name of the sequence
42 coral::ISessionProxy* m_proxy; // pointer to CORAL session
43 coral::ITable* m_table; // pointer to the sequence table
44};
45
46#endif // CORACOOL_CORACOOLSEQUENCE_H
coral::ITable * m_table
bool querySeq(int &keyval, bool update=false, bool gettable=false)
coral::ISessionProxy * m_proxy
std::string m_seqname
int fetch(const int inc=1)
CoraCoolSequence(const std::string &dbname, const std::string &seqname, coral::ISessionProxy *proxy, bool create=false)