diff --git a/alg/viewshed/combiner.h b/alg/viewshed/combiner.h index 4597a8fd8d9d..0e6ce9787a48 100644 --- a/alg/viewshed/combiner.h +++ b/alg/viewshed/combiner.h @@ -20,7 +20,8 @@ * DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#pragma once +#ifndef VIEWSHED_COMBINER_H_INCLUDED +#define VIEWSHED_COMBINER_H_INCLUDED #include "cumulative.h" #include "viewshed_types.h" @@ -67,3 +68,5 @@ class Combiner } // namespace viewshed } // namespace gdal + +#endif diff --git a/alg/viewshed/cumulative.cpp b/alg/viewshed/cumulative.cpp index 79d48c68c4d0..606ca23c8215 100644 --- a/alg/viewshed/cumulative.cpp +++ b/alg/viewshed/cumulative.cpp @@ -44,6 +44,10 @@ Cumulative::Cumulative(const Options &opts) : m_opts(opts) { } +/// Destructor +/// +Cumulative::~Cumulative() = default; + /// Compute the cumulative viewshed of a raster band. /// /// @param srcFilename Source filename. diff --git a/alg/viewshed/cumulative.h b/alg/viewshed/cumulative.h index 1d93a0896368..c9d2f8a3f958 100644 --- a/alg/viewshed/cumulative.h +++ b/alg/viewshed/cumulative.h @@ -20,7 +20,8 @@ * DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#pragma once +#ifndef VIEWSHED_CUMULATIVE_H_INCLUDED +#define VIEWSHED_CUMULATIVE_H_INCLUDED #include #include @@ -41,6 +42,11 @@ class Cumulative { public: CPL_DLL explicit Cumulative(const Options &opts); + // We define an explicit destructor, whose implementation is in libgdal, + // otherwise with gcc 9.4 of Ubuntu 20.04 in debug mode, this would need to + // redefinition of the NotifyQueue class in both libgdal and gdal_viewshed, + // leading to weird things related to mutex. + CPL_DLL ~Cumulative(); CPL_DLL bool run(const std::string &srcFilename, GDALProgressFunc pfnProgress = GDALDummyProgress, void *pProgressArg = nullptr); @@ -70,7 +76,12 @@ class Cumulative void rollupRasters(); void scaleOutput(); bool writeOutput(DatasetPtr pDstDS); + + Cumulative(const Cumulative &) = delete; + Cumulative &operator=(const Cumulative &) = delete; }; } // namespace viewshed } // namespace gdal + +#endif diff --git a/alg/viewshed/notifyqueue.h b/alg/viewshed/notifyqueue.h index 6ddeed8ec79d..e0e3f9da3725 100644 --- a/alg/viewshed/notifyqueue.h +++ b/alg/viewshed/notifyqueue.h @@ -19,7 +19,11 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#pragma once + +#ifndef VIEWSHED_NOTIFYQUEUE_H_INCLUDED +#define VIEWSHED_NOTIFYQUEUE_H_INCLUDED + +#include "cpl_port.h" #include #include @@ -134,3 +138,5 @@ template class NotifyQueue } // namespace viewshed } // namespace gdal + +#endif diff --git a/alg/viewshed/progress.h b/alg/viewshed/progress.h index d0afaa588a97..0eaee7d449c8 100644 --- a/alg/viewshed/progress.h +++ b/alg/viewshed/progress.h @@ -20,7 +20,8 @@ * DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#pragma once +#ifndef VIEWSHED_PROGRESS_H_INCLUDED +#define VIEWSHED_PROGRESS_H_INCLUDED #include #include @@ -54,3 +55,5 @@ class Progress } // namespace viewshed } // namespace gdal + +#endif diff --git a/alg/viewshed/util.h b/alg/viewshed/util.h index 281bd382608f..3ebf6a9203dc 100644 --- a/alg/viewshed/util.h +++ b/alg/viewshed/util.h @@ -20,7 +20,8 @@ * DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#pragma once +#ifndef VIEWSHED_UTIL_H_INCLUDED +#define VIEWSHED_UTIL_H_INCLUDED #include "viewshed_types.h" @@ -36,3 +37,5 @@ DatasetPtr createOutputDataset(GDALRasterBand &srcBand, const Options &opts, } // namespace viewshed } // namespace gdal + +#endif diff --git a/alg/viewshed/viewshed.cpp b/alg/viewshed/viewshed.cpp index fb0008ed7460..df5638bb70ac 100644 --- a/alg/viewshed/viewshed.cpp +++ b/alg/viewshed/viewshed.cpp @@ -234,6 +234,12 @@ bool getTransforms(GDALRasterBand &band, double *pFwdTransform, } // unnamed namespace +Viewshed::Viewshed(const Options &opts) : oOpts{opts} +{ +} + +Viewshed::~Viewshed() = default; + /// Calculate the extent of the output raster in terms of the input raster and /// save the input raster extent. /// diff --git a/alg/viewshed/viewshed.h b/alg/viewshed/viewshed.h index 9109772d214d..996276596dd9 100644 --- a/alg/viewshed/viewshed.h +++ b/alg/viewshed/viewshed.h @@ -27,7 +27,8 @@ * DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#pragma once +#ifndef VIEWSHED_H_INCLUDED +#define VIEWSHED_H_INCLUDED #include #include @@ -59,13 +60,10 @@ class Viewshed * * @param opts Options to use when calculating viewshed. */ - CPL_DLL explicit Viewshed(const Options &opts) - : oOpts{opts}, oOutExtent{}, oCurExtent{}, poDstDS{}, pSrcBand{} - { - } + CPL_DLL explicit Viewshed(const Options &opts); - Viewshed(const Viewshed &) = delete; - Viewshed &operator=(const Viewshed &) = delete; + /** Destructor */ + CPL_DLL ~Viewshed(); CPL_DLL bool run(GDALRasterBandH hBand, GDALProgressFunc pfnProgress = GDALDummyProgress, @@ -83,10 +81,10 @@ class Viewshed private: Options oOpts; - Window oOutExtent; - Window oCurExtent; - DatasetPtr poDstDS; - GDALRasterBand *pSrcBand; + Window oOutExtent{}; + Window oCurExtent{}; + DatasetPtr poDstDS{}; + GDALRasterBand *pSrcBand = nullptr; DatasetPtr execute(int nX, int nY, const std::string &outFilename); void setOutput(double &dfResult, double &dfCellVal, double dfZ); @@ -96,7 +94,12 @@ class Viewshed std::vector &thisLineVal); bool calcExtents(int nX, int nY, const std::array &adfInvTransform); + + Viewshed(const Viewshed &) = delete; + Viewshed &operator=(const Viewshed &) = delete; }; } // namespace viewshed } // namespace gdal + +#endif diff --git a/alg/viewshed/viewshed_types.h b/alg/viewshed/viewshed_types.h index abdaae49a2fb..fa1f0b2b9ead 100644 --- a/alg/viewshed/viewshed_types.h +++ b/alg/viewshed/viewshed_types.h @@ -19,7 +19,8 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#pragma once +#ifndef VIEWSHED_TYPES_H_INCLUDED +#define VIEWSHED_TYPES_H_INCLUDED #include #include @@ -171,3 +172,5 @@ struct Window } // namespace viewshed } // namespace gdal + +#endif