CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TransactionCache.cc
Go to the documentation of this file.
1 #include "TransactionCache.h"
2 #include "DatabaseContainer.h"
4 
6  m_dbExists(false,false),
7  m_containersByName(),
8  m_containersById(),
9  m_dbParams(),
10  m_utility(),
11  m_loaded( false ),
12  m_namedRefCache(),
13  m_dropPermission(false,false){
14 }
15 
17  clear();
18 }
19 
21  m_dbExists.first = false;
22  m_dbExists.second = false;
23  for( std::map<int, Handle<DatabaseContainer> >::iterator iCont = m_containersById.begin();
24  iCont != m_containersById.end(); iCont++ ){
25  iCont->second.clear();
26  }
27  m_utility.clear();
28  m_containersById.clear();
29  m_containersByName.clear();
30  m_dbParams.clear();
31  m_loaded = false;
32  m_namedRefCache.clear();
33  m_dropPermission.first = false;
34  m_dropPermission.second = false;
35 }
36 
38  m_dbExists.first = true;
39  m_dbExists.second = exists;
40 }
41 
43  return m_dbExists.first;
44 }
45 
47  return m_dbExists.second;
48 }
49 
51  const std::string& name,
52  Handle<DatabaseContainer>& contPtr ){
53  m_containersById.insert( std::make_pair( id, contPtr ) );
54  m_containersByName.insert( std::make_pair( name, id ) );
55 }
56 
58  const std::string& name ){
59  m_containersById.erase( id );
60  m_containersByName.erase( name );
61 }
62 
65  std::map<int, Handle<DatabaseContainer> >::iterator iCont = m_containersById.find( id );
66  if( iCont != m_containersById.end() ){
67  instance = iCont->second;
68  }
69  return instance;
70 }
71 
74  std::map<std::string, int>::iterator iId = m_containersByName.find( name );
75  if( iId == m_containersByName.end() ){
76  return instance;
77  }
78  return getContainer( iId->second );
79 }
80 
81 const std::map<int,ora::Handle<ora::DatabaseContainer> >& ora::TransactionCache::containers(){
82  return m_containersById;
83 }
84 
86  m_dbExists.second = true;
87  m_dbExists.second = false;
88  m_containersById.clear();
89  m_containersByName.clear();
90  m_dbParams.clear();
91  m_namedRefCache.clear();
92  m_dropPermission.first = false;
93  m_dropPermission.second = false;
94 }
95 
96 std::map<std::string,std::string>& ora::TransactionCache::dbParams(){
97  return m_dbParams;
98 }
99 
101  m_utility = utility;
102 }
103 
105  return m_utility;
106 }
107 
109  return m_loaded;
110 }
111 
113  m_loaded = true;
114 }
115 
117  std::vector<std::string> namesToDelete;
118  for( std::map<std::string,boost::weak_ptr<void> >::const_iterator iEntry = m_namedRefCache.begin();
119  iEntry != m_namedRefCache.end(); iEntry++ ){
120  if( iEntry->second.expired() ) namesToDelete.push_back( iEntry->first );
121  }
122  for( std::vector<std::string>::const_iterator iName = namesToDelete.begin();
123  iName != namesToDelete.end(); iName++ ){
124  m_namedRefCache.erase( *iName );
125  }
126 }
127 
129  boost::shared_ptr<void>& data ){
130  m_namedRefCache.insert( std::make_pair( name, boost::weak_ptr<void>(data) ) );
131 }
132 
134  cleanUpNamedRefCache();
135  boost::shared_ptr<void> ret;
136  std::map<std::string,boost::weak_ptr<void> >::const_iterator iEntry = m_namedRefCache.find( name );
137  if( iEntry != m_namedRefCache.end() ){
138  ret = iEntry->second.lock();
139  }
140  return ret;
141 }
142 
144  m_dropPermission.first = true;
145  m_dropPermission.second = allowed;
146 }
147 
149  return m_dropPermission.first;
150 }
151 
153  return m_dropPermission.second;
154 }
void eraseContainer(int id, const std::string &name)
Handle< DatabaseContainer > getContainer(int id)
void setUtility(Handle< DatabaseUtilitySession > &utility)
static PFTauRenderPlugin instance
void addContainer(int id, const std::string &name, Handle< DatabaseContainer > &contPtr)
Handle< DatabaseUtilitySession > utility()
void setDbExists(bool exists)
const std::map< int, Handle< DatabaseContainer > > & containers()
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
boost::shared_ptr< void > getNamedReference(const std::string &name)
void setDropPermission(bool allowed)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void setNamedReference(const std::string &name, boost::shared_ptr< void > &data)
volatile std::atomic< bool > shutdown_flag false
std::map< std::string, std::string > & dbParams()