From 930ed375799df1d24e2a13b927cd1ace459d5699 Mon Sep 17 00:00:00 2001
From: Johannes Josef Junggeburth <johannes.josef.junggeburth@cern.ch>
Date: Thu, 30 Jan 2025 17:25:27 +0100
Subject: [PATCH] GeoModelKernel - Tidy the GeoAccessVolumeAction & minor tidy
 in the GeoMaterial & GeoVolumeCursor

---
 .../GeoModelKernel/GeoAccessVolumeAction.h    | 39 ++++++++-----------
 .../GeoModelKernel/GeoMaterial.h              | 29 +++++---------
 .../GeoModelKernel/GeoNodeAction.h            | 12 +++---
 .../src/GeoAccessVolumeAction.cxx             | 34 +++++-----------
 .../GeoModelKernel/src/GeoNodeAction.cxx      | 16 ++------
 .../GeoModelKernel/src/GeoVolumeCursor.cxx    | 13 +++----
 6 files changed, 48 insertions(+), 95 deletions(-)

diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoAccessVolumeAction.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoAccessVolumeAction.h
index 2399f4c4a..113568fd1 100644
--- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoAccessVolumeAction.h
+++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoAccessVolumeAction.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 GeoAccessVolumeAction_h
@@ -25,7 +25,7 @@ class GeoAccessVolumeAction final : public GeoNodeAction
  public:
 
   GeoAccessVolumeAction (unsigned int Index, const GeoVAlignmentStore* store);
-  virtual ~GeoAccessVolumeAction() override;
+  virtual ~GeoAccessVolumeAction()  =default; 
 
   /// Handles a Transform.
   virtual void handleTransform (const GeoTransform *xform) override;
@@ -70,49 +70,42 @@ class GeoAccessVolumeAction final : public GeoNodeAction
   virtual void handleSerialIdentifier(const GeoSerialIdentifier *sI) override;
 
  private:
-
-  GeoAccessVolumeAction(const GeoAccessVolumeAction &right);
-  GeoAccessVolumeAction & operator=(const GeoAccessVolumeAction &right);
-
   /// Returns a pointer to the ith physical volume under this one.
-  PVConstLink m_volume;
+  PVConstLink m_volume{};
 
   /// The transformation to the ith volume.
-  GeoTrf::Transform3D m_transform;
+  GeoTrf::Transform3D m_transform{GeoTrf::Transform3D::Identity()};
 
   /// The default transformation to the ith volume.
-  GeoTrf::Transform3D m_defTransform;
+  GeoTrf::Transform3D m_defTransform{GeoTrf::Transform3D::Identity()};
 
   /// The volume which we are interested in seeking.
-  unsigned int m_index;
+  unsigned int m_index{0};
 
   /// The volume which we are interested in seeking.
-  unsigned int m_counter;
+  unsigned int m_counter{0};
 
   /// The name of the volume.  From a nametag or a serial denominator.
-  mutable std::string m_name;
-
-  /// The identifier of the volume.  From an identifier tag.
-  mutable Query<int> m_id;
+  mutable std::string m_name{};
 
   /// A pointer to a name tag.  If the volume is named.
-  const GeoNameTag *m_nameTag;
+  const GeoNameTag *m_nameTag{nullptr};
 
   /// A pointer to a serial denominator.  If one exists.
-  const GeoSerialDenominator *m_serialDenominator;
+  const GeoSerialDenominator *m_serialDenominator{nullptr};
 
   /// A pointer to an identifier tag.  If the volume is identified.
-  const GeoIdentifierTag *m_idTag;
+  const GeoIdentifierTag *m_idTag{nullptr};
 
   /// List of Pending Transformations.
-  std::vector<const GeoTransform *>  m_pendingTransformList;
+  std::vector<const GeoTransform *>  m_pendingTransformList{};
 
   /// Position of the serial denominator.  Used to assign a numeric suffix to the name, eg BaseName+99
-  unsigned int m_serialDenomPosition;
+  unsigned int m_serialDenomPosition{0};
 
-  const GeoSerialIdentifier *m_serialIdentifier;
-  unsigned int m_serialIdentPosition;
-  const GeoVAlignmentStore* m_alignStore;
+  const GeoSerialIdentifier *m_serialIdentifier{nullptr};
+  unsigned int m_serialIdentPosition{0};
+  const GeoVAlignmentStore* m_alignStore{nullptr};
 };
 
 #endif
diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoMaterial.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoMaterial.h
index 8050cbf9f..907a7f7b7 100644
--- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoMaterial.h
+++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoMaterial.h
@@ -74,14 +74,18 @@ class GeoMaterial : public RCBase {
   double getFraction (int i) const;
   
   // The name of the material.
-  const std::string& getName () const;
-  
+  const std::string& getName () const{
+      return m_name;
+  }
   // The density of the material.
-  const double& getDensity () const;
-  
+   double getDensity () const{
+      return m_density;
+   }
   // Gives an integral identifier for the material.  For
   // convenience.
-  const unsigned int& getID () const;
+  unsigned int getID () const {
+      return m_iD;
+  }
   
  protected:
   virtual ~GeoMaterial() = default;
@@ -121,19 +125,4 @@ class GeoMaterial : public RCBase {
   
 };
 
-inline const std::string& GeoMaterial::getName () const
-{
-  return m_name;
-}
-
-inline const double& GeoMaterial::getDensity () const
-{
-  return m_density;
-}
-
-inline const unsigned int& GeoMaterial::getID () const
-{
-  return m_iD;
-}
-
 #endif
diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoNodeAction.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoNodeAction.h
index ba80f9198..a26100d86 100644
--- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoNodeAction.h
+++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoNodeAction.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_GEONODEACTION_H
@@ -40,10 +40,10 @@ class GeoNodeAction
   { ALL_ANCESTORS = -1, SELF = 0, SELF_AND_CHILDREN = 1 };
 
  public:
-  GeoNodeAction();
+  GeoNodeAction() = default;
   GeoNodeAction(const GeoNodeAction &right) = delete;
   GeoNodeAction & operator=(const GeoNodeAction &right) = delete; 
-  virtual ~GeoNodeAction();
+  virtual ~GeoNodeAction() = default;
   
   //	Handles a Node.
   virtual void handleNode (const GeoGraphNode *);
@@ -109,15 +109,15 @@ class GeoNodeAction
   
  protected:
   //	Termination flag; causes an abortion of action execution.
-  bool m_terminate;
+  bool m_terminate{false};
 
  private:
   
   //	A limit may be placed upon the depth to which the action
   //	descends.  0 = self.  1 = self and children.
-  Query<unsigned int> m_depth;
+  Query<unsigned int> m_depth{};
 
-  GeoNodePath m_path;  
+  GeoNodePath m_path{};  
 };
 
 #endif
diff --git a/GeoModelCore/GeoModelKernel/src/GeoAccessVolumeAction.cxx b/GeoModelCore/GeoModelKernel/src/GeoAccessVolumeAction.cxx
index 82bf0cc65..95c969fd4 100755
--- a/GeoModelCore/GeoModelKernel/src/GeoAccessVolumeAction.cxx
+++ b/GeoModelCore/GeoModelKernel/src/GeoAccessVolumeAction.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 "GeoModelKernel/GeoAccessVolumeAction.h"
@@ -9,26 +9,13 @@
 
 #include <string>
 
-GeoAccessVolumeAction::GeoAccessVolumeAction(unsigned int Index, const GeoVAlignmentStore* store)
-  : m_transform(GeoTrf::Transform3D::Identity())
-  , m_defTransform(GeoTrf::Transform3D::Identity())
-  , m_index(Index)
-  , m_counter(0)
-  , m_nameTag(nullptr)
-  , m_serialDenominator(nullptr)
-  , m_idTag(nullptr)
-  , m_serialDenomPosition(0)
-  , m_serialIdentifier(nullptr)
-  , m_serialIdentPosition(0)
-  , m_alignStore(store)
-{
+GeoAccessVolumeAction::GeoAccessVolumeAction(unsigned int Index, const GeoVAlignmentStore* store):
+    m_index(Index),
+   m_alignStore(store) {
   setDepthLimit (1);
   m_pendingTransformList.reserve(1);
 }
 
-GeoAccessVolumeAction::~GeoAccessVolumeAction()
-{
-}
 
 void GeoAccessVolumeAction::handleTransform (const GeoTransform *xform)
 {
@@ -137,8 +124,7 @@ const GeoTrf::Transform3D & GeoAccessVolumeAction::getDefTransform () const
   return m_defTransform;
 }
 
-const std::string & GeoAccessVolumeAction::getName () const
-{
+const std::string & GeoAccessVolumeAction::getName () const {
   if(m_name.empty()) {
     if(m_nameTag) {
       m_name = m_nameTag->getName();
@@ -199,16 +185,14 @@ void GeoAccessVolumeAction::handleIdentifierTag (const GeoIdentifierTag *idTag)
   m_serialIdentPosition = 0;
 }
 
-Query<int> GeoAccessVolumeAction::getId () const
-{
-  Query<int> id;
+Query<int> GeoAccessVolumeAction::getId () const {
   if(m_idTag) {
-    id = Query<int>(m_idTag->getIdentifier());
+    return Query<int>(m_idTag->getIdentifier());
   }
   else if(m_serialIdentifier) {
-    id = Query<int>(m_index - m_serialIdentPosition + m_serialIdentifier->getBaseId());
+    return Query<int>(m_index - m_serialIdentPosition + m_serialIdentifier->getBaseId());
   }
-  return id;
+  return std::nullopt;
 }
 
 void GeoAccessVolumeAction::handleSerialIdentifier(const GeoSerialIdentifier *sI)
diff --git a/GeoModelCore/GeoModelKernel/src/GeoNodeAction.cxx b/GeoModelCore/GeoModelKernel/src/GeoNodeAction.cxx
index 7732f697c..c0aced898 100755
--- a/GeoModelCore/GeoModelKernel/src/GeoNodeAction.cxx
+++ b/GeoModelCore/GeoModelKernel/src/GeoNodeAction.cxx
@@ -1,18 +1,9 @@
 /*
-  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/GeoNodeAction.h"
 
-GeoNodeAction::GeoNodeAction()
- : m_terminate (false)
-{
-}
-
-GeoNodeAction::~GeoNodeAction()
-{
-}
-
 void GeoNodeAction::handleNode (const GeoGraphNode *)
 {
   // Do nothing...    
@@ -64,9 +55,8 @@ void GeoNodeAction::setDepthLimit (unsigned int limit)
   m_depth = limit;
 }
 
-void GeoNodeAction::clearDepthLimit ()
-{
-  m_depth = Query < unsigned int >();
+void GeoNodeAction::clearDepthLimit () {
+  m_depth = std::nullopt;
 }
 
 void GeoNodeAction::handleSerialTransformer (const GeoSerialTransformer  *)
diff --git a/GeoModelCore/GeoModelKernel/src/GeoVolumeCursor.cxx b/GeoModelCore/GeoModelKernel/src/GeoVolumeCursor.cxx
index d28c9d1c1..c17850808 100755
--- a/GeoModelCore/GeoModelKernel/src/GeoVolumeCursor.cxx
+++ b/GeoModelCore/GeoModelKernel/src/GeoVolumeCursor.cxx
@@ -255,19 +255,16 @@ std::string  GeoVolumeCursor::getName () const
   return name;
 }
 
-Query<int> GeoVolumeCursor::getId () const
-{
-  Query<int> id;
+Query<int> GeoVolumeCursor::getId () const {
   if (m_idTag) {
-    id = Query<int> (m_idTag->getIdentifier ());
+    return Query<int>{m_idTag->getIdentifier ()};
   }
   else if (m_serialIdentifier) {
-    id = Query<int> (m_volCount - m_serialIdentPosition - 1 + m_serialIdentifier->getBaseId());
+    return Query<int>{m_volCount - m_serialIdentPosition - 1 + m_serialIdentifier->getBaseId()};
   }
-  return id;
+  return std::nullopt;
 }
 
-bool GeoVolumeCursor::hasAlignableTransform() const
-{
+bool GeoVolumeCursor::hasAlignableTransform() const {
   return m_hasAlignTrans;
 }
-- 
GitLab