Skip to content

Commit 48c79f6

Browse files
chore: Improve type safety in FairModule::ConstructASCIIGeometry
Parts of FairModule::ConstructASCIIGeometry have expectations on the base classes of T and U. So document that more properly.
1 parent b8cd9d3 commit 48c79f6

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

fairroot/base/sim/FairModule.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include "FairGeoInterface.h" // for FairGeoInterface
1212
#include "FairGeoLoader.h" // for FairGeoLoader
1313
#include "FairGeoNode.h" // for FairGeoNode
14-
#include "FairGeoVolume.h" // for FairGeoVolume
15-
#include "FairLogger.h"
14+
#include "FairGeoSet.h"
15+
#include "FairGeoVolume.h"
1616
#include "FairRun.h" // for FairRun
1717
#include "FairRuntimeDb.h" // for FairRuntimeDb
1818

@@ -25,7 +25,9 @@
2525
#include <TRefArray.h> // for TRefArray
2626
#include <TString.h> // for TString, operator!=
2727
#include <TVirtualMC.h>
28+
#include <fairlogger/Logger.h>
2829
#include <string>
30+
#include <type_traits>
2931
#include <vector>
3032

3133
class FairVolumeList;
@@ -174,9 +176,11 @@ class FairModule : public TNamed
174176
template<class T, class U>
175177
void FairModule::ConstructASCIIGeometry(TString containerName)
176178
{
179+
static_assert(std::is_base_of_v<FairGeoSet,T>);
180+
static_assert(std::is_base_of_v<FairParSet,U>);
181+
FairGeoSet* MGeo = new T();
177182
FairGeoLoader* loader = FairGeoLoader::Instance();
178183
FairGeoInterface* GeoInterface = loader->getGeoInterface();
179-
T* MGeo = new T();
180184
MGeo->print();
181185
MGeo->setGeomFile(GetGeometryFileName());
182186
GeoInterface->addGeoModule(MGeo); // takes ownership!

0 commit comments

Comments
 (0)