Skip to content
Snippets Groups Projects
Commit b3f1d03f authored by Edward Moyse's avatar Edward Moyse
Browse files

Merge branch 'IApproachDescriptor_mem_leak' into 'master'

ATLASRECTS-5829: IApproachDescriptor use unique_ptrs for the remaining ptr data...

See merge request atlas/athena!38950
parents 651d5f26 dec78687
No related branches found
No related tags found
6 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!38950ATLASRECTS-5829: IApproachDescriptor use unique_ptrs for the remaining ptr data...
...@@ -13,42 +13,42 @@ ...@@ -13,42 +13,42 @@
#include "TrkGeometry/IApproachDescriptor.h" #include "TrkGeometry/IApproachDescriptor.h"
namespace Trk { namespace Trk {
/** /**
@class ApproachDescriptor @class ApproachDescriptor
Class to decide and return which approaching surface to be taken, Class to decide and return which approaching surface to be taken.
it either has a
@author Andreas.Salzburger@cern.ch
@author Andreas.Salzburger@cern.ch */
*/
class ApproachDescriptor : public IApproachDescriptor
class ApproachDescriptor : public IApproachDescriptor { {
public: public:
// Default constructor // Default constructor
ApproachDescriptor(std::unique_ptr<ApproachSurfaces> aSurfaces, ApproachDescriptor(std::unique_ptr<ApproachSurfaces> aSurfaces,
bool rebuild = true) bool rebuild = true)
: IApproachDescriptor(std::move(aSurfaces), rebuild) : IApproachDescriptor(std::move(aSurfaces), rebuild)
{} {}
// Default constructor // Default constructor
ApproachDescriptor( ApproachDescriptor(
std::unique_ptr<BinnedArray<ApproachSurfaces>> aSurfaceArray, std::unique_ptr<BinnedArray<ApproachSurfaces>> aSurfaceArray,
Surface* aSurfaceArraySurface = nullptr) std::unique_ptr<Surface> aSurfaceArraySurface = nullptr)
: IApproachDescriptor(std::move(aSurfaceArray), aSurfaceArraySurface) : IApproachDescriptor(std::move(aSurfaceArray), std::move(aSurfaceArraySurface))
{} {}
/** get the compatible surfaces /** get the compatible surfaces
- return : a boolean indicating if an actual intersection had been tried - return : a boolean indicating if an actual intersection had been tried
- fill vector of intersections - fill vector of intersections
- primary bin surface : sf - primary bin surface : sf
- position & direction : pos, dir - position & direction : pos, dir
*/ */
virtual const ApproachSurfaces* virtual const ApproachSurfaces* approachSurfaces(
approachSurfaces(const Amg::Vector3D& pos, const Amg::Vector3D& pos,
const Amg::Vector3D& dir) const override; const Amg::Vector3D& dir) const override final;
private : private:
}; };
} }
#endif #endif
......
...@@ -11,128 +11,128 @@ ...@@ -11,128 +11,128 @@
// Trk // Trk
#include "GeoPrimitives/GeoPrimitives.h" #include "GeoPrimitives/GeoPrimitives.h"
#include "TrkSurfaces/Surface.h"
#include "TrkDetDescrUtils/BinnedArray.h" #include "TrkDetDescrUtils/BinnedArray.h"
#include "TrkSurfaces/Surface.h"
#include <memory> #include <memory>
namespace Trk { namespace Trk {
/** /**
@class ApproachSurfaces @class ApproachSurfaces
just implement the delete on the objects just implement the delete on the objects
*/ */
class ApproachSurfaces : public std::vector<const Surface*> { class ApproachSurfaces : public std::vector<const Surface*>
public : {
// Default constructor public:
ApproachSurfaces() : // Default constructor
std::vector<const Surface*>() ApproachSurfaces()
{} : std::vector<const Surface*>()
{}
// Desctructur with cleanup
~ApproachSurfaces() // Desctructur with cleanup
{ ~ApproachSurfaces()
for (auto& sf : (*this)){ {
//delete when not owned by for (auto& sf : (*this)) {
//Tracking Geometry delete sf;
if (sf && sf->isFree()) {
delete sf;
}
}
}
};
/**
@class IApproachDescriptor
CVirtual class to decide and return which approaching surface to be taken,
it either has a
@author Andreas.Salzburger@cern.ch, made virtual by Remi.Lafaye@cern.ch
*/
class IApproachDescriptor {
public:
// Default constructor
IApproachDescriptor(std::unique_ptr<ApproachSurfaces> aSurfaces,
bool rebuild = true)
: m_approachSurfaces(std::move(aSurfaces))
, m_approachSurfaceArraySurface(nullptr)
, m_approachSurfaceArray(nullptr)
, m_rebuild(rebuild)
{}
// Default constructor
IApproachDescriptor(
std::unique_ptr<BinnedArray<ApproachSurfaces>> aSurfaceArray,
Surface* aSurfaceArraySurface = nullptr)
: m_approachSurfaces(nullptr)
, m_approachSurfaceArraySurface(aSurfaceArraySurface)
, m_approachSurfaceArray(std::move(aSurfaceArray))
, m_rebuild(false)
{}
virtual ~IApproachDescriptor() {
//Delet if not free
if (m_approachSurfaceArraySurface &&
m_approachSurfaceArraySurface->isFree()) {
delete m_approachSurfaceArraySurface;
}
}
// register Layer
void registerLayer(const Layer& lay);
// Telling you if it needs to be rebuilt
bool rebuild() const;
/** get the compatible surfaces
- return : a boolean indicating if an actual intersection had been tried
- fill vector of intersections
- primary bin surface : sf
- position & direction : pos, dir
*/
virtual const ApproachSurfaces* approachSurfaces(const Amg::Vector3D& pos, const Amg::Vector3D& dir) const = 0;
private :
// register the Layer
void registerLayerToSurfaces(const Layer& lay, const ApproachSurfaces& aSurfaces);
// Copy constructor - private
IApproachDescriptor(const IApproachDescriptor&):
m_approachSurfaces(nullptr),
m_approachSurfaceArraySurface(nullptr),
m_approachSurfaceArray(nullptr)
{}
protected:
std::unique_ptr<ApproachSurfaces> m_approachSurfaces;
Surface* m_approachSurfaceArraySurface;
std::unique_ptr<BinnedArray<ApproachSurfaces>> m_approachSurfaceArray;
bool m_rebuild;
};
inline bool IApproachDescriptor::rebuild() const { return m_rebuild; }
inline void IApproachDescriptor::registerLayer(const Layer& lay) {
if (m_approachSurfaces)
registerLayerToSurfaces(lay, *m_approachSurfaces);
if (m_approachSurfaceArraySurface){
m_approachSurfaceArraySurface->associateLayer(lay);
m_approachSurfaceArraySurface->setOwner(Trk::TGOwn);
}
if (m_approachSurfaceArray){
const std::vector<const ApproachSurfaces*>& aSurfaceObjects = m_approachSurfaceArray->arrayObjects();
for (auto& aSurfaces : aSurfaceObjects)
registerLayerToSurfaces(lay, *aSurfaces);
}
} }
}
inline void IApproachDescriptor::registerLayerToSurfaces(const Layer& lay, const ApproachSurfaces& aSurfaces) { };
for (auto& aSurface : aSurfaces){
aSurface->associateLayer(lay); /**
aSurface->setOwner(Trk::TGOwn); @class IApproachDescriptor
}
CVirtual class to decide and return which approaching surface to be taken.
@author Andreas.Salzburger@cern.ch, made virtual by Remi.Lafaye@cern.ch
*/
class IApproachDescriptor
{
public:
// Default constructor
IApproachDescriptor(std::unique_ptr<ApproachSurfaces> aSurfaces,
bool rebuild = true)
: m_approachSurfaces(std::move(aSurfaces))
, m_approachSurfaceArraySurface(nullptr)
, m_approachSurfaceArray(nullptr)
, m_rebuild(rebuild)
{}
// Default constructor
IApproachDescriptor(
std::unique_ptr<BinnedArray<ApproachSurfaces>> aSurfaceArray,
std::unique_ptr<Surface> aSurfaceArraySurface = nullptr)
: m_approachSurfaces(nullptr)
, m_approachSurfaceArraySurface(std::move(aSurfaceArraySurface))
, m_approachSurfaceArray(std::move(aSurfaceArray))
, m_rebuild(false)
{}
virtual ~IApproachDescriptor() = default;
// register Layer
void registerLayer(const Layer& lay);
// Telling you if it needs to be rebuilt
bool rebuild() const;
/** get the compatible surfaces
- return : a boolean indicating if an actual intersection had been tried
- fill vector of intersections
- primary bin surface : sf
- position & direction : pos, dir
*/
virtual const ApproachSurfaces* approachSurfaces(
const Amg::Vector3D& pos,
const Amg::Vector3D& dir) const = 0;
private:
// register the Layer
void registerLayerToSurfaces(const Layer& lay,
const ApproachSurfaces& aSurfaces);
IApproachDescriptor(const IApproachDescriptor&) = delete;
IApproachDescriptor& operator=(const IApproachDescriptor&) = delete;
protected:
std::unique_ptr<ApproachSurfaces> m_approachSurfaces;
std::unique_ptr<Surface> m_approachSurfaceArraySurface;
std::unique_ptr<BinnedArray<ApproachSurfaces>> m_approachSurfaceArray;
bool m_rebuild;
};
inline bool
IApproachDescriptor::rebuild() const
{
return m_rebuild;
}
inline void
IApproachDescriptor::registerLayer(const Layer& lay)
{
if (m_approachSurfaces)
registerLayerToSurfaces(lay, *m_approachSurfaces);
if (m_approachSurfaceArraySurface) {
m_approachSurfaceArraySurface->associateLayer(lay);
m_approachSurfaceArraySurface->setOwner(Trk::TGOwn);
}
if (m_approachSurfaceArray) {
const std::vector<const ApproachSurfaces*>& aSurfaceObjects =
m_approachSurfaceArray->arrayObjects();
for (auto& aSurfaces : aSurfaceObjects) {
registerLayerToSurfaces(lay, *aSurfaces);
} }
}
}
inline void
IApproachDescriptor::registerLayerToSurfaces(const Layer& lay,
const ApproachSurfaces& aSurfaces)
{
for (auto& aSurface : aSurfaces) {
aSurface->associateLayer(lay);
aSurface->setOwner(Trk::TGOwn);
}
}
} }
#endif // TRKGEOMETRY_IAPPROACHDESCRIPTOR_H #endif // TRKGEOMETRY_IAPPROACHDESCRIPTOR_H
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment