80 #include <system_error>
91 template<
class VALTYPE>
137 template<
class VALTYPE>
174 template<
class KEYTYPE,
class VALTYPE>
180 typedef typename std::map<key_type,value_type>
map_type;
228 cout<<
"G4Cache id: "<<
id<<endl;
237 if (
this == &rhs )
return;
244 cout<<
"Copy constructor with id: "<<
id<<endl;
251 if (
this == &rhs)
return *
this;
256 cout<<
"Assignement operator with id: "<<
id<<endl;
268 cout<<
"G4Cache id: "<<
id<<
" "<<endl;
276 cout<<
"~G4Cache id: "<<
id<<
" "<<endl;
291 catch (std::system_error&
e)
295 G4cout <<
"Non-critical error: mutex lock failure in ~G4Cache<"
296 <<
typeid(V).
name() <<
">. "
297 <<
"If the RunManagerKernel has been deleted, it failed to "
298 <<
"delete an allocated resource and this destructor is being "
299 <<
"called after the statics were destroyed." <<
G4endl;
300 G4cout <<
"Exception: [code: " << e.code() <<
"] caught: "
305 G4bool last = ( dstrctr == instancesctr );
306 theCache.Destroy(
id, last);
308 instancesctr.store(0);
315 {
return GetCache(); }
319 { GetCache() = val; }
324 {
return GetCache(); }
341 for (
size_type i = 0 ; i < Size() ; ++i )
342 cout<<
operator[](i)<<
",";
357 for (
G4int idx = 0 ; idx < nElems ; ++idx )
408 template<
class K,
class V>
413 for (
iterator it = Begin() ; it != End() ; ++it )
414 cout<<it->first<<
":"<<it->second<<
",";
419 template<
class K,
class V>
420 std::pair<typename G4MapCache<K,V>::iterator,
G4bool>
432 template<
class K,
class V>
437 template<
class K,
class V>
443 template<
class K,
class V>
449 template<
class K,
class V>
452 return ( Find(k) != End() );
455 template<
class K,
class V>
458 return Find(k)->second;
461 template<
class K,
class V>
467 template<
class K,
class V>
void Initialize(unsigned int id)
G4CacheReference< value_type > theCache
value_type & operator[](const key_type &k)
vector_type::const_iterator const_iterator
std::pair< iterator, G4bool > Insert(const key_type &k, const value_type &v)
G4Cache & operator=(const G4Cache &rhs)
std::vector< value_type > vector_type
map_type::size_type size_type
G4bool Has(const key_type &k)
value_type & operator[](const G4int &idx)
G4Mutex & G4TypeMutex(const unsigned int &_n=0)
size_type Erase(const key_type &k)
value_type & GetCache() const
VALTYPE & GetCache(unsigned int id) const
static std::atomic< unsigned int > dstrctr
vector_type::iterator iterator
map_type::iterator iterator
const int & GetId() const
vector_type::size_type size_type
void Put(const value_type &val) const
iterator Find(const key_type &k)
G4GLOB_DLL std::ostream G4cout
std::map< key_type, value_type > map_type
map_type::const_iterator const_iterator
static std::atomic< unsigned int > instancesctr
void Push_back(const value_type &val)