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

GeoAbsPositionInfo & GeoAccessVolAndSTAction - Smart pointers & constructor clean up

parent 661778e1
Branches
Tags
1 merge request!235GeoAbsPositionInfo & GeoAccessVolAndSTAction - Smart pointers & constructor clean up
Pipeline #6623623 passed with warnings
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEOMODELKERNEL_GEOABSPOSITIONINFO_H
......@@ -13,18 +13,23 @@
*/
#include <GeoModelKernel/GeoDefinitions.h>
#include <memory>
class GeoAbsPositionInfo
{
public:
GeoAbsPositionInfo();
~GeoAbsPositionInfo();
GeoAbsPositionInfo() = default;
~GeoAbsPositionInfo() = default;
// Returns the default absolute transform.
const GeoTrf::Transform3D * getAbsTransform () const;
const GeoTrf::Transform3D * getAbsTransform () const {
return m_absTransform.get();
}
// Returns the default absolute transform.
const GeoTrf::Transform3D * getDefAbsTransform () const;
const GeoTrf::Transform3D * getDefAbsTransform () const {
return m_defAbsTransform.get();
}
// Clears the absolute transform.
......@@ -40,26 +45,14 @@ class GeoAbsPositionInfo
void setDefAbsTransform (const GeoTrf::Transform3D & xform);
private:
GeoAbsPositionInfo(const GeoAbsPositionInfo &right);
GeoAbsPositionInfo & operator=(const GeoAbsPositionInfo &right);
// The absolute transform from the world coord down to this
// positioned object.
GeoTrf::Transform3D *m_absTransform;
std::unique_ptr<GeoTrf::Transform3D> m_absTransform{};
// The default absolute transform from the world coord down
// to this positioned object.
GeoTrf::Transform3D *m_defAbsTransform;
std::unique_ptr<GeoTrf::Transform3D> m_defAbsTransform{};
};
inline const GeoTrf::Transform3D * GeoAbsPositionInfo::getAbsTransform () const
{
return m_absTransform;
}
inline const GeoTrf::Transform3D * GeoAbsPositionInfo::getDefAbsTransform () const
{
return m_defAbsTransform;
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEOMODELKERNEL_GEOACCESSVOLANDSTACTION_H
......@@ -21,11 +21,10 @@
class GeoVPhysVol;
class GeoTransform;
class GeoAccessVolAndSTAction final : public GeoNodeAction
{
class GeoAccessVolAndSTAction final : public GeoNodeAction {
public:
GeoAccessVolAndSTAction(unsigned int index);
virtual ~GeoAccessVolAndSTAction() override;
virtual ~GeoAccessVolAndSTAction() = default;
virtual void handleTransform(const GeoTransform* xform) override;
virtual void handlePhysVol(const GeoPhysVol* vol) override;
......@@ -51,17 +50,17 @@ class GeoAccessVolAndSTAction final : public GeoNodeAction
const GeoAccessVolAndSTAction & operator=(const GeoAccessVolAndSTAction &right);
/// A pointer to the ith physical volume under this one.
PVConstLink m_volume;
PVConstLink m_volume{};
/// A pointer to the Serial Transformer
const GeoSerialTransformer* m_serialTransformer;
const GeoSerialTransformer* m_serialTransformer{nullptr};
/// The transformation and default transformation to the ith volume.
GeoTrf::Transform3D m_transform;
GeoTrf::Transform3D m_defTransform;
GeoTrf::Transform3D m_transform{GeoTrf::Transform3D::Identity()};
GeoTrf::Transform3D m_defTransform{GeoTrf::Transform3D::Identity()};
unsigned int m_index;
unsigned int m_counter;
unsigned int m_index{0};
unsigned int m_counter{0};
/// The name of the volume. From a nametag or a serial denominator
mutable std::string m_name;
......@@ -70,12 +69,12 @@ class GeoAccessVolAndSTAction final : public GeoNodeAction
mutable Query<unsigned int> m_id;
/// A pointer to a name tag. If the volume is named.
const GeoNameTag *m_nameTag;
const GeoSerialDenominator *m_serialDenominator;
const GeoIdentifierTag *m_idTag;
const GeoNameTag *m_nameTag{nullptr};
const GeoSerialDenominator *m_serialDenominator{nullptr};
const GeoIdentifierTag *m_idTag{nullptr};
std::vector<const GeoTransform *> m_pendingTransformList;
unsigned int m_serialDenomPosition;
unsigned int m_serialDenomPosition{0};
};
#endif
......
/*
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/GeoAbsPositionInfo.h"
#include "GeoModelKernel/GeoDefinitions.h"
#include <memory>
GeoAbsPositionInfo::GeoAbsPositionInfo()
: m_absTransform(nullptr),
m_defAbsTransform(nullptr)
{
void GeoAbsPositionInfo::clearAbsTransform () {
m_absTransform.reset();
}
GeoAbsPositionInfo::~GeoAbsPositionInfo()
{
delete m_absTransform;
delete m_defAbsTransform;
}
void GeoAbsPositionInfo::clearAbsTransform ()
{
delete m_absTransform;
m_absTransform = nullptr;
}
void GeoAbsPositionInfo::clearDefAbsTransform ()
{
delete m_defAbsTransform;
m_defAbsTransform = nullptr;
void GeoAbsPositionInfo::clearDefAbsTransform () {
m_defAbsTransform.reset();
}
void GeoAbsPositionInfo::setAbsTransform (const GeoTrf::Transform3D & xform)
{
if (m_absTransform)
{
(*m_absTransform) = xform;
}
else
{
m_absTransform = new GeoTrf::Transform3D (xform);
}
if (m_absTransform) {
(*m_absTransform) = xform;
} else {
m_absTransform = std::make_unique<GeoTrf::Transform3D> (xform);
}
}
void GeoAbsPositionInfo::setDefAbsTransform (const GeoTrf::Transform3D & xform)
{
if (m_defAbsTransform)
{
void GeoAbsPositionInfo::setDefAbsTransform (const GeoTrf::Transform3D& xform) {
if (m_defAbsTransform) {
(*m_defAbsTransform) = xform;
}
else
{
m_defAbsTransform = new GeoTrf::Transform3D (xform);
}
} else {
m_defAbsTransform = std::make_unique<GeoTrf::Transform3D>(xform);
}
}
......@@ -8,25 +8,11 @@
#include "GeoModelKernel/GeoSerialDenominator.h"
#include <string>
GeoAccessVolAndSTAction::GeoAccessVolAndSTAction(unsigned int index)
: m_volume(0)
, m_serialTransformer(0)
, m_transform(GeoTrf::Transform3D::Identity())
, m_defTransform(GeoTrf::Transform3D::Identity())
, m_index(index)
, m_counter(0)
, m_nameTag(0)
, m_serialDenominator(0)
, m_idTag(0)
, m_serialDenomPosition(0)
{
GeoAccessVolAndSTAction::GeoAccessVolAndSTAction(unsigned int index):
m_index{index} {
setDepthLimit(1);
}
GeoAccessVolAndSTAction::~GeoAccessVolAndSTAction()
{
}
void GeoAccessVolAndSTAction::handleTransform(const GeoTransform *xform)
{
m_pendingTransformList.push_back (xform);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment