CMS 3D CMS Logo

Public Member Functions | Private Attributes

ora::Sequences Class Reference

#include <Sequences.h>

List of all members.

Public Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 12 of file Sequences.h.


Constructor & Destructor Documentation

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

Definition at line 4 of file Sequences.cc.

                                                   :
  m_lastIds(),
  m_schema( schema){
}
ora::Sequences::~Sequences ( ) [virtual]

Definition at line 9 of file Sequences.cc.

                        {
}

Member Function Documentation

void ora::Sequences::clear ( void  )

Definition at line 57 of file Sequences.cc.

                        {
  m_lastIds.clear();
}
void ora::Sequences::erase ( const std::string &  sequenceName)

Definition at line 53 of file Sequences.cc.

                                                       {
  m_schema.sequenceTable().erase( sequenceName );
}
int ora::Sequences::getNextId ( const std::string &  sequenceName,
bool  sinchronize = false 
)

Definition at line 12 of file Sequences.cc.

References newFWLiteAna::found.

                                                                            {
  int next = 0;
  std::map<std::string,int>::iterator iS = m_lastIds.find( sequenceName );
  if( iS == m_lastIds.end() ){
    bool found = m_schema.sequenceTable().getLastId( sequenceName, next );
    if( ! found ) {
      m_schema.sequenceTable().add( sequenceName );
    } else {
      next += 1;
    }
    m_lastIds.insert( std::make_pair( sequenceName, next ));
  } else {
    next = ++iS->second;
  }

  if( sinchronize){
    m_schema.sequenceTable().sinchronize( sequenceName, next );
  }  
  return next;
}
void ora::Sequences::sinchronize ( const std::string &  sequenceName)

Definition at line 33 of file Sequences.cc.

References edm::second().

                                                             {
  std::map<std::string,int>::iterator iS = m_lastIds.find( sequenceName );
  if( iS != m_lastIds.end() ){
    int lastOnDb = 0;
    m_schema.sequenceTable().getLastId( sequenceName, lastOnDb );
    if( lastOnDb < iS->second ) m_schema.sequenceTable().sinchronize( sequenceName, iS->second );
    m_lastIds.erase( sequenceName );
  }
}
void ora::Sequences::sinchronizeAll ( )

Definition at line 43 of file Sequences.cc.

References edm::second().

                                 {
  for( std::map<std::string,int>::iterator iS = m_lastIds.begin();
       iS != m_lastIds.end(); iS++ ){
    int lastOnDb = 0;
    m_schema.sequenceTable().getLastId( iS->first, lastOnDb );
    if( lastOnDb < iS->second ) m_schema.sequenceTable().sinchronize( iS->first, iS->second );    
  }
  clear();
}

Member Data Documentation

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

Definition at line 22 of file Sequences.h.

Definition at line 23 of file Sequences.h.