CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
ora::Sequences Class Reference

#include <Sequences.h>

Public Member Functions

void clear ()
 
void create (const std::string &sequenceName)
 
void erase (const std::string &sequenceName)
 
int getNextId (const std::string &sequenceName, bool sinchronize=false)
 
 Sequences (IDatabaseSchema &dbSchema)
 
 Sequences (ISequenceTable &table)
 
void sinchronize (const std::string &sequenceName)
 
void sinchronizeAll ()
 
virtual ~Sequences ()
 

Private Attributes

std::map< std::string, int > m_lastIds
 
ISequenceTablem_table
 

Detailed Description

Definition at line 13 of file Sequences.h.

Constructor & Destructor Documentation

ora::Sequences::Sequences ( ora::IDatabaseSchema schema)
explicit

Definition at line 5 of file Sequences.cc.

5  :
6  m_lastIds(),
7  m_table( schema.sequenceTable()){
8 }
ISequenceTable & m_table
Definition: Sequences.h:26
std::map< std::string, int > m_lastIds
Definition: Sequences.h:25
virtual ISequenceTable & sequenceTable()=0
ora::Sequences::Sequences ( ora::ISequenceTable table)
explicit

Definition at line 10 of file Sequences.cc.

10  :
11  m_lastIds(),
12  m_table( table ){
13 }
ISequenceTable & m_table
Definition: Sequences.h:26
std::map< std::string, int > m_lastIds
Definition: Sequences.h:25
ora::Sequences::~Sequences ( )
virtual

Definition at line 15 of file Sequences.cc.

15  {
16 }

Member Function Documentation

void ora::Sequences::clear ( void  )
void ora::Sequences::create ( const std::string &  sequenceName)

Definition at line 18 of file Sequences.cc.

18  {
19  m_table.add( sequenceName );
20 }
ISequenceTable & m_table
Definition: Sequences.h:26
virtual bool add(const std::string &sequenceName)=0
void ora::Sequences::erase ( const std::string &  sequenceName)

Definition at line 63 of file Sequences.cc.

63  {
64  m_table.erase( sequenceName );
65 }
virtual void erase(const std::string &sequenceName)=0
ISequenceTable & m_table
Definition: Sequences.h:26
int ora::Sequences::getNextId ( const std::string &  sequenceName,
bool  sinchronize = false 
)

Definition at line 22 of file Sequences.cc.

References newFWLiteAna::found, and ora::throwException().

22  {
23  int next = 0;
24  std::map<std::string,int>::iterator iS = m_lastIds.find( sequenceName );
25  if( iS == m_lastIds.end() ){
26  bool found = m_table.getLastId( sequenceName, next );
27  if( ! found ) {
28  throwException("Sequence \""+sequenceName+"\" does not exists.","Sequences::getNextId");
29  } else {
30  next += 1;
31  }
32  m_lastIds.insert( std::make_pair( sequenceName, next ));
33  } else {
34  next = ++iS->second;
35  }
36 
37  if( sinchronize){
38  m_table.sinchronize( sequenceName, next );
39  }
40  return next;
41 }
virtual void sinchronize(const std::string &sequenceName, int lastValue)=0
virtual bool getLastId(const std::string &sequenceName, int &lastId)=0
void sinchronize(const std::string &sequenceName)
Definition: Sequences.cc:43
ISequenceTable & m_table
Definition: Sequences.h:26
std::map< std::string, int > m_lastIds
Definition: Sequences.h:25
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
void ora::Sequences::sinchronize ( const std::string &  sequenceName)

Definition at line 43 of file Sequences.cc.

References edm::second().

43  {
44  std::map<std::string,int>::iterator iS = m_lastIds.find( sequenceName );
45  if( iS != m_lastIds.end() ){
46  int lastOnDb = 0;
47  m_table.getLastId( sequenceName, lastOnDb );
48  if( lastOnDb < iS->second ) m_table.sinchronize( sequenceName, iS->second );
49  m_lastIds.erase( sequenceName );
50  }
51 }
virtual void sinchronize(const std::string &sequenceName, int lastValue)=0
virtual bool getLastId(const std::string &sequenceName, int &lastId)=0
U second(std::pair< T, U > const &p)
ISequenceTable & m_table
Definition: Sequences.h:26
std::map< std::string, int > m_lastIds
Definition: Sequences.h:25
void ora::Sequences::sinchronizeAll ( )

Definition at line 53 of file Sequences.cc.

References hitfit::clear(), and edm::second().

53  {
54  for( std::map<std::string,int>::iterator iS = m_lastIds.begin();
55  iS != m_lastIds.end(); iS++ ){
56  int lastOnDb = 0;
57  m_table.getLastId( iS->first, lastOnDb );
58  if( lastOnDb < iS->second ) m_table.sinchronize( iS->first, iS->second );
59  }
60  clear();
61 }
virtual void sinchronize(const std::string &sequenceName, int lastValue)=0
virtual bool getLastId(const std::string &sequenceName, int &lastId)=0
U second(std::pair< T, U > const &p)
ISequenceTable & m_table
Definition: Sequences.h:26
void clear()
Definition: Sequences.cc:67
std::map< std::string, int > m_lastIds
Definition: Sequences.h:25

Member Data Documentation

std::map<std::string, int> ora::Sequences::m_lastIds
private

Definition at line 25 of file Sequences.h.

ISequenceTable& ora::Sequences::m_table
private

Definition at line 26 of file Sequences.h.