Skip to content
Snippets Groups Projects
Commit 871a9df5 authored by Johannes Junggeburth's avatar Johannes Junggeburth :dog2:
Browse files

Transform the daughter pointers into GeoModelIntrusivePtrs

parent 00909f63
No related branches found
No related tags found
1 merge request!228GeoPhysVol / GeoFullPhysVol - Pointer managment clean up
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEOMODELKERNEL_GEOPHYSVOL_H
......@@ -28,14 +28,10 @@
#include <mutex>
class GeoPhysVol : public GeoVPhysVol
{
class GeoPhysVol : public GeoVPhysVol {
public:
GeoPhysVol(const GeoLogVol* LogVol);
GeoPhysVol(const GeoPhysVol &right) = delete;
GeoPhysVol & operator=(const GeoPhysVol &right) = delete;
/// Adds a Graph Node to the Geometry Graph
virtual void add(GeoGraphNode* graphNode) override final;
......@@ -72,10 +68,10 @@ class GeoPhysVol : public GeoVPhysVol
virtual const GeoGraphNode * const *findChildNode(const GeoGraphNode *n) const override final;
protected:
virtual ~GeoPhysVol() override;
virtual ~GeoPhysVol() = default;
private:
std::vector<const GeoGraphNode*> m_daughters;
std::vector<GeoIntrusivePtr<GeoGraphNode>> m_daughters{};
mutable std::mutex m_muxVec;
};
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoModelKernel/GeoPhysVol.h"
......@@ -17,17 +17,11 @@ GeoPhysVol::GeoPhysVol(const GeoLogVol* LogVol)
{
}
GeoPhysVol::~GeoPhysVol()
{
std::scoped_lock<std::mutex> lk(m_muxVec);
for(const GeoGraphNode* daughter : m_daughters) daughter->unref();
}
void GeoPhysVol::add(GeoGraphNode* graphNode)
{
std::scoped_lock<std::mutex> lk(m_muxVec);
m_daughters.push_back(graphNode);
graphNode->ref();
graphNode->dockTo(this);
}
......@@ -199,20 +193,17 @@ unsigned int GeoPhysVol::getNChildNodes() const
return m_daughters.size();
}
const GeoGraphNode * const * GeoPhysVol::getChildNode(unsigned int i) const
{
const GeoGraphNode * const * GeoPhysVol::getChildNode(unsigned int i) const {
std::scoped_lock<std::mutex> lk(m_muxVec);
return &(m_daughters[i]);
return m_daughters[i];
}
const GeoGraphNode * const * GeoPhysVol::findChildNode(const GeoGraphNode * n) const
{
const GeoGraphNode * const * GeoPhysVol::findChildNode(const GeoGraphNode * n) const {
std::scoped_lock<std::mutex> lk(m_muxVec);
std::vector<const GeoGraphNode *>::const_iterator i = std::find(m_daughters.begin(),m_daughters.end(),n);
std::vector<GeoIntrusivePtr<GeoGraphNode>>::const_iterator i = std::find(m_daughters.begin(),m_daughters.end(),n);
if (i==m_daughters.end()) {
return nullptr;
}
else {
return &*i;
}
return (*i);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment