|
1 | 1 | /******************************************************************************** |
2 | | - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * |
| 2 | + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * |
3 | 3 | * * |
4 | 4 | * This software is distributed under the terms of the * |
5 | 5 | * GNU Lesser General Public Licence (LGPL) version 3, * |
@@ -29,42 +29,44 @@ FairGeoLoader* FairGeoLoader::fgInstance = nullptr; |
29 | 29 |
|
30 | 30 | FairGeoLoader* FairGeoLoader::Instance() { return fgInstance; } |
31 | 31 |
|
| 32 | +static std::unique_ptr<FairGeoBuilder> MakeGeoBuilder(const char* Name) |
| 33 | +{ |
| 34 | + if (strncmp(Name, "TGeo", 4) == 0) { |
| 35 | + auto geom = std::make_unique<TGeoManager>("FAIRGeom", "FAIR geometry"); |
| 36 | + return std::make_unique<FairGeoRootBuilder>("TGeo builder", "geometry builder", std::move(geom)); |
| 37 | + } |
| 38 | + |
| 39 | + if (strncmp(Name, "G3Native", 8) == 0) { |
| 40 | + cout << "-I- FairGeoLoader() : Native G3 Geometry is used: This option is not supported any more!" << endl; |
| 41 | + exit(0); |
| 42 | + // gGeoManager = NULL; |
| 43 | + // fGeoBuilder=new FairGeoG3Builder("G3 builder","geometry builder"); |
| 44 | + } |
| 45 | + |
| 46 | + return {}; |
| 47 | +} |
| 48 | + |
32 | 49 | FairGeoLoader::FairGeoLoader() |
33 | 50 | : TNamed() |
34 | | - , fInterface(NULL) |
35 | | - , fGeoBuilder(NULL) |
36 | 51 | { |
37 | 52 | fgInstance = this; |
38 | 53 | } |
39 | 54 |
|
40 | 55 | FairGeoLoader::FairGeoLoader(const char* Name, const char* title) |
41 | 56 | : TNamed(Name, title) |
42 | | - , fInterface(NULL) |
43 | | - , fGeoBuilder(NULL) |
| 57 | + , fGeoBuilder(MakeGeoBuilder(Name)) |
44 | 58 | { |
45 | 59 | if (fgInstance) { |
46 | 60 | Fatal("FairGeoLoader", "Singleton instance already exists."); |
47 | 61 | return; |
48 | 62 | } |
49 | 63 | fgInstance = this; |
50 | | - fInterface = new FairGeoInterface; |
51 | | - if (strncmp(Name, "TGeo", 4) == 0) { |
52 | | - TGeoManager* geom = new TGeoManager("FAIRGeom", "FAIR geometry"); |
53 | | - fGeoBuilder = new FairGeoRootBuilder("TGeo builder", "geometry builder"); |
54 | | - (static_cast<FairGeoRootBuilder*>(fGeoBuilder))->setGeoManager(geom); |
55 | | - } else if (strncmp(Name, "G3Native", 8) == 0) { |
56 | | - cout << "-I- FairGeoLoader() : Native G3 Geometry is used: This option is not supported any more!" << endl; |
57 | | - exit(0); |
58 | | - // gGeoManager = NULL; |
59 | | - // fGeoBuilder=new FairGeoG3Builder("G3 builder","geometry builder"); |
60 | | - } |
61 | 64 |
|
62 | | - fInterface->setGeomBuilder(fGeoBuilder); |
| 65 | + fInterface.setGeomBuilder(fGeoBuilder.get()); |
63 | 66 | } |
64 | 67 |
|
65 | 68 | FairGeoLoader::~FairGeoLoader() |
66 | 69 | { |
67 | | - delete fInterface; |
68 | 70 | if (fgInstance == this) { |
69 | 71 | // Do not point to a destructed object! |
70 | 72 | fgInstance = nullptr; |
|
0 commit comments