From efbf4487252d80b248c5bec970bbe5049dae5103 Mon Sep 17 00:00:00 2001
From: Shaun <shaun.roe@cern.ch>
Date: Mon, 14 Apr 2025 21:48:08 +0200
Subject: [PATCH 1/2] solve one warning

---
 GeoModelCore/GeoModelKernel/GeoModelKernel/GeoRectSurface.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoRectSurface.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoRectSurface.h
index c5a9935c9..1e95164c1 100644
--- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoRectSurface.h
+++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoRectSurface.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 
 /*
@@ -36,11 +36,11 @@ class GeoRectSurface : public GeoVSurfaceShape
     return m_yHalfLength;
   }
 
-  virtual const std::string & type () const{
+  virtual const std::string & type () const override final{
      return s_classType;
   }
 
-  virtual ShapeType typeID () const{
+  virtual ShapeType typeID () const override final{
      return s_classTypeID;
   }
 
-- 
GitLab


From fa3835f6003d667bce1f96eeefa9525346eae9f2 Mon Sep 17 00:00:00 2001
From: Shaun <shaun.roe@cern.ch>
Date: Mon, 14 Apr 2025 22:49:31 +0200
Subject: [PATCH 2/2] clear remaining warnings

---
 .../GeoModelHelpers/src/GeoDeDuplicator.cxx       | 10 ++++++++--
 GeoModelCore/GeoModelHelpers/src/cloneVolume.cxx  | 15 +++++++++++----
 .../GeoModelHelpers/src/getChildNodesWithTrf.cxx  | 13 +++++++++----
 .../GeoModelHelpers/tests/testFullPhysVol.cxx     |  5 +++--
 .../GeoModelKernel/GeoAnnulusSurface.h            |  6 +++---
 .../GeoModelKernel/GeoCountVolAction.h            |  8 ++++----
 .../GeoModelKernel/GeoDiamondSurface.h            |  4 ++--
 .../GeoModelKernel/GeoTrapezoidSurface.h          |  6 +++---
 8 files changed, 43 insertions(+), 24 deletions(-)

diff --git a/GeoModelCore/GeoModelHelpers/src/GeoDeDuplicator.cxx b/GeoModelCore/GeoModelHelpers/src/GeoDeDuplicator.cxx
index 0e0aba4cf..72e26bf83 100644
--- a/GeoModelCore/GeoModelHelpers/src/GeoDeDuplicator.cxx
+++ b/GeoModelCore/GeoModelHelpers/src/GeoDeDuplicator.cxx
@@ -3,6 +3,8 @@
 */
 
 #include "GeoModelHelpers/GeoDeDuplicator.h"
+#include <ios>
+#include <type_traits>
 
 GeoDeDuplicator::TrfSet GeoDeDuplicator::s_trfStore{};
 GeoDeDuplicator::ShapeSet GeoDeDuplicator::s_shapeStore{};
@@ -12,6 +14,10 @@ GeoDeDuplicator::GeoIdMap GeoDeDuplicator::s_geoIds{};
 
 namespace {
     std::mutex s_mutex{};
+    template<class A, class B>
+    bool compare(B& b) {
+      return typeid(b)  == typeid(A);
+    }
 }
 
 void GeoDeDuplicator::setShapeDeDuplication(bool enable){
@@ -124,10 +130,10 @@ PVLink GeoDeDuplicator::clone(PVConstLink cloneMe) const {
     for(unsigned int chNode =0; chNode < cloneMe->getNChildNodes(); ++chNode) {
         GeoIntrusivePtr<const GeoGraphNode>node{*cloneMe->getChildNode(chNode)};
         /** transform nodes */
-        if (typeid(*node) == typeid(GeoAlignableTransform)) {
+        if (compare<GeoAlignableTransform>(*node)) {
             const auto geoTrf = dynamic_pointer_cast<const GeoAlignableTransform>(node);
             newVol->add(make_intrusive<GeoAlignableTransform>(geoTrf->getDefTransform()));
-        } else if (typeid(*node) == typeid(GeoTransform)) {
+        } else if (compare<GeoTransform>(*node)) {
             const auto geoTrf = dynamic_pointer_cast<const GeoTransform>(node);
             auto geoTrfNonConst = const_pointer_cast(geoTrf);
             newVol->add(cacheTransform(geoTrfNonConst));
diff --git a/GeoModelCore/GeoModelHelpers/src/cloneVolume.cxx b/GeoModelCore/GeoModelHelpers/src/cloneVolume.cxx
index 6177229d4..ddc8dc1e5 100644
--- a/GeoModelCore/GeoModelHelpers/src/cloneVolume.cxx
+++ b/GeoModelCore/GeoModelHelpers/src/cloneVolume.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 #include "GeoModelHelpers/cloneVolume.h"
 #include "GeoModelHelpers/getChildNodesWithTrf.h"
@@ -7,18 +7,25 @@
 #include "GeoModelKernel/GeoFullPhysVol.h"
 #include "GeoModelKernel/GeoPhysVol.h"
 
+namespace{
+  template<class A, class B>
+  bool compare(B &b) {
+    return typeid(b)  == typeid(A);
+  }
+}
+
 PVLink cloneVolume(const PVLink& volume, bool allowShared) {
     PVLink newVolume{volume};
     if (!allowShared || hasFullPhysVolInTree(volume)) {
-        if (typeid(*volume) == typeid(GeoPhysVol)) {
+        if (compare<GeoPhysVol>(*volume)) {
             newVolume = make_intrusive<GeoPhysVol>(volume->getLogVol());
-        } else if (typeid(*volume) == typeid(GeoFullPhysVol)) {
+        } else if (compare<GeoFullPhysVol>(*volume)) {
             newVolume = make_intrusive<GeoFullPhysVol>(volume->getLogVol());
         }
         for (unsigned int ch = 0; ch < volume->getNChildNodes(); ++ch){
           const GeoGraphNode* node = (*volume->getChildNode(ch));
           
-          if (typeid(*node) == typeid(GeoPhysVol) || typeid(*node) == typeid(GeoFullPhysVol)) {    
+          if (compare<GeoPhysVol>(node)| compare<GeoFullPhysVol>(node)) {    
             const GeoVPhysVol* childConstVol{static_cast<const GeoVPhysVol*>(node)};
             GeoVPhysVol* childVol{const_cast<GeoVPhysVol*>(childConstVol)};
             newVolume->add(cloneVolume(childVol, allowShared));
diff --git a/GeoModelCore/GeoModelHelpers/src/getChildNodesWithTrf.cxx b/GeoModelCore/GeoModelHelpers/src/getChildNodesWithTrf.cxx
index f1d8fec4b..ccbd9e052 100644
--- a/GeoModelCore/GeoModelHelpers/src/getChildNodesWithTrf.cxx
+++ b/GeoModelCore/GeoModelHelpers/src/getChildNodesWithTrf.cxx
@@ -11,7 +11,12 @@
 #include "GeoModelKernel/GeoFullPhysVol.h"
 
 namespace {
-    constexpr std::string_view dummyNodeName{"ANON"};
+  constexpr std::string_view dummyNodeName{"ANON"};
+  template<class A, class B>
+  bool compare(B & b) {
+    return typeid(b)  == typeid(A);
+  }
+
 }
 
 
@@ -20,7 +25,7 @@ namespace {
     volume{curs.getVolume()},
     nodeName{curs.getName()},
     isAlignable{curs.hasAlignableTransform()},
-    isSensitive{typeid(*volume) == typeid(GeoFullPhysVol)},
+    isSensitive{compare<GeoFullPhysVol>(*volume)},
     volumeId{static_cast<const std::optional<int>&>(curs.getId())} {
     //// Do not specify a node name if it's a dummy one
     if (nodeName == dummyNodeName) {
@@ -95,8 +100,8 @@ std::vector<GeoChildNodeWithTrf> getAllSubVolumes(PVConstLink physVol) {
 }
 
 bool hasFullPhysVolInTree(const PVConstLink& physVol) {
-    if (typeid(*physVol) == typeid(GeoFullPhysVol) ||
-        typeid(*physVol) == typeid(GeoVFullPhysVol)){
+    if (compare<GeoFullPhysVol>(*physVol) ||
+        compare<GeoVFullPhysVol>(*physVol)){
         return true;
     }
     for (unsigned int ch = 0; ch < physVol->getNChildVols(); ++ch) {
diff --git a/GeoModelCore/GeoModelHelpers/tests/testFullPhysVol.cxx b/GeoModelCore/GeoModelHelpers/tests/testFullPhysVol.cxx
index b834b3018..06e0a723a 100644
--- a/GeoModelCore/GeoModelHelpers/tests/testFullPhysVol.cxx
+++ b/GeoModelCore/GeoModelHelpers/tests/testFullPhysVol.cxx
@@ -1,4 +1,4 @@
-// Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 
 
 #include <GeoModelKernel/GeoBox.h>
@@ -89,8 +89,9 @@ int main(int argc, char *argv[]){
     while (cParent) {        
       std::optional<int> query = cParent->getIdOfChildVol(0);
         if (!query) {
+            auto testObj = *cParent->getChildVol(0);
             std::cerr<<__FILE__<<":"<<__LINE__<<" Failed to obtain a valid child volume ID. Expected "<<currentK
-                     <<" "<<typeid(*cParent->getChildVol(0)).name()<<std::endl;
+                     <<" "<<typeid(testObj).name()<<std::endl;
             return EXIT_FAILURE;
         }
         unsigned int parentID = *query;
diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoAnnulusSurface.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoAnnulusSurface.h
index 7dc31d3dc..b2f05a204 100644
--- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoAnnulusSurface.h
+++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoAnnulusSurface.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 
 /*
@@ -66,11 +66,11 @@ class GeoAnnulusSurface : public GeoVSurfaceShape
       // coming soon!
       //bool isInside(double x, double y) const;
 
-      virtual const std::string & type() const{
+      virtual const std::string & type() const override final{
         return s_classType;
       }
 
-      virtual ShapeType typeID() const{
+      virtual ShapeType typeID() const override final{
         return s_classTypeID;
       }
 
diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoCountVolAction.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoCountVolAction.h
index 0dbf06058..5d04c4931 100644
--- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoCountVolAction.h
+++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoCountVolAction.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef GEOMODELKERNEL_GEOCOUNTVOLACTION_H
@@ -14,13 +14,13 @@ class GeoCountVolAction : public GeoNodeAction
   virtual ~GeoCountVolAction() = default;
 
   //	Handles a physical volume.
-  virtual void handlePhysVol (const GeoPhysVol *);
+  virtual void handlePhysVol (const GeoPhysVol *) override;
   
   //	Handles a physical volume.
-  virtual void handleFullPhysVol (const GeoFullPhysVol *);
+  virtual void handleFullPhysVol (const GeoFullPhysVol *) override;
   
   //	Handles a Serial Transformer
-  virtual void handleSerialTransformer (const GeoSerialTransformer  *st);
+  virtual void handleSerialTransformer (const GeoSerialTransformer  *st) override;
   
   //	Handles a virtual surface.
   virtual void handleVSurface (const GeoVSurface *) override;
diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoDiamondSurface.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoDiamondSurface.h
index bcf1b62cd..3babff966 100644
--- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoDiamondSurface.h
+++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoDiamondSurface.h
@@ -54,11 +54,11 @@ class GeoDiamondSurface : public GeoVSurfaceShape
     return m_YtopHalf;
   }  
 
-  virtual const std::string & type () const{
+  virtual const std::string & type () const override final{
      return s_classType;
   }
 
-  virtual ShapeType typeID () const{
+  virtual ShapeType typeID () const override final{
      return s_classTypeID;
   }
 
diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoTrapezoidSurface.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoTrapezoidSurface.h
index 91a16c8dc..8dc31bd88 100644
--- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoTrapezoidSurface.h
+++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoTrapezoidSurface.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 
 /*
@@ -42,11 +42,11 @@ class GeoTrapezoidSurface : public GeoVSurfaceShape
     return m_yHalfLength;
   }  
 
-  virtual const std::string & type () const{
+  virtual const std::string & type () const override final{
      return s_classType;
   }
 
-  virtual ShapeType typeID () const{
+  virtual ShapeType typeID () const override final{
      return s_classTypeID;
   }
 
-- 
GitLab