ATLAS Offline Software
Loading...
Searching...
No Matches
EscapedEnergyRegistry.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef CALOG4SIM_ESCAPEDENERGYREGISTRY_H
6#define CALOG4SIM_ESCAPEDENERGYREGISTRY_H
7
10#include "globals.hh"
11
12#include <map>
13#include <memory>
14
15#include <thread>
16#include "G4Types.hh"
17#ifdef G4MULTITHREADED
18# include "tbb/concurrent_unordered_map.h"
19#endif
20namespace CaloG4
21{
50
52 {
53 public:
54
56
58
59 // Add a VEscapedEnergyProcessing object to the registry. The
60 // name include "Adopt" because we assume responsibility for
61 // deleting the pointer.
62 void AddAndAdoptProcessing( const G4String& name, std::unique_ptr<VEscapedEnergyProcessing> process );
63
64 // Given a volume name,
65 VEscapedEnergyProcessing* GetProcessing( const G4String& volumeName ) const;
66
67 protected:
68
69 // Constructor protected according to singleton pattern.
71
72 private:
73
74 typedef std::map< const G4String, std::unique_ptr<VEscapedEnergyProcessing> > m_processingMap_t;
75 typedef m_processingMap_t::iterator m_processingMap_ptr_t;
76 typedef m_processingMap_t::const_iterator m_processingMap_const_ptr_t;
78#ifdef G4MULTITHREADED
79 // Thread-to-EscapeEnergyRegistry concurrent map type
80 using EERThreadMap_t = tbb::concurrent_unordered_map< std::thread::id, EscapedEnergyRegistry*, std::hash<std::thread::id> >;
81 // Concurrent map of EERs, one for each thread
82 static EERThreadMap_t m_EERThreadMap ATLAS_THREAD_SAFE;
83 // @brief Search inside m_EERThreadMap the element with the current threadID
84 // and return it or return a null pointer if the element is not found
85 static EscapedEnergyRegistry* getEER();
86 // @brief Insert the current EER in m_EERThreadMap and
87 // associate it with the current threadID
88 static EscapedEnergyRegistry* setEER();
89#endif
90 };
91
92} // namespace CaloG4
93
94#endif // CaloG4_EscapedEnergyRegistry_H
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
VEscapedEnergyProcessing * GetProcessing(const G4String &volumeName) const
static EscapedEnergyRegistry * GetInstance()
m_processingMap_t::iterator m_processingMap_ptr_t
void AddAndAdoptProcessing(const G4String &name, std::unique_ptr< VEscapedEnergyProcessing > process)
std::map< const G4String, std::unique_ptr< VEscapedEnergyProcessing > > m_processingMap_t
m_processingMap_t::const_iterator m_processingMap_const_ptr_t
Virtual interface for escaped energy processor classes.
const std::string process