Skip to content
Snippets Groups Projects
Commit 06e0ad20 authored by Joseph Boudreau's avatar Joseph Boudreau
Browse files

Deprecate GeoG4ExtensionSolidLoader in favor of Generic Loader

parent d2a2eea4
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEOG4EXTENSIONSOLIDLOADER_H_
#define GEOG4EXTENSIONSOLIDLOADER_H_
#include <string>
class GeoVG4ExtensionSolid;
class GeoG4ExtensionSolidLoader
{
public:
// Constructor:
GeoG4ExtensionSolidLoader();
// Destructor:
~GeoG4ExtensionSolidLoader();
// load G4Solid plugin
GeoVG4ExtensionSolid *load(const std::string & path) const;
private:
GeoG4ExtensionSolidLoader(const GeoG4ExtensionSolidLoader &)=delete;
GeoG4ExtensionSolidLoader & operator=(const GeoG4ExtensionSolidLoader &)=delete;
};
#endif
#include "GeoModelKernel/GeoG4ExtensionSolidLoader.h" /*
#include "GeoModelKernel/GeoVG4ExtensionSolid.h" Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
#include <string> */
#ifndef GEOPLUGINLOADER_H_
#define GEOPLUGINLOADER_H_
#include <iostream> #include <iostream>
#include <dlfcn.h> #include <dlfcn.h>
#include <libgen.h> #include <libgen.h>
#include <string>
template <class Plugin> class GeoPluginLoader
{
public:
// Constructor:
GeoPluginLoader<Plugin>();
// Destructor:
~GeoPluginLoader();
// load G4Solid plugin
Plugin *load(const std::string & path) const;
private:
GeoPluginLoader (const GeoPluginLoader &)=delete;
GeoPluginLoader & operator=(const GeoPluginLoader &)=delete;
};
GeoG4ExtensionSolidLoader::GeoG4ExtensionSolidLoader () {
}
GeoG4ExtensionSolidLoader::~GeoG4ExtensionSolidLoader () { template <class Plugin>
GeoPluginLoader<Plugin>::GeoPluginLoader () {
} }
GeoVG4ExtensionSolid *GeoG4ExtensionSolidLoader::load(const std::string & pString) const { template <class Plugin>
GeoPluginLoader<Plugin>::~GeoPluginLoader () {
}
template <class Plugin>
Plugin *GeoPluginLoader<Plugin>::load(const std::string & pString) const {
std::string bNameString=basename ((char *) pString.c_str()); // Strip off the directory std::string bNameString=basename ((char *) pString.c_str()); // Strip off the directory
bNameString=bNameString.substr(3); // Strip off leading "lib" bNameString=bNameString.substr(3); // Strip off leading "lib"
bNameString=bNameString.substr(0,bNameString.find(".")); // Strip off extensions bNameString=bNameString.substr(0,bNameString.find(".")); // Strip off extensions
...@@ -43,7 +74,10 @@ GeoVG4ExtensionSolid *GeoG4ExtensionSolidLoader::load(const std::string & pStrin ...@@ -43,7 +74,10 @@ GeoVG4ExtensionSolid *GeoG4ExtensionSolidLoader::load(const std::string & pStrin
// //
// //
// //
GeoVG4ExtensionSolid * factory = (GeoVG4ExtensionSolid *) F(); Plugin * factory = (Plugin *) F();
return factory; return factory;
} }
#endif
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "GeoModelKernel/GeoShapeIntersection.h" #include "GeoModelKernel/GeoShapeIntersection.h"
#include "GeoModelKernel/GeoShapeSubtraction.h" #include "GeoModelKernel/GeoShapeSubtraction.h"
#include "GeoModelKernel/GeoUnidentifiedShape.h" #include "GeoModelKernel/GeoUnidentifiedShape.h"
#include "GeoModelKernel/GeoG4ExtensionSolidLoader.h" #include "GeoModelKernel/GeoPluginLoader.h"
#include "GeoModelKernel/GeoVG4ExtensionSolid.h" #include "GeoModelKernel/GeoVG4ExtensionSolid.h"
#include "G4VSolid.hh" #include "G4VSolid.hh"
...@@ -489,7 +489,7 @@ G4VSolid *Geo2G4SolidFactory::Build(const GeoShape* geoShape, std::string name) ...@@ -489,7 +489,7 @@ G4VSolid *Geo2G4SolidFactory::Build(const GeoShape* geoShape, std::string name)
plugin=(*p).second; plugin=(*p).second;
} }
else { // make and store the new plugin. else { // make and store the new plugin.
static GeoG4ExtensionSolidLoader loader; static GeoPluginLoader<GeoVG4ExtensionSolid> loader;
std::string pName; std::string pName;
char * qName=getenv("G4EXTENSION_SOLID_DIR"); char * qName=getenv("G4EXTENSION_SOLID_DIR");
if (qName) { if (qName) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment