diff --git a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h index b3276c5aa737490dd1ee0e7f5baf0818e26a9c7f..8f895631253bef3ae3916cda3463909b5eace277 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h @@ -18,6 +18,8 @@ #ifndef otbSarSensorModelAdapter_h #define otbSarSensorModelAdapter_h +#include <memory> + #include "otbDEMHandler.h" namespace ossimplugins @@ -55,7 +57,7 @@ public: typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - typedef ossimplugins::ossimSarSensorModel* InternalModelPointer; + typedef std::auto_ptr<ossimplugins::ossimSarSensorModel> InternalModelPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); diff --git a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx index 929bdef3ccb5a808b45bf1e7264ee7f59ebd9722..7cda57a0cc4f116f50ce0e5bfd2e9da9db89496b 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx @@ -46,9 +46,7 @@ SarSensorModelAdapter::SarSensorModelAdapter(): } SarSensorModelAdapter::~SarSensorModelAdapter() -{ - delete m_SensorModel; -} +{} bool SarSensorModelAdapter::LoadState(const ImageKeywordlist& image_kwl) { @@ -57,19 +55,15 @@ bool SarSensorModelAdapter::LoadState(const ImageKeywordlist& image_kwl) ossimKeywordlist geom; image_kwl.convertToOSSIMKeywordlist(geom); - if(m_SensorModel != ITK_NULLPTR) - { - delete m_SensorModel; - } - m_SensorModel = dynamic_cast<ossimplugins::ossimSarSensorModel* >(ossimplugins::ossimPluginProjectionFactory::instance()->createProjection(geom)); + m_SensorModel.reset(dynamic_cast<ossimplugins::ossimSarSensorModel* >(ossimplugins::ossimPluginProjectionFactory::instance()->createProjection(geom))); return IsValidSensorModel(); } bool SarSensorModelAdapter::SaveState(ImageKeywordlist & image_kwl) { - if(m_SensorModel != ITK_NULLPTR) + if(m_SensorModel.get() != ITK_NULLPTR) { ossimKeywordlist geom; @@ -89,12 +83,12 @@ bool SarSensorModelAdapter::SaveState(ImageKeywordlist & image_kwl) bool SarSensorModelAdapter::IsValidSensorModel() const { - return m_SensorModel != ITK_NULLPTR; + return m_SensorModel.get() != ITK_NULLPTR; } bool SarSensorModelAdapter::Deburst(std::vector<std::pair<unsigned long, unsigned long>> & lines) { - if(m_SensorModel != ITK_NULLPTR) + if(m_SensorModel.get() != ITK_NULLPTR) { return m_SensorModel->deburst(lines); }