ATLAS Offline Software
SegMemSvc.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef CONTROL_STOREGATE_SEGMEMSVC_H
8 #define CONTROL_STOREGATE_SEGMEMSVC_H 1
9 
10 #include "GaudiKernel/Service.h"
11 #include "GaudiKernel/IIncidentListener.h"
12 #include "GaudiKernel/IIncidentSvc.h"
13 #include "GaudiKernel/MsgStream.h"
14 #include "GaudiKernel/ServiceHandle.h"
15 #include "AthAllocators/Arena.h"
16 
17 #include <string>
18 
19 
29 class SegMemSvc: public Service,
30  public IIncidentListener {
31 
32 public:
33 
34 
35  enum LIFETIME {
36  EVENT = 0,
37  JOB = 1,
38  INCIDENT = 2
39  };
40 
43 
44 
45  virtual StatusCode initialize();
46  virtual StatusCode reinitialize();
47  virtual StatusCode finalize();
48 
49  virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface );
50  static const InterfaceID& interfaceID() {
51  static const InterfaceID IID("SegMemSvc", 1, 0);
52  return IID;
53  }
54 
55  virtual void handle(const Incident&);
56 
58 
59 
62 
63 
64 
68  template <typename T>
69  T* allocate(SegMemSvc::LIFETIME, bool cache=true);
70 
72  template <typename T>
73  bool del(T*);
74 
76 
77 
78  SegMemSvc( const std::string& name, ISvcLocator* svc );
79 
80  // Destructor.
81  virtual ~SegMemSvc();
82 
83 
84 private:
85 
87 
89  inline std::string cvt(SegMemSvc::LIFETIME life) {
90  switch (life) {
91  case SegMemSvc::EVENT : return "EVENT";
92  case SegMemSvc::JOB : return "JOB";
93  case SegMemSvc::INCIDENT: return "INCIDENT";
94  }
95  return "UNKNOWN";
96  }
97 
101 
102 
103 };
104 
105 
106 #include "StoreGate/SegMemSvc.icc"
107 
108 #endif
SegMemSvc::reinitialize
virtual StatusCode reinitialize()
Definition: SegMemSvc.cxx:74
SegMemSvc::LIFETIME
LIFETIME
Definition: SegMemSvc.h:35
SegMemSvc.icc
SegMemSvc::~SegMemSvc
virtual ~SegMemSvc()
Definition: SegMemSvc.cxx:30
SegMemSvc::m_arena_inc
SG::Arena m_arena_inc
Definition: SegMemSvc.h:100
SegMemSvc::del
bool del(T *)
free memory managed by arena
SegMemSvc::JOB
@ JOB
Definition: SegMemSvc.h:37
SegMemSvc::m_ahead_inc
SG::ArenaHeader m_ahead_inc
Definition: SegMemSvc.h:99
SG::ArenaHeader
Proxy for a group of Arenas.
Definition: ArenaHeader.h:54
SegMemSvc::allocate
T * allocate(SegMemSvc::LIFETIME, bool cache=true)
Get pointer to an area in the arena, used for new with placement.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SegMemSvc::INCIDENT
@ INCIDENT
Definition: SegMemSvc.h:38
SegMemSvc::m_ahead_evt
SG::ArenaHeader m_ahead_evt
Definition: SegMemSvc.h:99
SG::Arena
Collection of memory allocators with a common lifetime,.
Definition: Arena.h:238
SegMemSvc::m_arena_evt
SG::Arena m_arena_evt
Definition: SegMemSvc.h:100
SegMemSvc::interfaceID
static const InterfaceID & interfaceID()
Definition: SegMemSvc.h:50
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
SegMemSvc::handle
virtual void handle(const Incident &)
Definition: SegMemSvc.cxx:92
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SegMemSvc
Service to access an arena caching allocator.
Definition: SegMemSvc.h:30
SegMemSvc::EVENT
@ EVENT
Definition: SegMemSvc.h:36
SegMemSvc::m_arena_job
SG::Arena m_arena_job
Definition: SegMemSvc.h:100
Arena.h
Collection of memory allocators with a common lifetime, plus subsystem summary.
SegMemSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
Definition: SegMemSvc.cxx:35
SegMemSvc::SegMemSvc
SegMemSvc(const std::string &name, ISvcLocator *svc)
Definition: SegMemSvc.cxx:18
SegMemSvc::cvt
std::string cvt(SegMemSvc::LIFETIME life)
helper to for printout
Definition: SegMemSvc.h:89
SegMemSvc::m_ahead_job
SG::ArenaHeader m_ahead_job
three arenas for different lifetimes
Definition: SegMemSvc.h:99
SegMemSvc::p_incSvc
ServiceHandle< IIncidentSvc > p_incSvc
Definition: SegMemSvc.h:86
SegMemSvc::finalize
virtual StatusCode finalize()
Definition: SegMemSvc.cxx:83
SegMemSvc::initialize
virtual StatusCode initialize()
Definition: SegMemSvc.cxx:55
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
ServiceHandle< IIncidentSvc >