BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSCavityFactory.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "BDSCavityFactory.hh"
19#include "BDSCavityFactoryBase.hh"
20#include "BDSCavityFactoryElliptical.hh"
21#include "BDSCavityFactoryPillBox.hh"
22#include "BDSCavityFactoryRectangular.hh"
23#include "BDSCavityInfo.hh"
24#include "BDSCavityType.hh"
25#include "BDSDebug.hh"
26
27#include "globals.hh"
28
30
37
39 elliptical(new BDSCavityFactoryElliptical()),
40 rectangular(new BDSCavityFactoryRectangular()),
41 pillBox(new BDSCavityFactoryPillBox())
42{;}
43
45{
46 delete elliptical;
47 delete rectangular;
48 delete pillBox;
49 instance = nullptr;
50}
51
52BDSCavityFactoryBase* BDSCavityFactory::GetAppropriateFactory(const BDSCavityType cavityType)
53{
55 switch (cavityType.underlying())
56 {
57 case BDSCavityType::elliptical:
58 {result = elliptical; break;}
59 case BDSCavityType::rectangular:
60 {result = rectangular; break;}
61 case BDSCavityType::pillbox:
62 {result = pillBox; break;}
63 default:
64 {break;}
65 }
66 return result;
67}
68
70 G4double totalChordLength,
71 const BDSCavityInfo* info,
72 G4Material* vacuumMaterial)
73{
74 BDSCavityFactoryBase* factory = GetAppropriateFactory(info->cavityType);
75
76 return factory->CreateCavity(name, totalChordLength, info, vacuumMaterial);
77}
Abstract base class for rf cavity geometry factories.
BDSCavity * CreateCavity(const G4String &name, G4double totalChordLength, const BDSCavityInfo *info, G4Material *vacuumMaterial)
Factory for elliptical SRF cavity geometry.
Factory for elliptical SRF cavity geometry.
Factory for elliptical SRF cavity geometry.
Interface to create any RF cavity geometry.
BDSCavityFactoryPillBox * pillBox
Point to factory this main interface owns.
static BDSCavityFactory * instance
Singleton instance.
BDSCavityFactoryRectangular * rectangular
Point to factory this main interface owns.
BDSCavityFactory()
Private constructor as singleton pattern.
static BDSCavityFactory * Instance()
Singleton accessor.
BDSCavityFactoryElliptical * elliptical
Point to factory this main interface owns.
BDSCavity * CreateCavity(const G4String &name, G4double totalChordLength, const BDSCavityInfo *info, G4Material *vacuumMaterial)
Main function to create a piece of cavity geometry.
Holder for all Geometrical information required to create an RF cavity.
BDSCavityType cavityType
Cavity type.
A holder class for an RF cavity piece of geometry.
Definition BDSCavity.hh:38
type underlying() const
return underlying value (can be used in switch statement)