80#include <system_error>
87template <
class VALTYPE>
121 static std::atomic<unsigned int> instancesctr;
122 static std::atomic<unsigned int> dstrctr;
134template <
class VALTYPE>
174template <
class KEYTYPE,
class VALTYPE>
182 using map_type =
typename std::map<key_type, value_type>;
215 std::cout <<
"G4Cache id: " <<
id << std::endl;
232 V aCopy = rhs.GetCache();
236 std::cout <<
"Copy constructor with id: " <<
id << std::endl;
248 V aCopy = rhs.GetCache();
252 std::cout <<
"Assignement operator with id: " <<
id << std::endl;
265 std::cout <<
"G4Cache id: " <<
id << std::endl;
273 std::cout <<
"~G4Cache id: " <<
id << std::endl;
290 }
catch(std::system_error& e)
294 G4cout <<
"Non-critical error: mutex lock failure in ~G4Cache<"
295 <<
typeid(V).name() <<
">. " <<
G4endl
296 <<
"If the RunManagerKernel has been deleted, it failed to "
297 <<
"delete an allocated resource" <<
G4endl
298 <<
"and this destructor is being called after the statics "
299 <<
"were destroyed." <<
G4endl;
300 G4cout <<
"Exception: [code: " << e.code() <<
"] caught: " << e.what()
305 G4bool last = (dstrctr == instancesctr);
309 instancesctr.store(0);
348 std::cout <<
"~G4VectorCache "
350 <<
" with size: " << Size() <<
"->";
352 std::cout <<
operator[](i) <<
",";
353 std::cout <<
"<-" << std::endl;
369 for(
G4int idx = 0; idx < nElems; ++idx)
421template <
class K,
class V>
426 <<
" with size: " << Size() <<
"->";
427 for(
iterator it = Begin(); it != End(); ++it)
428 std::cout << it->first <<
":" << it->second <<
",";
429 std::cout <<
"<-" << std::endl;
433template <
class K,
class V>
435 const K& k,
const V& v)
446template <
class K,
class V>
451template <
class K,
class V>
457template <
class K,
class V>
463template <
class K,
class V>
466 return (Find(k) != End());
469template <
class K,
class V>
472 return Find(k)->second;
475template <
class K,
class V>
481template <
class K,
class V>
G4GLOB_DLL std::ostream G4cout
VALTYPE & GetCache(unsigned int id) const
void Initialize(unsigned int id)
void Destroy(unsigned int id, G4bool last)
const G4int & GetId() const
G4Cache(const G4Cache &rhs)
void Put(const value_type &val) const
G4Cache(const value_type &v)
G4Cache & operator=(const G4Cache &rhs)
typename map_type::iterator iterator
typename map_type::size_type size_type
value_type & Get(const key_type &k)
std::pair< iterator, G4bool > Insert(const key_type &k, const value_type &v)
iterator Find(const key_type &k)
size_type Erase(const key_type &k)
G4bool Has(const key_type &k)
value_type & operator[](const key_type &k)
typename std::map< key_type, value_type > map_type
typename map_type::const_iterator const_iterator
value_type & operator[](const G4int &idx)
typename vector_type::size_type size_type
G4VectorCache(G4int nElems, value_type *vals)
typename vector_type::const_iterator const_iterator
typename vector_type::iterator iterator
typename std::vector< value_type > vector_type
G4VectorCache(G4int nElems)
void Push_back(const value_type &val)