BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
BDSBLMRegistry.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2022.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "BDSBLM.hh"
20#include "BDSBLMRegistry.hh"
21
22#include "globals.hh"
23
24#include <vector>
25
27
29{
30 if (!instance)
31 {instance = new BDSBLMRegistry();}
32 return instance;
33}
34
36 numberOfEntries(0)
37{;}
38
39BDSBLMRegistry::~BDSBLMRegistry()
40{
41 for (auto b : blms)
42 {delete b;}
43 instance = nullptr;
44}
45
46G4int BDSBLMRegistry::RegisterBLM(G4String name,
47 BDSBLM* blm,
48 G4double SIn)
49{
50 names.push_back(name);
51 blms.insert(blm);
52 blmsVector.push_back(blm);
53 S.push_back(SIn);
54 G4int index = numberOfEntries; // copy the number of entires / the index of this entry
56 return index;
57}
Registry of all BLMs so we know each one uniquely.
static BDSBLMRegistry * Instance()
Accessor for registry.
static BDSBLMRegistry * instance
Singleton instance.
BDSBLMRegistry()
Private constructor to enforce singleton pattern.
std::set< BDSBLM * > blms
Cache of unique sampler objects for memory management.
A beam loss monitor.
Definition: BDSBLM.hh:42