From f305b9c9050b1280cc52f7b8f428794df1d7f991 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 9 Jul 2021 15:26:46 +0200 Subject: [PATCH 1/4] + const --- Core/Computation/DWBASingleComputation.cpp | 4 ++-- Core/Computation/DWBASingleComputation.h | 2 +- auto/Wrap/doxygenBase.i | 6 +++--- auto/Wrap/doxygenCore.i | 2 +- auto/Wrap/doxygenDevice.i | 4 ++-- auto/Wrap/doxygenParam.i | 4 ++-- auto/Wrap/libBornAgainCore.py | 2 +- auto/Wrap/libBornAgainDevice.py | 2 +- auto/Wrap/libBornAgainParam.py | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Core/Computation/DWBASingleComputation.cpp b/Core/Computation/DWBASingleComputation.cpp index a4095a7be04..457c955e7c2 100644 --- a/Core/Computation/DWBASingleComputation.cpp +++ b/Core/Computation/DWBASingleComputation.cpp @@ -24,11 +24,11 @@ namespace { -std::vector<std::unique_ptr<ParticleLayoutComputation>> +std::vector<std::unique_ptr<const ParticleLayoutComputation>> makeLayoutComputation(const std::vector<ProcessedLayout>& layouts, const SimulationOptions& options, bool polarized) { - std::vector<std::unique_ptr<ParticleLayoutComputation>> result; + std::vector<std::unique_ptr<const ParticleLayoutComputation>> result; for (const ProcessedLayout& layout : layouts) result.emplace_back(new ParticleLayoutComputation(layout, options, polarized)); diff --git a/Core/Computation/DWBASingleComputation.h b/Core/Computation/DWBASingleComputation.h index daf0af28c43..48cec031587 100644 --- a/Core/Computation/DWBASingleComputation.h +++ b/Core/Computation/DWBASingleComputation.h @@ -51,7 +51,7 @@ private: const IFresnelMap* const m_fresnel_map; const std::unique_ptr<const GISASSpecularComputation> m_spec_comp; const std::unique_ptr<const RoughMultiLayerComputation> m_roughness_comp; - const std::vector<std::unique_ptr<ParticleLayoutComputation>> m_layout_comps; + const std::vector<std::unique_ptr<const ParticleLayoutComputation>> m_layout_comps; std::unique_ptr<DelayedProgressCounter> m_progress_counter; }; diff --git a/auto/Wrap/doxygenBase.i b/auto/Wrap/doxygenBase.i index 2168544733f..70111543b13 100644 --- a/auto/Wrap/doxygenBase.i +++ b/auto/Wrap/doxygenBase.i @@ -943,10 +943,10 @@ C++ includes: RectangularPixel.h // File: classSafePointerVector.xml %feature("docstring") SafePointerVector " -The objects pointed to must support the ICloneable interface. - A vector of pointers, owned by *this, with methods to handle them safely. +The objects pointed to must support the ICloneable interface. + C++ includes: SafePointerVector.h "; @@ -1798,7 +1798,7 @@ Checks if value is contained in bin: value in [m_lower, m_upper) // File: IntegratorMCMiser_8h.xml %feature("docstring") make_integrator_miser "P_integrator_miser<T> make_integrator_miser(const T *object, miser_integrand< T > mem_function, size_t dim) -Template function to create an integrator object +Template function to create an integrator object. "; diff --git a/auto/Wrap/doxygenCore.i b/auto/Wrap/doxygenCore.i index 44d66e30576..9c9e5c2c12f 100644 --- a/auto/Wrap/doxygenCore.i +++ b/auto/Wrap/doxygenCore.i @@ -825,7 +825,7 @@ C++ includes: GISASSpecularComputation.h // File: classIBackground.xml %feature("docstring") IBackground " -Interface for a simulating the background signal +Interface for a simulating the background signal. C++ includes: IBackground.h "; diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i index 92b3d6c67ef..c6a3202a69c 100644 --- a/auto/Wrap/doxygenDevice.i +++ b/auto/Wrap/doxygenDevice.i @@ -283,7 +283,7 @@ Creates OutputData array in converter units. // File: classCoordSystem2D.xml %feature("docstring") CoordSystem2D " -Interface for objects that provide axis translations to different units for IDetector objects +Interface for objects that provide axis translations to different units for IDetector objects. C++ includes: CoordSystem2D.h "; @@ -1227,7 +1227,7 @@ Returns index of pixel that contains the specular wavevector. If no pixel contai // File: classIDetectorResolution.xml %feature("docstring") IDetectorResolution " -Interface for detector resolution algorithms +Interface for detector resolution algorithms. C++ includes: IDetectorResolution.h "; diff --git a/auto/Wrap/doxygenParam.i b/auto/Wrap/doxygenParam.i index 57ad93426b6..8d5e63a0c20 100644 --- a/auto/Wrap/doxygenParam.i +++ b/auto/Wrap/doxygenParam.i @@ -503,10 +503,10 @@ Returns display name, composed from the name of node and it's copy number. // File: classINodeVisitor.xml %feature("docstring") INodeVisitor " -From visitor pattern to achieve double dispatch. - Visitor interface to visit ISampleNode objects. +From visitor pattern to achieve double dispatch. + C++ includes: INodeVisitor.h "; diff --git a/auto/Wrap/libBornAgainCore.py b/auto/Wrap/libBornAgainCore.py index 8aec86e4e81..8d5e453b2fe 100644 --- a/auto/Wrap/libBornAgainCore.py +++ b/auto/Wrap/libBornAgainCore.py @@ -4186,7 +4186,7 @@ class IBackground(libBornAgainBase.ICloneable, libBornAgainParam.INode): r""" - Interface for a simulating the background signal + Interface for a simulating the background signal. C++ includes: IBackground.h diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py index 934933de4d4..a7bf54b3525 100644 --- a/auto/Wrap/libBornAgainDevice.py +++ b/auto/Wrap/libBornAgainDevice.py @@ -3544,7 +3544,7 @@ class IDetectorResolution(libBornAgainBase.ICloneable, libBornAgainParam.INode): r""" - Interface for detector resolution algorithms + Interface for detector resolution algorithms. C++ includes: IDetectorResolution.h diff --git a/auto/Wrap/libBornAgainParam.py b/auto/Wrap/libBornAgainParam.py index 8b3406368c2..e780d0c3b9b 100644 --- a/auto/Wrap/libBornAgainParam.py +++ b/auto/Wrap/libBornAgainParam.py @@ -2812,10 +2812,10 @@ class INodeVisitor(object): r""" - From visitor pattern to achieve double dispatch. - Visitor interface to visit ISampleNode objects. + From visitor pattern to achieve double dispatch. + C++ includes: INodeVisitor.h """ -- GitLab From a97061b0bd7194ac87cf31aa6acdb019875758b5 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 9 Jul 2021 15:55:45 +0200 Subject: [PATCH 2/4] +const with mutable member --- Core/Computation/DWBAComputation.h | 2 +- Core/Computation/DWBASingleComputation.cpp | 2 +- Core/Computation/DWBASingleComputation.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/Computation/DWBAComputation.h b/Core/Computation/DWBAComputation.h index f88a2a54afb..8c657f9c7b8 100644 --- a/Core/Computation/DWBAComputation.h +++ b/Core/Computation/DWBAComputation.h @@ -43,7 +43,7 @@ private: //! These iterators define the span of detector bins this simulation will work on std::vector<SimulationElement>::iterator m_begin_it, m_end_it; //! Contains the information, necessary to calculate the Fresnel coefficients. - DWBASingleComputation m_single_computation; + const DWBASingleComputation m_single_computation; }; #endif // BORNAGAIN_CORE_COMPUTATION_DWBACOMPUTATION_H diff --git a/Core/Computation/DWBASingleComputation.cpp b/Core/Computation/DWBASingleComputation.cpp index 457c955e7c2..88c2f6ccb48 100644 --- a/Core/Computation/DWBASingleComputation.cpp +++ b/Core/Computation/DWBASingleComputation.cpp @@ -51,7 +51,7 @@ DWBASingleComputation::DWBASingleComputation(const ProcessedSample& sample, DWBASingleComputation::~DWBASingleComputation() = default; -void DWBASingleComputation::setProgressHandler(ProgressHandler* progress) +void DWBASingleComputation::setProgressHandler(ProgressHandler* progress) const { m_progress_counter = std::make_unique<DelayedProgressCounter>(progress, 100); } diff --git a/Core/Computation/DWBASingleComputation.h b/Core/Computation/DWBASingleComputation.h index 48cec031587..a136a948073 100644 --- a/Core/Computation/DWBASingleComputation.h +++ b/Core/Computation/DWBASingleComputation.h @@ -43,7 +43,7 @@ public: DWBASingleComputation(const DWBASingleComputation&) = delete; ~DWBASingleComputation(); - void setProgressHandler(ProgressHandler* progress); + void setProgressHandler(ProgressHandler* progress) const; void compute(SimulationElement& ele) const; @@ -52,7 +52,7 @@ private: const std::unique_ptr<const GISASSpecularComputation> m_spec_comp; const std::unique_ptr<const RoughMultiLayerComputation> m_roughness_comp; const std::vector<std::unique_ptr<const ParticleLayoutComputation>> m_layout_comps; - std::unique_ptr<DelayedProgressCounter> m_progress_counter; + mutable std::unique_ptr<DelayedProgressCounter> m_progress_counter; }; #endif // BORNAGAIN_CORE_COMPUTATION_DWBASINGLECOMPUTATION_H -- GitLab From d00d86c418cda59c1d6fed9638816393290934c1 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 9 Jul 2021 16:15:55 +0200 Subject: [PATCH 3/4] +const in MC integrator --- Base/Math/IntegratorMCMiser.h | 12 ++++++------ Resample/Interparticle/IInterparticleStrategy.cpp | 4 ++-- Resample/Interparticle/IInterparticleStrategy.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Base/Math/IntegratorMCMiser.h b/Base/Math/IntegratorMCMiser.h index 83e74970852..9390e43812c 100644 --- a/Base/Math/IntegratorMCMiser.h +++ b/Base/Math/IntegratorMCMiser.h @@ -24,7 +24,7 @@ #include <memory> //! Alias template for member function with signature double f(double) -template <class T> using miser_integrand = double (T::*)(double*, size_t, void*) const; +template <class T> using miser_integrand = double (T::*)(double*, size_t, const void*) const; //! Template class to use Monte Carlo MISER integration of class member functions. //! @@ -40,8 +40,8 @@ public: //! structure holding the object and possible extra parameters struct CallBackHolder { const T* m_object_pointer; - miser_integrand<T> m_member_function; - void* m_data; + const miser_integrand<T> m_member_function; + const void* m_data; }; //! to integrate p_member_function, which must belong to p_object @@ -49,7 +49,7 @@ public: ~IntegratorMCMiser(); //! perform the actual integration over the ranges [min_array, max_array] - double integrate(double* min_array, double* max_array, void* params, size_t nbr_points); + double integrate(double* min_array, double* max_array, const void* params, size_t nbr_points) const; private: //! static function that can be passed to gsl integrator @@ -103,8 +103,8 @@ template <class T> IntegratorMCMiser<T>::~IntegratorMCMiser() } template <class T> -double IntegratorMCMiser<T>::integrate(double* min_array, double* max_array, void* params, - size_t nbr_points) +double IntegratorMCMiser<T>::integrate(double* min_array, double* max_array, const void* params, + size_t nbr_points) const { CallBackHolder cb = {m_object, m_member_function, params}; diff --git a/Resample/Interparticle/IInterparticleStrategy.cpp b/Resample/Interparticle/IInterparticleStrategy.cpp index d2396aac1fa..1f7a8a88bf4 100644 --- a/Resample/Interparticle/IInterparticleStrategy.cpp +++ b/Resample/Interparticle/IInterparticleStrategy.cpp @@ -56,12 +56,12 @@ double IInterparticleStrategy::MCIntegratedEvaluate(const SimulationElement& sim } double IInterparticleStrategy::evaluate_for_fixed_angles(double* fractions, size_t, - void* params) const + const void* params) const { double par0 = fractions[0]; double par1 = fractions[1]; - SimulationElement* pars = static_cast<SimulationElement*>(params); + const auto* pars = static_cast<const SimulationElement*>(params); SimulationElement sim_element = pars->pointElement(par0, par1); return pars->integrationFactor(par0, par1) * evaluateSinglePoint(sim_element); diff --git a/Resample/Interparticle/IInterparticleStrategy.h b/Resample/Interparticle/IInterparticleStrategy.h index d3a3909b8ac..d2fbb20155e 100644 --- a/Resample/Interparticle/IInterparticleStrategy.h +++ b/Resample/Interparticle/IInterparticleStrategy.h @@ -57,7 +57,7 @@ protected: private: double evaluateSinglePoint(const SimulationElement& sim_element) const; double MCIntegratedEvaluate(const SimulationElement& sim_element) const; - double evaluate_for_fixed_angles(double* fractions, size_t dim, void* params) const; + double evaluate_for_fixed_angles(double* fractions, size_t dim, const void* params) const; //! Evaluates the intensity in the scalar case virtual double scalarCalculation(const SimulationElement& sim_element) const = 0; //! Evaluates the intensity in the polarized case -- GitLab From 448d6c490d19f4a0656ed5eb9b250242cb0ab87e Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 9 Jul 2021 16:16:49 +0200 Subject: [PATCH 4/4] + const; clang-format --- Base/Math/IntegratorMCMiser.h | 3 ++- GUI/Models/TransformationItem.h | 4 ++-- Resample/Interparticle/IInterparticleStrategy.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Base/Math/IntegratorMCMiser.h b/Base/Math/IntegratorMCMiser.h index 9390e43812c..c75b6499e16 100644 --- a/Base/Math/IntegratorMCMiser.h +++ b/Base/Math/IntegratorMCMiser.h @@ -49,7 +49,8 @@ public: ~IntegratorMCMiser(); //! perform the actual integration over the ranges [min_array, max_array] - double integrate(double* min_array, double* max_array, const void* params, size_t nbr_points) const; + double integrate(double* min_array, double* max_array, const void* params, + size_t nbr_points) const; private: //! static function that can be passed to gsl integrator diff --git a/GUI/Models/TransformationItem.h b/GUI/Models/TransformationItem.h index 0893a2d23c1..f18b3fc49bc 100644 --- a/GUI/Models/TransformationItem.h +++ b/GUI/Models/TransformationItem.h @@ -37,8 +37,8 @@ template <typename T> T* TransformationItem::setRotationType() { static_assert(std::is_base_of<RotationItem, T>::value, "Class must be derived from RotationItem"); - + return setGroupPropertyType<T>(P_ROT); } - + #endif // BORNAGAIN_GUI_MODELS_TRANSFORMATIONITEM_H diff --git a/Resample/Interparticle/IInterparticleStrategy.h b/Resample/Interparticle/IInterparticleStrategy.h index d2fbb20155e..376db2a8940 100644 --- a/Resample/Interparticle/IInterparticleStrategy.h +++ b/Resample/Interparticle/IInterparticleStrategy.h @@ -63,7 +63,7 @@ private: //! Evaluates the intensity in the polarized case virtual double polarizedCalculation(const SimulationElement& sim_element) const = 0; - bool m_polarized; + const bool m_polarized; std::unique_ptr<IntegratorMCMiser<IInterparticleStrategy>> m_integrator; }; -- GitLab