diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoPhysVol.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoPhysVol.h index bd2ac00fd6c7b6df49dfa844034f78bdff67526c..2e5988637d10add49e3a22dc1214487d1354055f 100644 --- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoPhysVol.h +++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoPhysVol.h @@ -1,5 +1,5 @@ /* - 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; }; diff --git a/GeoModelCore/GeoModelKernel/src/GeoPhysVol.cxx b/GeoModelCore/GeoModelKernel/src/GeoPhysVol.cxx index 7b6161be085854086be3704e9a8d9981129714aa..6f764284fe95676254476ef6b79dcdfb8c348b93 100755 --- a/GeoModelCore/GeoModelKernel/src/GeoPhysVol.cxx +++ b/GeoModelCore/GeoModelKernel/src/GeoPhysVol.cxx @@ -1,5 +1,5 @@ /* - 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); + }