diff --git a/DDCore/include/DD4hep/GridPhiEta.h b/DDCore/include/DD4hep/GridPhiEta.h index ebf3a079a6de6dcc8bf2ea668e2c33e213d3e9b4..67dab0f7bd1c600c8313fbe910b33b63a61a30c3 100644 --- a/DDCore/include/DD4hep/GridPhiEta.h +++ b/DDCore/include/DD4hep/GridPhiEta.h @@ -18,7 +18,6 @@ // Framework includes #include "DDSegmentation/GridPhiEta.h" #include "DD4hep/Segmentations.h" -#include "DD4hep/detail/SegmentationsInterna.h" /// Namespace for the AIDA detector description toolkit namespace dd4hep { diff --git a/DDCore/include/DD4hep/GridRPhiEta.h b/DDCore/include/DD4hep/GridRPhiEta.h index 68761dfdb1f342d91dda399f97807c544427fbbc..c081bec79f22c592e0f282b45eccfc770d2bf601 100644 --- a/DDCore/include/DD4hep/GridRPhiEta.h +++ b/DDCore/include/DD4hep/GridRPhiEta.h @@ -18,7 +18,6 @@ // Framework includes #include "DD4hep/Segmentations.h" #include "DDSegmentation/GridRPhiEta.h" -#include "DD4hep/detail/SegmentationsInterna.h" /// Namespace for the AIDA detector description toolkit namespace dd4hep { diff --git a/DDCore/include/DD4hep/detail/SegmentationsInterna.h b/DDCore/include/DD4hep/detail/SegmentationsInterna.h index a3d35ef458f8d3134fc33ff9bbab82d6ad8f1c81..a43606b33d4de88a4c76b409d1e29cae5d2ee2bc 100644 --- a/DDCore/include/DD4hep/detail/SegmentationsInterna.h +++ b/DDCore/include/DD4hep/detail/SegmentationsInterna.h @@ -17,7 +17,6 @@ #include "DD4hep/Handle.h" #include "DD4hep/Objects.h" #include "DD4hep/BitFieldCoder.h" -#include "DDSegmentation/Segmentation.h" // C/C++ include files @@ -29,6 +28,13 @@ namespace dd4hep { class SegmentationObject; class SensitiveDetectorObject; + namespace DDSegmentation { + class Segmentation; + class SegmentationParameter; + typedef SegmentationParameter* Parameter; + typedef std::vector<Parameter> Parameters; + } + /// Implementation class supporting generic Segmentation of sensitive detectors /** * The SegmentationObject wraps the functionality of the DDSegmentation base class. diff --git a/DDCore/include/DDSegmentation/Segmentation.h b/DDCore/include/DDSegmentation/Segmentation.h index 2d401d4076dfd2a7be1ea0a4969826852f262510..0c59d1fe1423e38d978a8819ad0a8d642fed976d 100644 --- a/DDCore/include/DDSegmentation/Segmentation.h +++ b/DDCore/include/DDSegmentation/Segmentation.h @@ -19,8 +19,8 @@ #ifndef DDSEGMENTATION_SEGMENTATION_H #define DDSEGMENTATION_SEGMENTATION_H +#include "DD4hep/detail/SegmentationsInterna.h" #include "DDSegmentation/BitFieldCoder.h" -#include "DDSegmentation/SegmentationFactory.h" #include "DDSegmentation/SegmentationParameter.h" #include <map> @@ -177,10 +177,6 @@ namespace dd4hep { Segmentation(const Segmentation&); }; - /// Macro to instantiate a new SegmentationCreator by its type name -#define REGISTER_SEGMENTATION(classname) \ - static const SegmentationCreator<classname> classname##_creator(#classname); - } /* namespace DDSegmentation */ } /* namespace dd4hep */ #endif // DDSEGMENTATION_SEGMENTATION_H diff --git a/DDCore/include/DDSegmentation/SegmentationFactory.h b/DDCore/include/DDSegmentation/SegmentationFactory.h deleted file mode 100644 index 2e1dd19944846dba1857fcbf4f5008990cc79e24..0000000000000000000000000000000000000000 --- a/DDCore/include/DDSegmentation/SegmentationFactory.h +++ /dev/null @@ -1,88 +0,0 @@ -//========================================================================== -// AIDA Detector description implementation -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see $DD4hepINSTALL/LICENSE. -// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. -// -//========================================================================== - -/* - * SegmentationFactory.h - * - * Factory and helper classes to allow instantiation of segmentations by name. - * - * Created on: Dec 15, 2013 - * Author: Christian Grefe, CERN - */ - -#ifndef DDSEGMENTATION_SEGMENTATIONFACTORY_H -#define DDSEGMENTATION_SEGMENTATIONFACTORY_H - -#include "DDSegmentation/Segmentation.h" - -#include <map> -#include <vector> -#include <string> - -namespace dd4hep { - namespace DDSegmentation { - - /// Forward declaration required because of circular dependency - class Segmentation; - class SegmentationCreatorBase; - - /// Base class for the SegmentationCreator objects. Allows to use the factory without template. - class SegmentationCreatorBase { - public: - /// Default constructor. Takes the class name as argument and takes care of registration with the factory - SegmentationCreatorBase(const std::string& name); - /// Destructor - virtual ~SegmentationCreatorBase() {}; - /// Create a new object - virtual Segmentation* create(const std::string& identifier) const = 0; - }; - - /// Concrete class to create segmentation objects. Every segmentation needs to instantiate a static instance of this. - template<class TYPE> class SegmentationCreator : public SegmentationCreatorBase { - public: - /// Default constructor. Takes the class name as argument which should match the class type - SegmentationCreator<TYPE>(const std::string& name) : SegmentationCreatorBase(name) {}; - /// Destructor - virtual ~SegmentationCreator() {}; - /// Create a new object of the given type. - Segmentation* create(const std::string& identifier) const {return new TYPE(identifier);}; - }; - - /// Factory for creating segmentation objects by type name - class SegmentationFactory { - /// Allow SegmentationCreators to register themselves with the factory - friend class SegmentationCreatorBase; - public: - /// Access to the global factory instance - static SegmentationFactory* instance(); - /// Create a new segmentation object with the given type name. Returns NULL if type name is unknown. - Segmentation* create(const std::string& name, const std::string& identifier = "") const; - /// Access to the list of registered segmentations - std::vector<std::string> registeredSegmentations() const; - protected: - /// Default constructor - SegmentationFactory() {}; - /// Copy constructor - SegmentationFactory(const SegmentationFactory&) {}; - /// Destructor - virtual ~SegmentationFactory() {}; - /// Registers a new SegmentationCreator with the factory - void registerSegmentation(const std::string& name, SegmentationCreatorBase* creator); - /// Map to store SegmentationCreators by name - std::map<std::string, SegmentationCreatorBase*> _segmentations; - private: - /// The global factory instance - static SegmentationFactory* _instance; - }; - - } /* namespace DDSegmentation */ -} /* namespace dd4hep */ -#endif // DDSEGMENTATION_SEGMENTATIONFACTORY_H diff --git a/DDCore/src/CartesianGridXY.cpp b/DDCore/src/CartesianGridXY.cpp index d0f7b72b62f4ec88d7c3297bd4a9747d2a42a718..949aefba309fd80f5385591744e03028601ec267 100644 --- a/DDCore/src/CartesianGridXY.cpp +++ b/DDCore/src/CartesianGridXY.cpp @@ -13,7 +13,6 @@ // Framework include files #include "DD4hep/CartesianGridXY.h" -#include "DD4hep/detail/SegmentationsInterna.h" #include "DDSegmentation/CartesianGridXY.h" // C/C++ include files diff --git a/DDCore/src/CartesianGridXYZ.cpp b/DDCore/src/CartesianGridXYZ.cpp index 88c706a6fce9b32f14705d34271c513e941999e2..ae4017c7a684cf2885cdeaad1c27e4497f0c785a 100644 --- a/DDCore/src/CartesianGridXYZ.cpp +++ b/DDCore/src/CartesianGridXYZ.cpp @@ -13,7 +13,6 @@ // Framework include files #include "DD4hep/CartesianGridXYZ.h" -#include "DD4hep/detail/SegmentationsInterna.h" #include "DDSegmentation/CartesianGridXYZ.h" // C/C++ include files diff --git a/DDCore/src/CartesianGridXZ.cpp b/DDCore/src/CartesianGridXZ.cpp index 431b06c4fe7d82caff303e9b7d0953914f82425d..8bc00bd893e6a8d0ab8f0a1432446368a21028c3 100644 --- a/DDCore/src/CartesianGridXZ.cpp +++ b/DDCore/src/CartesianGridXZ.cpp @@ -13,7 +13,6 @@ // Framework include files #include "DD4hep/CartesianGridXZ.h" -#include "DD4hep/detail/SegmentationsInterna.h" #include "DDSegmentation/CartesianGridXZ.h" // C/C++ include files diff --git a/DDCore/src/CartesianGridYZ.cpp b/DDCore/src/CartesianGridYZ.cpp index ed045595cc3f25c4351f79953b05315ce25b0b77..a7fbc27a665a00269b6b2b55b835ee61f7f0712a 100644 --- a/DDCore/src/CartesianGridYZ.cpp +++ b/DDCore/src/CartesianGridYZ.cpp @@ -13,7 +13,6 @@ // Framework include files #include "DD4hep/CartesianGridYZ.h" -#include "DD4hep/detail/SegmentationsInterna.h" #include "DDSegmentation/CartesianGridYZ.h" // C/C++ include files diff --git a/DDCore/src/CartesianStripX.cpp b/DDCore/src/CartesianStripX.cpp index 0987e4a907b7a29fa901054b47dc3ee73cb3fae8..413150051b1679e8917815ae4e0891e137b1d5c6 100644 --- a/DDCore/src/CartesianStripX.cpp +++ b/DDCore/src/CartesianStripX.cpp @@ -13,7 +13,6 @@ // Framework include files #include "DD4hep/CartesianStripX.h" -#include "DD4hep/detail/SegmentationsInterna.h" #include "DDSegmentation/CartesianStripX.h" using namespace std; diff --git a/DDCore/src/CartesianStripY.cpp b/DDCore/src/CartesianStripY.cpp index 5a41561634e01d318b7db83c251e896f37c7da88..91e38b48be56b1e490bc546977d1b5a1c71ebc50 100644 --- a/DDCore/src/CartesianStripY.cpp +++ b/DDCore/src/CartesianStripY.cpp @@ -13,7 +13,6 @@ // Framework include files #include "DD4hep/CartesianStripY.h" -#include "DD4hep/detail/SegmentationsInterna.h" #include "DDSegmentation/CartesianStripY.h" using namespace std; diff --git a/DDCore/src/CartesianStripZ.cpp b/DDCore/src/CartesianStripZ.cpp index ff564d3a466e03f487af386892eee6106228f879..8ea1333f2150e25237aeb5c7177b83113ec2e3f5 100644 --- a/DDCore/src/CartesianStripZ.cpp +++ b/DDCore/src/CartesianStripZ.cpp @@ -13,7 +13,6 @@ // Framework include files #include "DD4hep/CartesianStripZ.h" -#include "DD4hep/detail/SegmentationsInterna.h" #include "DDSegmentation/CartesianStripZ.h" using namespace std; diff --git a/DDCore/src/MultiSegmentation.cpp b/DDCore/src/MultiSegmentation.cpp index d293c7ed1c30520deccd847e2b201643648ab60e..7cc357cdce91f83fa36be5fc4ffa239dae1bac10 100644 --- a/DDCore/src/MultiSegmentation.cpp +++ b/DDCore/src/MultiSegmentation.cpp @@ -13,7 +13,6 @@ // Framework include files #include "DD4hep/MultiSegmentation.h" -#include "DD4hep/detail/SegmentationsInterna.h" #include "DDSegmentation/MultiSegmentation.h" // C/C++ include files diff --git a/DDCore/src/NoSegmentation.cpp b/DDCore/src/NoSegmentation.cpp index f48afa0c038aa637f14bf28a09bd10db6349c5b1..7b226f90f54b6210029d82853bc051402cb59ca4 100644 --- a/DDCore/src/NoSegmentation.cpp +++ b/DDCore/src/NoSegmentation.cpp @@ -13,7 +13,6 @@ // Framework include files #include "DD4hep/NoSegmentation.h" -#include "DD4hep/detail/SegmentationsInterna.h" #include "DDSegmentation/NoSegmentation.h" // C/C++ include files diff --git a/DDCore/src/PolarGridRPhi.cpp b/DDCore/src/PolarGridRPhi.cpp index 3cde97121c44a9e53c62689a12f2a53116bc870e..0bddb1fb2cebfa1c25a149e13d552a323b581926 100644 --- a/DDCore/src/PolarGridRPhi.cpp +++ b/DDCore/src/PolarGridRPhi.cpp @@ -13,7 +13,6 @@ // Framework include files #include "DD4hep/PolarGridRPhi.h" -#include "DD4hep/detail/SegmentationsInterna.h" #include "DDSegmentation/PolarGridRPhi.h" // C/C++ include files diff --git a/DDCore/src/PolarGridRPhi2.cpp b/DDCore/src/PolarGridRPhi2.cpp index d3a527de0b0dc00c7c0d8f238f727636a67b6e8d..b2976fabaecf0658431092f249eae2d23ec14ef2 100644 --- a/DDCore/src/PolarGridRPhi2.cpp +++ b/DDCore/src/PolarGridRPhi2.cpp @@ -13,7 +13,6 @@ // Framework include files #include "DD4hep/PolarGridRPhi2.h" -#include "DD4hep/detail/SegmentationsInterna.h" #include "DDSegmentation/PolarGridRPhi2.h" // C/C++ include files diff --git a/DDCore/src/SegmentationsInterna.cpp b/DDCore/src/SegmentationsInterna.cpp index 53fbc63828964ca0962a1fb6f9f42ff677d3f950..88edfed21bf56584e738e7454d92656d7f8ef70d 100644 --- a/DDCore/src/SegmentationsInterna.cpp +++ b/DDCore/src/SegmentationsInterna.cpp @@ -15,6 +15,8 @@ #include "DD4hep/detail/SegmentationsInterna.h" #include "DD4hep/InstanceCount.h" +#include "DDSegmentation/Segmentation.h" + using namespace std; using namespace dd4hep; diff --git a/DDCore/src/WaferGridXY.cpp b/DDCore/src/WaferGridXY.cpp index e365bc202c8a10ca1ea2c784242abf54f1e328c1..a555856883b4f41c77134d18051214256c74730e 100644 --- a/DDCore/src/WaferGridXY.cpp +++ b/DDCore/src/WaferGridXY.cpp @@ -13,7 +13,6 @@ // Framework include files #include "DD4hep/WaferGridXY.h" -#include "DD4hep/detail/SegmentationsInterna.h" #include "DDSegmentation/WaferGridXY.h" // C/C++ include files diff --git a/DDCore/src/plugins/ReadoutSegmentations.cpp b/DDCore/src/plugins/ReadoutSegmentations.cpp index 8da001cc7fc8709fbfe8850dfbc9a7064270090a..8105d461ce192ddc18352b032fdc26bf6e02aae8 100644 --- a/DDCore/src/plugins/ReadoutSegmentations.cpp +++ b/DDCore/src/plugins/ReadoutSegmentations.cpp @@ -12,7 +12,6 @@ //========================================================================== // Framework includes -#include "DD4hep/detail/SegmentationsInterna.h" #include "DD4hep/Factories.h" using namespace dd4hep; diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index dae82fb7d0684aa63d39635a06843caa26e14e45..88cce3e9eb8d750d0fb8f6254a4867b6196f875b 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -6,6 +6,7 @@ */ #include "DDSegmentation/CartesianGridXY.h" +#include "DD4hep/Factories.h" namespace dd4hep { namespace DDSegmentation { @@ -75,7 +76,9 @@ std::vector<double> CartesianGridXY::cellDimensions(const CellID&) const { #endif } -REGISTER_SEGMENTATION(CartesianGridXY) } /* namespace DDSegmentation */ } /* namespace dd4hep */ + + +DECLARE_SEGMENTATION(CartesianGridXY,dd4hep::create_segmentation<dd4hep::DDSegmentation::CartesianGridXY>) diff --git a/DDCore/src/segmentations/CartesianGridXYZ.cpp b/DDCore/src/segmentations/CartesianGridXYZ.cpp index 440981497657f97ff2cb01c775a85d4284ac229d..1f8d420a165866fcbd4a3b50e4737e50d6c1ec4e 100644 --- a/DDCore/src/segmentations/CartesianGridXYZ.cpp +++ b/DDCore/src/segmentations/CartesianGridXYZ.cpp @@ -6,6 +6,7 @@ */ #include "DDSegmentation/CartesianGridXYZ.h" +#include "DD4hep/Factories.h" namespace dd4hep { namespace DDSegmentation { @@ -71,7 +72,8 @@ std::vector<double> CartesianGridXYZ::cellDimensions(const CellID&) const { #endif } -REGISTER_SEGMENTATION(CartesianGridXYZ) } /* namespace DDSegmentation */ } /* namespace dd4hep */ + +DECLARE_SEGMENTATION(CartesianGridXYZ,create_segmentation<dd4hep::DDSegmentation::CartesianGridXYZ>) diff --git a/DDCore/src/segmentations/CartesianGridXZ.cpp b/DDCore/src/segmentations/CartesianGridXZ.cpp index 396dc2ec676e9ed0bb72de62a438832f1c6a4fc6..e89599ac6a4f9728c91c7d0df28e0231cb0a80e8 100644 --- a/DDCore/src/segmentations/CartesianGridXZ.cpp +++ b/DDCore/src/segmentations/CartesianGridXZ.cpp @@ -6,6 +6,7 @@ */ #include "DDSegmentation/CartesianGridXZ.h" +#include "DD4hep/Factories.h" namespace dd4hep { namespace DDSegmentation { @@ -78,7 +79,8 @@ std::vector<double> CartesianGridXZ::cellDimensions(const CellID&) const { #endif } -REGISTER_SEGMENTATION(CartesianGridXZ) } /* namespace DDSegmentation */ } /* namespace dd4hep */ + +DECLARE_SEGMENTATION(CartesianGridXZ,create_segmentation<dd4hep::DDSegmentation::CartesianGridXZ>) diff --git a/DDCore/src/segmentations/CartesianGridYZ.cpp b/DDCore/src/segmentations/CartesianGridYZ.cpp index 652506190f128bba624f76e960e6a0764676b02f..1ff9bb5c93218c1c877d0e24b69d562bd2cb94cd 100644 --- a/DDCore/src/segmentations/CartesianGridYZ.cpp +++ b/DDCore/src/segmentations/CartesianGridYZ.cpp @@ -7,6 +7,7 @@ * by Christian Grefe, CERN */ #include "DDSegmentation/CartesianGridYZ.h" +#include "DD4hep/Factories.h" namespace dd4hep { namespace DDSegmentation { @@ -76,7 +77,8 @@ std::vector<double> CartesianGridYZ::cellDimensions(const CellID&) const { #endif } -REGISTER_SEGMENTATION(CartesianGridYZ) } /* namespace DDSegmentation */ } /* namespace dd4hep */ + +DECLARE_SEGMENTATION(CartesianGridYZ,create_segmentation<dd4hep::DDSegmentation::CartesianGridYZ>) diff --git a/DDCore/src/segmentations/CartesianStripX.cpp b/DDCore/src/segmentations/CartesianStripX.cpp index 3ad57394843742fa2d2117055942529da0e18370..a105b93553bf2bd0f8d31d4451c87a83b6114f8f 100644 --- a/DDCore/src/segmentations/CartesianStripX.cpp +++ b/DDCore/src/segmentations/CartesianStripX.cpp @@ -7,6 +7,7 @@ */ #include "DDSegmentation/CartesianStripX.h" +#include "DD4hep/Factories.h" namespace dd4hep { namespace DDSegmentation { @@ -62,6 +63,6 @@ std::vector<double> CartesianStripX::cellDimensions(const CellID&) const { #endif } -REGISTER_SEGMENTATION(CartesianStripX) } // namespace DDSegmentation } /* namespace dd4hep */ +DECLARE_SEGMENTATION(CartesianStripX,create_segmentation<dd4hep::DDSegmentation::CartesianStripX>) diff --git a/DDCore/src/segmentations/CartesianStripY.cpp b/DDCore/src/segmentations/CartesianStripY.cpp index 036597541d6f4a1892310d9acb88eaa2fd017805..e2403f11e7aeb6209c9ab8db3647bc0efeada55d 100644 --- a/DDCore/src/segmentations/CartesianStripY.cpp +++ b/DDCore/src/segmentations/CartesianStripY.cpp @@ -7,6 +7,7 @@ */ #include "DDSegmentation/CartesianStripY.h" +#include "DD4hep/Factories.h" namespace dd4hep { namespace DDSegmentation { @@ -62,6 +63,6 @@ std::vector<double> CartesianStripY::cellDimensions(const CellID&) const { #endif } -REGISTER_SEGMENTATION(CartesianStripY) } // namespace DDSegmentation } /* namespace dd4hep */ +DECLARE_SEGMENTATION(CartesianStripY,create_segmentation<dd4hep::DDSegmentation::CartesianStripY>) diff --git a/DDCore/src/segmentations/CartesianStripZ.cpp b/DDCore/src/segmentations/CartesianStripZ.cpp index 8b759010852822a197895ba912ef9262a6863bc7..d2e27ac6dbf47970f55e3133893dc4abdbc06bfa 100644 --- a/DDCore/src/segmentations/CartesianStripZ.cpp +++ b/DDCore/src/segmentations/CartesianStripZ.cpp @@ -7,6 +7,7 @@ */ #include "DDSegmentation/CartesianStripZ.h" +#include "DD4hep/Factories.h" namespace dd4hep { namespace DDSegmentation { @@ -62,6 +63,6 @@ std::vector<double> CartesianStripZ::cellDimensions(const CellID&) const { #endif } -REGISTER_SEGMENTATION(CartesianStripZ) } // namespace DDSegmentation } /* namespace dd4hep */ +DECLARE_SEGMENTATION(CartesianStripZ,create_segmentation<dd4hep::DDSegmentation::CartesianStripZ>) diff --git a/DDCore/src/segmentations/GridPhiEta.cpp b/DDCore/src/segmentations/GridPhiEta.cpp index 0b4b640305621ade4bf0ca6360bba2799aa31bbd..7a8b0e5415a72b3a30f400d05e3f7365ed2745cd 100644 --- a/DDCore/src/segmentations/GridPhiEta.cpp +++ b/DDCore/src/segmentations/GridPhiEta.cpp @@ -1,5 +1,6 @@ #include "DDSegmentation/GridPhiEta.h" #include "DDSegmentation/SegmentationUtil.h" +#include "DD4hep/Factories.h" namespace dd4hep { namespace DDSegmentation { @@ -55,7 +56,7 @@ double GridPhiEta::phi(const CellID& cID) const { CellID phiValue = _decoder->get(cID, m_phiID); return binToPosition(phiValue, 2.*M_PI/(double)m_phiBins, m_offsetPhi); } -REGISTER_SEGMENTATION(GridPhiEta) } } +DECLARE_SEGMENTATION(GridPhiEta,create_segmentation<dd4hep::DDSegmentation::GridPhiEta>) diff --git a/DDCore/src/segmentations/GridRPhiEta.cpp b/DDCore/src/segmentations/GridRPhiEta.cpp index 00335d125f3f5cc0de4f9b3b5132fd00edda0b56..dafff9915708e0dbf5d4ead9aefd4986c4095562 100644 --- a/DDCore/src/segmentations/GridRPhiEta.cpp +++ b/DDCore/src/segmentations/GridRPhiEta.cpp @@ -1,5 +1,6 @@ #include "DDSegmentation/GridRPhiEta.h" #include "DDSegmentation/SegmentationUtil.h" +#include "DD4hep/Factories.h" namespace dd4hep { namespace DDSegmentation { @@ -47,7 +48,7 @@ double GridRPhiEta::r(const CellID& cID) const { CellID rValue = _decoder->get(cID, m_rID); return binToPosition(rValue, m_gridSizeR, m_offsetR); } -REGISTER_SEGMENTATION(GridRPhiEta) } } +DECLARE_SEGMENTATION(GridRPhiEta,create_segmentation<dd4hep::DDSegmentation::GridRPhiEta>) diff --git a/DDCore/src/segmentations/MegatileLayerGridXY.cpp b/DDCore/src/segmentations/MegatileLayerGridXY.cpp index 1bb022e00afba32fd72a121a95f9914daee0e86d..bbe7c6c5a5582e687f0d40f5779a4541fa8610d5 100644 --- a/DDCore/src/segmentations/MegatileLayerGridXY.cpp +++ b/DDCore/src/segmentations/MegatileLayerGridXY.cpp @@ -7,6 +7,7 @@ */ #include "DDSegmentation/MegatileLayerGridXY.h" +#include "DD4hep/Factories.h" #undef NDEBUG #include <cmath> @@ -183,7 +184,8 @@ namespace dd4hep { #endif } - REGISTER_SEGMENTATION(MegatileLayerGridXY) } /* namespace DDSegmentation */ } /* namespace dd4hep */ + +DECLARE_SEGMENTATION(MegatileLayerGridXY,create_segmentation<dd4hep::DDSegmentation::MegatileLayerGridXY>) diff --git a/DDCore/src/segmentations/MultiSegmentation.cpp b/DDCore/src/segmentations/MultiSegmentation.cpp index 3c32418965bd26d0f250b37fba7625a63a76fe14..bdc3b93eeca0e812d22f1c9b74dd6d789fba1314 100644 --- a/DDCore/src/segmentations/MultiSegmentation.cpp +++ b/DDCore/src/segmentations/MultiSegmentation.cpp @@ -6,6 +6,8 @@ */ #include "DDSegmentation/MultiSegmentation.h" +#include "DD4hep/Factories.h" + #include <iomanip> #include <stdexcept> #include <iostream> @@ -98,7 +100,7 @@ namespace dd4hep { return subsegmentation(cID).cellDimensions(cID); } - REGISTER_SEGMENTATION(MultiSegmentation) - } /* namespace DDSegmentation */ } /* namespace dd4hep */ + +DECLARE_SEGMENTATION(MultiSegmentation,create_segmentation<dd4hep::DDSegmentation::MultiSegmentation>) diff --git a/DDCore/src/segmentations/NoSegmentation.cpp b/DDCore/src/segmentations/NoSegmentation.cpp index ae3f50049f075a4f1fd89d2902b8bb1d0862e676..67ba05b6936ae04e05d41429ff55d0293a7f1882 100644 --- a/DDCore/src/segmentations/NoSegmentation.cpp +++ b/DDCore/src/segmentations/NoSegmentation.cpp @@ -6,6 +6,7 @@ */ #include "DDSegmentation/NoSegmentation.h" +#include "DD4hep/Factories.h" namespace dd4hep { namespace DDSegmentation { @@ -36,7 +37,7 @@ namespace dd4hep { return vID; } -REGISTER_SEGMENTATION(NoSegmentation) } /* namespace DDSegmentation */ } /* namespace dd4hep */ +DECLARE_SEGMENTATION(NoSegmentation,create_segmentation<dd4hep::DDSegmentation::NoSegmentation>) diff --git a/DDCore/src/segmentations/PolarGridRPhi.cpp b/DDCore/src/segmentations/PolarGridRPhi.cpp index 7822119453dafb73bbf326724f3c3047491127fd..112af39bdff022caa4ec5d65c660b18dc3c0da1a 100644 --- a/DDCore/src/segmentations/PolarGridRPhi.cpp +++ b/DDCore/src/segmentations/PolarGridRPhi.cpp @@ -6,6 +6,7 @@ */ #include "DDSegmentation/PolarGridRPhi.h" +#include "DD4hep/Factories.h" namespace dd4hep { namespace DDSegmentation { @@ -81,7 +82,7 @@ std::vector<double> PolarGridRPhi::cellDimensions(const CellID& cID) const { #endif } -REGISTER_SEGMENTATION(PolarGridRPhi) } /* namespace DDSegmentation */ } /* namespace dd4hep */ +DECLARE_SEGMENTATION(PolarGridRPhi,create_segmentation<dd4hep::DDSegmentation::PolarGridRPhi>) diff --git a/DDCore/src/segmentations/PolarGridRPhi2.cpp b/DDCore/src/segmentations/PolarGridRPhi2.cpp index 73c1d29e499848a8096d04209a8c5829e164c3c6..6bbf5aa71c3fc05bad27f1563b9e63db7151be80 100644 --- a/DDCore/src/segmentations/PolarGridRPhi2.cpp +++ b/DDCore/src/segmentations/PolarGridRPhi2.cpp @@ -6,6 +6,7 @@ */ #include "DDSegmentation/PolarGridRPhi2.h" +#include "DD4hep/Factories.h" namespace dd4hep { namespace DDSegmentation { @@ -103,7 +104,7 @@ std::vector<double> PolarGridRPhi2::cellDimensions(const CellID& cID) const { #endif } -REGISTER_SEGMENTATION(PolarGridRPhi2) } /* namespace DDSegmentation */ } /* namespace dd4hep */ +DECLARE_SEGMENTATION(PolarGridRPhi2,create_segmentation<dd4hep::DDSegmentation::PolarGridRPhi2>) diff --git a/DDCore/src/segmentations/ProjectiveCylinder.cpp b/DDCore/src/segmentations/ProjectiveCylinder.cpp index 37c5ce675509611c912c1c2be78f0ee2c36f1a91..6a4e021d961f384a3b59be73c6cf03f6c935cbf1 100644 --- a/DDCore/src/segmentations/ProjectiveCylinder.cpp +++ b/DDCore/src/segmentations/ProjectiveCylinder.cpp @@ -7,6 +7,7 @@ #include "DDSegmentation/ProjectiveCylinder.h" #include "DDSegmentation/SegmentationUtil.h" +#include "DD4hep/Factories.h" #define _USE_MATH_DEFINES #include <cmath> @@ -80,7 +81,8 @@ double ProjectiveCylinder::phi(const CellID& cID) const { return 2. * M_PI * ((double) phiIndex + 0.5) / (double) _phiBins; } -REGISTER_SEGMENTATION(ProjectiveCylinder) } /* namespace DDSegmentation */ } /* namespace dd4hep */ + +DECLARE_SEGMENTATION(ProjectiveCylinder,create_segmentation<dd4hep::DDSegmentation::ProjectiveCylinder>) diff --git a/DDCore/src/segmentations/SegmentationFactory.cpp b/DDCore/src/segmentations/SegmentationFactory.cpp deleted file mode 100644 index 4806a4475df0476e7732858c32348b6066f81ae0..0000000000000000000000000000000000000000 --- a/DDCore/src/segmentations/SegmentationFactory.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SegmentationFactory.cpp - * - * Created on: Dec 15, 2013 - * Author: Christian Grefe, CERN - */ - -#include "DDSegmentation/SegmentationFactory.h" - -namespace dd4hep { -namespace DDSegmentation { - -using std::map; -using std::vector; - -/// Default constructor. Takes the class name as argument and takes care of registration with the factory -SegmentationCreatorBase::SegmentationCreatorBase(const std::string& name) { - SegmentationFactory::instance()->registerSegmentation(name, this); -} - -/// Initialize the global factory instance -SegmentationFactory* SegmentationFactory::_instance = 0; - -/// Access to the global factory instance -SegmentationFactory* SegmentationFactory::instance() { - if (not _instance) { - _instance = new SegmentationFactory(); - } - return _instance; -} - -/// Create a new segmentation object with the given type name. Returns NULL if type name is unknown. -Segmentation* SegmentationFactory::create(const std::string& name, const std::string& identifier) const { - map<std::string, SegmentationCreatorBase*>::const_iterator it; - it = _segmentations.find(name); - if (it != _segmentations.end()) { - return it->second->create(identifier); - } - return 0; -} - -/// Access to the list of registered segmentations -vector<std::string> SegmentationFactory::registeredSegmentations() const { - vector<std::string> segmentationNames; - map<std::string, SegmentationCreatorBase*>::const_iterator it; - for (it = _segmentations.begin(); it != _segmentations.end(); ++ it) { - segmentationNames.emplace_back(it->first); - } - return segmentationNames; -} - -/// Registers a new SegmentationCreator with the factory -void SegmentationFactory::registerSegmentation(const std::string& name, SegmentationCreatorBase* creator) { - _segmentations[name] = creator; -} - -} /* namespace DDSegmentation */ -} /* namespace dd4hep */ diff --git a/DDCore/src/segmentations/TiledLayerGridXY.cpp b/DDCore/src/segmentations/TiledLayerGridXY.cpp index aa46448d9c2c9f73a5ace2dee03b1bafe67f9df7..36ac181553f022f7579287080fbd75b2bd643e82 100644 --- a/DDCore/src/segmentations/TiledLayerGridXY.cpp +++ b/DDCore/src/segmentations/TiledLayerGridXY.cpp @@ -6,6 +6,7 @@ */ #include "DDSegmentation/TiledLayerGridXY.h" +#include "DD4hep/Factories.h" // C/C++ includes #include <algorithm> @@ -122,7 +123,8 @@ std::vector<double> TiledLayerGridXY::cellDimensions(const CellID&) const { #endif } -REGISTER_SEGMENTATION(TiledLayerGridXY) } /* namespace DDSegmentation */ } /* namespace dd4hep */ + +DECLARE_SEGMENTATION(TiledLayerGridXY,create_segmentation<dd4hep::DDSegmentation::TiledLayerGridXY>) diff --git a/DDCore/src/segmentations/WaferGridXY.cpp b/DDCore/src/segmentations/WaferGridXY.cpp index 5b7ad38485132393ea76eb93ca1081df8582ce9e..52c9a4e08df7546e13727eaddc34e38634d3ce3d 100644 --- a/DDCore/src/segmentations/WaferGridXY.cpp +++ b/DDCore/src/segmentations/WaferGridXY.cpp @@ -6,6 +6,7 @@ */ #include "DDSegmentation/WaferGridXY.h" +#include "DD4hep/Factories.h" namespace dd4hep { namespace DDSegmentation { @@ -126,7 +127,7 @@ std::vector<double> WaferGridXY::cellDimensions(const CellID&) const { #endif } -REGISTER_SEGMENTATION(WaferGridXY) - } /* namespace DDSegmentation */ } /* namespace dd4hep */ + +DECLARE_SEGMENTATION(WaferGridXY,create_segmentation<dd4hep::DDSegmentation::WaferGridXY>)