PandaRoot
PndSttTubeMap.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /*
14  * PndSttTubeMap.h
15  *
16  * Created on: 02.08.2018
17  * Author: tstockmanns
18  */
19 
20 #ifndef DETECTORS_STT_PNDSTTTUBEMAP_H_
21 #define DETECTORS_STT_PNDSTTTUBEMAP_H_
22 
23 #include <TObject.h>
24 #include <map>
25 
26 class PndSttTube;
27 
28 class PndSttTubeMap : public TObject {
29  public:
30  static PndSttTubeMap *Instance();
31  virtual ~PndSttTubeMap();
32 
33  void AddTube(int tubeId, PndSttTube *tube) { fTubeMap[tubeId] = tube; }
34  PndSttTube *GetTube(int tubeId)
35  {
36  if (fTubeMap.count(tubeId) > 0)
37  return fTubeMap[tubeId];
38  else
39  return nullptr;
40  }
41  std::map<int, PndSttTube *> GetMap() { return fTubeMap; } // todo: change this to an iterator running through all fields of the map to hide the implementation
42  int GetMapSize() { return fTubeMap.size(); }
43 
44  private:
45  static PndSttTubeMap *fInstance;
46  std::map<int, PndSttTube *> fTubeMap;
47  PndSttTubeMap();
48 
49  ClassDef(PndSttTubeMap, 1);
50 };
51 
52 #endif /* DETECTORS_STT_PNDSTTTUBEMAP_H_ */
PndSttTube * GetTube(int tubeId)
Definition: PndSttTubeMap.h:34
virtual ~PndSttTubeMap()
std::map< int, PndSttTube * > GetMap()
Definition: PndSttTubeMap.h:41
static PndSttTubeMap * Instance()
void AddTube(int tubeId, PndSttTube *tube)
Definition: PndSttTubeMap.h:33