Skip to content
Snippets Groups Projects
Commit 301eae5f authored by Markus Frank's avatar Markus Frank
Browse files

Convert segmentations to DD4hep handles

parent 552432f0
No related branches found
No related tags found
No related merge requests found
...@@ -110,16 +110,24 @@ namespace DD4hep { ...@@ -110,16 +110,24 @@ namespace DD4hep {
/// Standard constructor /// Standard constructor
SegmentationImplementation(DDSegmentation::BitField64* decoder); SegmentationImplementation(DDSegmentation::BitField64* decoder);
/// Default destructor /// Default destructor
virtual ~SegmentationImplementation() {} virtual ~SegmentationImplementation();
}; };
/// Standard constructor
template <typename IMP> inline template <typename IMP> inline
SegmentationImplementation<IMP>::SegmentationImplementation(DDSegmentation::BitField64* decoder) SegmentationImplementation<IMP>::SegmentationImplementation(DDSegmentation::BitField64* decode)
: SegmentationObject(0), implementation(decoder) : SegmentationObject(0), implementation(decode)
{ {
this->segmentation = &implementation; this->segmentation = &implementation;
} }
/// Default destructor
template <typename IMP> inline
SegmentationImplementation<IMP>::~SegmentationImplementation()
{
this->segmentation = 0; // Prevent deletion! We have the object aggregated!
}
/// Handle class supporting generic Segmentation of sensitive detectors /// Handle class supporting generic Segmentation of sensitive detectors
/** /**
* *
......
...@@ -122,24 +122,24 @@ void SegmentationObject::neighbours(const CellID& cell, std::set<CellID>& nb) co ...@@ -122,24 +122,24 @@ void SegmentationObject::neighbours(const CellID& cell, std::set<CellID>& nb) co
} }
/// Constructor to used when creating a new object /// Constructor to used when creating a new object
Segmentation::Segmentation(const string& typ, const string& nam, BitField64* decoder) : Handle<Implementation>() Segmentation::Segmentation(const string& typ, const string& nam, BitField64* dec) : Handle<Implementation>()
{ {
string type = "segmentation_constructor__"+typ; string type = "segmentation_constructor__"+typ;
SegmentationObject* obj = PluginService::Create<SegmentationObject*>(type, decoder); SegmentationObject* obj = PluginService::Create<SegmentationObject*>(type, dec);
if ( obj != 0 ) { if ( obj != 0 ) {
assign(obj, nam, typ); assign(obj, nam, typ);
if ( !nam.empty() ) obj->setName(nam); if ( !nam.empty() ) obj->setName(nam);
return;
} }
#if 0 #if 0
BaseSegmentation* s = DDSegmentation::SegmentationFactory::instance()->create(typ); BaseSegmentation* s = DDSegmentation::SegmentationFactory::instance()->create(typ);
if (s != 0) { if (s != 0) {
assign(new Object(s), nam, ""); assign(new Object(s), nam, "");
if ( !nam.empty() ) s->setName(nam); if ( !nam.empty() ) s->setName(nam);
return;
} }
#endif #endif
else { except("Segmentation","FAILED to create segmentation: %s. [Missing factory]",typ.c_str());
throw runtime_error("FAILED to create segmentation: " + typ + ". Missing factory method for: " + typ + "!");
}
} }
/// Accessor: Segmentation type /// Accessor: Segmentation type
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment