ATLAS Offline Software
ItemListSvc.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // ItemListSvc.h
8 // Header file for class ItemListSvc
9 // Author: S.Binet<binet@cern.ch>
10 // B.Radics<radbal@cern.ch>
12 #ifndef ATHENASERVICES_ITEMLISTSVC_H
13 #define ATHENASERVICES_ITEMLISTSVC_H
14 
20 // for size_t
21 #include <cstddef>
22 
23 #include <cassert>
24 
25 // STL includes
26 #include <string>
27 #include <vector>
28 #include <map>
29 #include <mutex>
30 
31 // FrameWork includes
32 #include "GaudiKernel/IAlgManager.h"
33 #include "GaudiKernel/ISvcLocator.h"
34 #include "GaudiKernel/IProperty.h"
35 #include "GaudiKernel/MsgStream.h"
36 
37 // Athena includes
40 
42 
43 namespace item {
44  class value_equals {
45  private:
46  std::string m_value;
47  public:
48  value_equals(const std::string& v) : m_value(v) {}
49  bool operator() (std::pair<const std::string, std::string> elem) {
50  return elem.second == m_value;
51  }
52  };
53 }
54 
55 class ItemListSvc : public extends<AthService, IItemListSvc>
56 {
57 
58 public:
59 
61  ItemListSvc(const std::string& name, ISvcLocator* pSvcLocator );
62 
64  virtual ~ItemListSvc();
65 
66 public:
67 
69  StatusCode initialize() override;
70  //StatusCode start();
71  StatusCode finalize() override;
72 
73  // Public interface methods
74  // non-const
75  //
76  // add a stream-item pair to the service listing
77  virtual StatusCode addStreamItem(const std::string& stream, const std::string& itemname) override;
78  // remove Item
79  virtual StatusCode removeStreamItem(const std::string& stream, const std::string& itemname) override;
80  //
81  // const
82  //
83  // check if a stream-item is registered
84  virtual bool containsItem(const std::string& itemname, const std::string& stream="ANY") const override;
85  // get the streams for a given item
86  virtual std::vector<std::string> getStreamsForItem(const std::string& itemname) const override;
87  // get the items for a given stream
88  virtual std::vector<std::string> getItemsForStream(const std::string& stream) const override;
89 
90 private:
91  // Map between streams and items
92  std::map<std::string, std::set<std::string> > m_streamItems;
95  typedef std::lock_guard<std::mutex> lock_t;
96 
97  // Avoid coverity warnings.
100 
101 };
102 
103 
104 #endif //> !ATHENASERVICES_ITEMLISTSVC_H
ItemListSvc::addStreamItem
virtual StatusCode addStreamItem(const std::string &stream, const std::string &itemname) override
Definition: ItemListSvc.cxx:74
ItemListSvc::m_mutex
std::mutex m_mutex
Definition: ItemListSvc.h:94
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
item::value_equals::operator()
bool operator()(std::pair< const std::string, std::string > elem)
Definition: ItemListSvc.h:49
item::value_equals::m_value
std::string m_value
Definition: ItemListSvc.h:46
ItemListSvc::ItemListSvc
ItemListSvc(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: ItemListSvc.cxx:20
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
AthAlgorithm.h
IItemListSvc.h
ItemListSvc::initialize
StatusCode initialize() override
Gaudi Service Implementation.
Definition: ItemListSvc.cxx:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ItemListSvc::m_streamItems
std::map< std::string, std::set< std::string > > m_streamItems
Definition: ItemListSvc.h:92
ItemListSvc::getStreamsForItem
virtual std::vector< std::string > getStreamsForItem(const std::string &itemname) const override
Definition: ItemListSvc.cxx:128
ItemListSvc::m_verboseThresh
float m_verboseThresh
Definition: ItemListSvc.h:93
item::value_equals::value_equals
value_equals(const std::string &v)
Definition: ItemListSvc.h:48
ItemListSvc::finalize
StatusCode finalize() override
Definition: ItemListSvc.cxx:39
ItemListSvc
This implementes the methods for IItemListSvc.
Definition: ItemListSvc.h:56
ItemListSvc::removeStreamItem
virtual StatusCode removeStreamItem(const std::string &stream, const std::string &itemname) override
Definition: ItemListSvc.cxx:97
ItemListSvc::ItemListSvc
ItemListSvc(const ItemListSvc &)
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
ItemListSvc::~ItemListSvc
virtual ~ItemListSvc()
Destructor.
Definition: ItemListSvc.cxx:29
item
Definition: ItemListSvc.h:43
python.PyAthena.v
v
Definition: PyAthena.py:157
AthService.h
ItemListSvc::getItemsForStream
virtual std::vector< std::string > getItemsForStream(const std::string &stream) const override
Definition: ItemListSvc.cxx:141
ItemListSvc::operator=
ItemListSvc & operator=(const ItemListSvc &)
ItemListSvc::lock_t
std::lock_guard< std::mutex > lock_t
Definition: ItemListSvc.h:95
item::value_equals
Definition: ItemListSvc.h:44
ItemListSvc::containsItem
virtual bool containsItem(const std::string &itemname, const std::string &stream="ANY") const override
Definition: ItemListSvc.cxx:113