CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ora::TransactionCache Class Reference

#include <TransactionCache.h>

List of all members.

Public Member Functions

void addContainer (int id, const std::string &name, Handle< DatabaseContainer > &contPtr)
void clear ()
const std::map< int, Handle
< DatabaseContainer > > & 
containers ()
bool dbExists ()
bool dbExistsLoaded ()
std::map< std::string,
std::string > & 
dbParams ()
void dropDatabase ()
bool dropPermission ()
bool dropPermissionLoaded ()
void eraseContainer (int id, const std::string &name)
Handle< DatabaseContainergetContainer (int id)
Handle< DatabaseContainergetContainer (const std::string &name)
boost::shared_ptr< void > getNamedReference (const std::string &name)
bool isLoaded ()
void setDbExists (bool exists)
void setDropPermission (bool allowed)
void setLoaded ()
void setNamedReference (const std::string &name, boost::shared_ptr< void > &data)
void setUtility (Handle< DatabaseUtilitySession > &utility)
 TransactionCache ()
Handle< DatabaseUtilitySessionutility ()
virtual ~TransactionCache ()

Private Member Functions

void cleanUpNamedRefCache ()

Private Attributes

std::map< int, Handle
< DatabaseContainer > > 
m_containersById
std::map< std::string, int > m_containersByName
std::pair< bool, bool > m_dbExists
std::map< std::string,
std::string > 
m_dbParams
std::pair< bool, bool > m_dropPermission
bool m_loaded
std::map< std::string,
boost::weak_ptr< void > > 
m_namedRefCache
Handle< DatabaseUtilitySessionm_utility

Detailed Description

Definition at line 16 of file TransactionCache.h.


Constructor & Destructor Documentation

ora::TransactionCache::TransactionCache ( )

Definition at line 5 of file TransactionCache.cc.

ora::TransactionCache::~TransactionCache ( ) [virtual]

Definition at line 16 of file TransactionCache.cc.

References hitfit::clear().

                                      {
  clear();
}

Member Function Documentation

void ora::TransactionCache::addContainer ( int  id,
const std::string &  name,
Handle< DatabaseContainer > &  contPtr 
)

Definition at line 50 of file TransactionCache.cc.

                                                                              {
  m_containersById.insert( std::make_pair( id, contPtr ) );
  m_containersByName.insert( std::make_pair( name, id ) );
}
void ora::TransactionCache::cleanUpNamedRefCache ( ) [private]

Definition at line 116 of file TransactionCache.cc.

References Association::map, and AlCaHLTBitMon_QueryRunRegistry::string.

                                              {
  std::vector<std::string> namesToDelete;
  for( std::map<std::string,boost::weak_ptr<void> >::const_iterator iEntry = m_namedRefCache.begin();
       iEntry != m_namedRefCache.end(); iEntry++ ){
    if( iEntry->second.expired() ) namesToDelete.push_back( iEntry->first );
  }
  for( std::vector<std::string>::const_iterator iName = namesToDelete.begin();
       iName != namesToDelete.end(); iName++ ){
    m_namedRefCache.erase( *iName );
  }
}
void ora::TransactionCache::clear ( void  )

Definition at line 20 of file TransactionCache.cc.

References Association::map.

                               {
  m_dbExists.first = false;
  m_dbExists.second = false;
  for( std::map<int, Handle<DatabaseContainer> >::iterator iCont = m_containersById.begin();
       iCont != m_containersById.end(); iCont++ ){
    iCont->second.clear();
  }
  m_utility.clear();
  m_containersById.clear();
  m_containersByName.clear();
  m_dbParams.clear();
  m_loaded = false;
  m_namedRefCache.clear();
  m_dropPermission.first = false;
  m_dropPermission.second = false;
}
const std::map< int, ora::Handle< ora::DatabaseContainer > > & ora::TransactionCache::containers ( )

Definition at line 81 of file TransactionCache.cc.

                                                                                   {
  return m_containersById;  
}
bool ora::TransactionCache::dbExists ( )

Definition at line 46 of file TransactionCache.cc.

                                  {
  return m_dbExists.second;
}
bool ora::TransactionCache::dbExistsLoaded ( )

Definition at line 42 of file TransactionCache.cc.

                                        {
  return m_dbExists.first;  
}
std::map< std::string, std::string > & ora::TransactionCache::dbParams ( )

Definition at line 96 of file TransactionCache.cc.

                                                          {
  return m_dbParams;
}
void ora::TransactionCache::dropDatabase ( )

Definition at line 85 of file TransactionCache.cc.

                                      {
  m_dbExists.second = true;
  m_dbExists.second = false;
  m_containersById.clear();
  m_containersByName.clear();
  m_dbParams.clear();
  m_namedRefCache.clear();  
  m_dropPermission.first = false;
  m_dropPermission.second = false;
}
bool ora::TransactionCache::dropPermission ( )

Definition at line 152 of file TransactionCache.cc.

                                        {
  return m_dropPermission.second;
}
bool ora::TransactionCache::dropPermissionLoaded ( )

Definition at line 148 of file TransactionCache.cc.

                                              {
  return m_dropPermission.first;
}
void ora::TransactionCache::eraseContainer ( int  id,
const std::string &  name 
)

Definition at line 57 of file TransactionCache.cc.

                                                                   {
  m_containersById.erase( id );
  m_containersByName.erase( name );
}
ora::Handle< ora::DatabaseContainer > ora::TransactionCache::getContainer ( const std::string &  name)

Definition at line 72 of file TransactionCache.cc.

References instance.

                                                                                        {
  Handle<DatabaseContainer> instance;
  std::map<std::string, int>::iterator iId = m_containersByName.find( name );
  if( iId == m_containersByName.end() ){
    return instance;
  }
  return getContainer( iId->second );
}
ora::Handle< ora::DatabaseContainer > ora::TransactionCache::getContainer ( int  id)

Definition at line 63 of file TransactionCache.cc.

References instance.

                                                                         {
  Handle<DatabaseContainer> instance;
  std::map<int, Handle<DatabaseContainer> >::iterator iCont = m_containersById.find( id );
  if( iCont != m_containersById.end() ){
    instance = iCont->second;
  }
  return instance;
}
boost::shared_ptr< void > ora::TransactionCache::getNamedReference ( const std::string &  name)

Definition at line 133 of file TransactionCache.cc.

References run_regression::ret.

                                                                                   {
  cleanUpNamedRefCache();
  boost::shared_ptr<void> ret;
  std::map<std::string,boost::weak_ptr<void> >::const_iterator iEntry = m_namedRefCache.find( name );
  if( iEntry != m_namedRefCache.end() ){
    ret = iEntry->second.lock();
  }
  return ret;
}
bool ora::TransactionCache::isLoaded ( )

Definition at line 108 of file TransactionCache.cc.

                                  {
  return m_loaded;
}
void ora::TransactionCache::setDbExists ( bool  exists)

Definition at line 37 of file TransactionCache.cc.

                                                  {
  m_dbExists.first = true;
  m_dbExists.second = exists;  
}
void ora::TransactionCache::setDropPermission ( bool  allowed)

Definition at line 143 of file TransactionCache.cc.

                                                         {
  m_dropPermission.first = true;
  m_dropPermission.second = allowed;
}
void ora::TransactionCache::setLoaded ( )

Definition at line 112 of file TransactionCache.cc.

                                   {
  m_loaded = true;
}
void ora::TransactionCache::setNamedReference ( const std::string &  name,
boost::shared_ptr< void > &  data 
)

Definition at line 128 of file TransactionCache.cc.

                                                                            {
  m_namedRefCache.insert( std::make_pair( name, boost::weak_ptr<void>(data) ) );  
}
void ora::TransactionCache::setUtility ( Handle< DatabaseUtilitySession > &  utility)

Definition at line 100 of file TransactionCache.cc.

ora::Handle< ora::DatabaseUtilitySession > ora::TransactionCache::utility ( )

Definition at line 104 of file TransactionCache.cc.

                                                                 {
  return m_utility;
}

Member Data Documentation

Definition at line 66 of file TransactionCache.h.

std::map<std::string, int> ora::TransactionCache::m_containersByName [private]

Definition at line 65 of file TransactionCache.h.

std::pair<bool,bool> ora::TransactionCache::m_dbExists [private]

Definition at line 64 of file TransactionCache.h.

std::map<std::string,std::string> ora::TransactionCache::m_dbParams [private]

Definition at line 67 of file TransactionCache.h.

std::pair<bool,bool> ora::TransactionCache::m_dropPermission [private]

Definition at line 71 of file TransactionCache.h.

Definition at line 69 of file TransactionCache.h.

std::map<std::string,boost::weak_ptr<void> > ora::TransactionCache::m_namedRefCache [private]

Definition at line 70 of file TransactionCache.h.

Definition at line 68 of file TransactionCache.h.