From 59994ae677a911c928e5700dd1089b27b776c020 Mon Sep 17 00:00:00 2001 From: pospelov <pospelov@fz-juelich.de> Date: Thu, 10 Jan 2013 13:23:32 +0100 Subject: [PATCH] Static code analysis: fixes for constness, level of private/protected --- Core/Algorithms/inc/ChiSquaredFrequency.h | 2 +- Core/Algorithms/inc/DWBADiffuseReflection.h | 2 +- .../inc/DecouplingApproximationStrategy.h | 2 +- Core/Algorithms/inc/Detector.h | 2 +- Core/Algorithms/inc/FTDistributions.h | 4 +-- Core/Algorithms/inc/GISASExperiment.h | 4 ++- Core/Algorithms/inc/Mask.h | 10 +++++-- Core/Algorithms/inc/OpticalFresnel.h | 14 +++++----- Core/Algorithms/src/DWBADiffuseReflection.cpp | 2 +- .../src/DecouplingApproximationStrategy.cpp | 2 +- Core/Algorithms/src/Detector.cpp | 2 +- Core/Algorithms/src/OpticalFresnel.cpp | 14 +++++----- Core/FormFactors/inc/FormFactorCrystal.h | 2 +- Core/FormFactors/inc/FormFactorCylinder.h | 5 ++-- .../inc/FormFactorDecoratorFactor.h | 4 +-- .../inc/FormFactorDecoratorRefractiveIndex.h | 12 ++++---- Core/FormFactors/inc/FormFactorEllipsoid.h | 3 +- Core/FormFactors/inc/FormFactorWeighted.h | 2 +- Core/FormFactors/inc/IFormFactor.h | 2 +- Core/FormFactors/inc/IFormFactorDecorator.h | 4 +-- Core/FormFactors/src/FormFactorCrystal.cpp | 2 +- Core/FormFactors/src/FormFactorWeighted.cpp | 2 +- Core/Geometry/inc/BasicVector3D.h | 12 ++++---- Core/Geometry/src/Transform3D.cpp | 12 ++++---- Core/Samples/inc/HomogeneousMaterial.h | 4 +-- .../inc/InterferenceFunction2DParaCrystal.h | 6 ++-- Core/Samples/inc/Layer.h | 5 ++-- Core/Samples/inc/LayerInterface.h | 6 ++-- Core/Samples/inc/MultiLayer.h | 12 ++++---- Core/Samples/inc/Particle.h | 4 +-- Core/Samples/src/HomogeneousMaterial.cpp | 4 +-- Core/Samples/src/Particle.cpp | 4 +-- Core/Tools/inc/AxisBin.h | 4 +-- Core/Tools/inc/FitSuite.h | 12 ++++---- Core/Tools/inc/FitSuiteStrategy.h | 2 +- Core/Tools/inc/MathFunctions.h | 8 +++--- Core/Tools/inc/OutputData.h | 2 +- Core/Tools/inc/ParameterPool.h | 4 +-- Core/Tools/inc/ProgramOptions.h | 4 +-- Core/Tools/inc/StochasticGaussian.h | 2 +- Core/Tools/inc/Types.h | 2 +- Core/Tools/inc/Utils.h | 2 +- Core/Tools/src/FitSuite.cpp | 2 +- Core/Tools/src/FitSuiteStrategy.cpp | 2 +- Core/Tools/src/ParameterPool.cpp | 28 +++++++++---------- 45 files changed, 127 insertions(+), 114 deletions(-) diff --git a/Core/Algorithms/inc/ChiSquaredFrequency.h b/Core/Algorithms/inc/ChiSquaredFrequency.h index c13a9d9a9da..3079f31595b 100644 --- a/Core/Algorithms/inc/ChiSquaredFrequency.h +++ b/Core/Algorithms/inc/ChiSquaredFrequency.h @@ -27,7 +27,7 @@ public: void setCutoff(double cutoff) { if (cutoff>=0.0 && cutoff<=1.0) m_cutoff = cutoff; } - double getCutoff() { return m_cutoff; } + double getCutoff() const { return m_cutoff; } //! return output data which contains chi^2 values virtual OutputData<double > *createChi2DifferenceMap() const; diff --git a/Core/Algorithms/inc/DWBADiffuseReflection.h b/Core/Algorithms/inc/DWBADiffuseReflection.h index f9f13aa2761..a114051a800 100644 --- a/Core/Algorithms/inc/DWBADiffuseReflection.h +++ b/Core/Algorithms/inc/DWBADiffuseReflection.h @@ -43,7 +43,7 @@ private: void diffuse_crosscorr(); - complex_t get_refractive_term(size_t ilayer); + complex_t get_refractive_term(size_t ilayer) const; complex_t get_sum4terms(size_t ilayer); diff --git a/Core/Algorithms/inc/DecouplingApproximationStrategy.h b/Core/Algorithms/inc/DecouplingApproximationStrategy.h index 1b6e3214b5f..0d0789b5919 100644 --- a/Core/Algorithms/inc/DecouplingApproximationStrategy.h +++ b/Core/Algorithms/inc/DecouplingApproximationStrategy.h @@ -29,7 +29,7 @@ public: virtual double evaluate(const cvector_t &k_i, const Bin1DCVector &k_f_bin, double alpha_i, double alpha_f) const; private: - bool checkVectorSizes(); + bool checkVectorSizes() const; }; diff --git a/Core/Algorithms/inc/Detector.h b/Core/Algorithms/inc/Detector.h index 8bc3ad098c2..0a13ad61d1f 100644 --- a/Core/Algorithms/inc/Detector.h +++ b/Core/Algorithms/inc/Detector.h @@ -56,7 +56,7 @@ private: void swapContent(Detector &other); //! initialize axis the way IsGISAXS does - void initializeAnglesIsgisaxs(AxisDouble *p_axis, const TSampledRange<double> &axis_range); + void initializeAnglesIsgisaxs(AxisDouble *p_axis, const TSampledRange<double> &axis_range) const; SafePointerVector<IAxis> m_axes; IDetectorResolution *mp_detector_resolution; diff --git a/Core/Algorithms/inc/FTDistributions.h b/Core/Algorithms/inc/FTDistributions.h index d15a793cb41..59a23af9912 100644 --- a/Core/Algorithms/inc/FTDistributions.h +++ b/Core/Algorithms/inc/FTDistributions.h @@ -38,8 +38,8 @@ public: virtual IFTDistribution2D *clone() const=0; - double getGamma() { return m_gamma; } - double getDelta() { return m_delta; } + double getGamma() const { return m_gamma; } + double getDelta() const { return m_delta; } virtual double evaluate(double qx, double qy) const=0; protected: double m_omega_x; diff --git a/Core/Algorithms/inc/GISASExperiment.h b/Core/Algorithms/inc/GISASExperiment.h index 2886b53ba37..489fd481afc 100644 --- a/Core/Algorithms/inc/GISASExperiment.h +++ b/Core/Algorithms/inc/GISASExperiment.h @@ -55,10 +55,12 @@ protected: GISASExperiment(const GISASExperiment &other); GISASExperiment &operator=(const GISASExperiment &); -private: //! initialize pool parameters, i.e. register some of class members for later access via parameter pool virtual void init_parameters(); + +private: + double getSolidAngle(size_t index) const; double deltaAlpha(double alpha, double zeta) const; double deltaPhi(double alpha, double phi, double zeta) const; diff --git a/Core/Algorithms/inc/Mask.h b/Core/Algorithms/inc/Mask.h index 2aaecf7648f..2075bea1be9 100644 --- a/Core/Algorithms/inc/Mask.h +++ b/Core/Algorithms/inc/Mask.h @@ -16,7 +16,7 @@ #include "MaskCoordinateFunction.h" -#include <cstddef> +//#include <cstddef> //- ------------------------------------------------------------------- //! @class Mask @@ -59,8 +59,10 @@ public: virtual ~MaskIndexModulus() {} virtual MaskIndexModulus *clone() const; -private: +protected: virtual bool isMasked(size_t total_index) const; + +private: size_t m_modulus; size_t m_remainder; }; @@ -78,8 +80,10 @@ public: void setMaskCoordinateFunction(MaskCoordinateFunction *p_mask_function); -private: +protected: virtual bool isMasked(size_t total_index) const; + +private: void setCachedCoordinates(size_t index) const; size_t m_rank; int *m_dims; diff --git a/Core/Algorithms/inc/OpticalFresnel.h b/Core/Algorithms/inc/OpticalFresnel.h index 722736854b9..50733a50bfb 100644 --- a/Core/Algorithms/inc/OpticalFresnel.h +++ b/Core/Algorithms/inc/OpticalFresnel.h @@ -71,13 +71,13 @@ public: private: bool m_use_roughness; - void calculateKZ(const MultiLayer &sample, const kvector_t &k, MultiLayerCoeff_t &coeff); - void calculateFresnelCoefficients(MultiLayerCoeff_t &coeff); - void calculateFresnelCoefficientsWithRoughness(const MultiLayer &sample, MultiLayerCoeff_t &coeff); - void calculateX(const MultiLayer &sample, MultiLayerCoeff_t &coeff); - void calculateX2(const MultiLayer &sample, MultiLayerCoeff_t &coeff); - void calculateRT(const MultiLayer &sample, MultiLayerCoeff_t &coeff); - void calculateRT2(const MultiLayer &sample, MultiLayerCoeff_t &coeff); + void calculateKZ(const MultiLayer &sample, const kvector_t &k, MultiLayerCoeff_t &coeff) const; + void calculateFresnelCoefficients(MultiLayerCoeff_t &coeff) const; + void calculateFresnelCoefficientsWithRoughness(const MultiLayer &sample, MultiLayerCoeff_t &coeff) const; + void calculateX(const MultiLayer &sample, MultiLayerCoeff_t &coeff) const; + void calculateX2(const MultiLayer &sample, MultiLayerCoeff_t &coeff) const; + void calculateRT(const MultiLayer &sample, MultiLayerCoeff_t &coeff) const; + void calculateRT2(const MultiLayer &sample, MultiLayerCoeff_t &coeff) const; }; diff --git a/Core/Algorithms/src/DWBADiffuseReflection.cpp b/Core/Algorithms/src/DWBADiffuseReflection.cpp index b6e7c3ceb43..797c93150fb 100644 --- a/Core/Algorithms/src/DWBADiffuseReflection.cpp +++ b/Core/Algorithms/src/DWBADiffuseReflection.cpp @@ -77,7 +77,7 @@ void DWBADiffuseReflection::diffuse_crosscorr() } -complex_t DWBADiffuseReflection::get_refractive_term(size_t ilayer) +complex_t DWBADiffuseReflection::get_refractive_term(size_t ilayer) const { complex_t n1 = m_sample->getLayer(ilayer)->getRefractiveIndex(); complex_t n2 = m_sample->getLayer(ilayer+1)->getRefractiveIndex(); diff --git a/Core/Algorithms/src/DecouplingApproximationStrategy.cpp b/Core/Algorithms/src/DecouplingApproximationStrategy.cpp index 06da60a892e..c567f73a806 100644 --- a/Core/Algorithms/src/DecouplingApproximationStrategy.cpp +++ b/Core/Algorithms/src/DecouplingApproximationStrategy.cpp @@ -32,7 +32,7 @@ double DecouplingApproximationStrategy::evaluate(const cvector_t& k_i, return intensity + amplitude_norm*(itf_function-1.0); } -bool DecouplingApproximationStrategy::checkVectorSizes() +bool DecouplingApproximationStrategy::checkVectorSizes() const { size_t n_ffs = m_form_factors.size(); size_t n_frs = m_fractions.size(); diff --git a/Core/Algorithms/src/Detector.cpp b/Core/Algorithms/src/Detector.cpp index 8a4e2f20f89..dba08b873fb 100644 --- a/Core/Algorithms/src/Detector.cpp +++ b/Core/Algorithms/src/Detector.cpp @@ -120,7 +120,7 @@ void Detector::init_parameters() { } -void Detector::initializeAnglesIsgisaxs(AxisDouble* p_axis, const TSampledRange<double>& axis_range) +void Detector::initializeAnglesIsgisaxs(AxisDouble* p_axis, const TSampledRange<double>& axis_range) const { double start_sin = std::sin(axis_range.getMin()); double end_sin = std::sin(axis_range.getMax()); diff --git a/Core/Algorithms/src/OpticalFresnel.cpp b/Core/Algorithms/src/OpticalFresnel.cpp index cdbd657010b..1046b35ea2c 100644 --- a/Core/Algorithms/src/OpticalFresnel.cpp +++ b/Core/Algorithms/src/OpticalFresnel.cpp @@ -38,7 +38,7 @@ void OpticalFresnel::execute(const MultiLayer &sample, const kvector_t &kvec, Mu } -void OpticalFresnel::calculateKZ(const MultiLayer &sample, const kvector_t &kvec, MultiLayerCoeff_t &coeff) +void OpticalFresnel::calculateKZ(const MultiLayer &sample, const kvector_t &kvec, MultiLayerCoeff_t &coeff) const { // z-component of reflected wave vector inside each layer // Q_{z,j} &= 2k_{z,j} = 2\cdot \sqrt{ k^2 n_j^2 - k_x^2 } @@ -50,7 +50,7 @@ void OpticalFresnel::calculateKZ(const MultiLayer &sample, const kvector_t &kvec } } -void OpticalFresnel::calculateFresnelCoefficients(MultiLayerCoeff_t &coeff) +void OpticalFresnel::calculateFresnelCoefficients(MultiLayerCoeff_t &coeff) const { // calculation of reflection/transmission Fresnel coefficients for(size_t i=0; i<coeff.size() - 1; i++) { @@ -76,7 +76,7 @@ void OpticalFresnel::calculateFresnelCoefficients(MultiLayerCoeff_t &coeff) } -void OpticalFresnel::calculateFresnelCoefficientsWithRoughness(const MultiLayer &sample, MultiLayerCoeff_t &coeff) +void OpticalFresnel::calculateFresnelCoefficientsWithRoughness(const MultiLayer &sample, MultiLayerCoeff_t &coeff) const { double picoeff = std::pow(M_PI/2., 1.5); @@ -115,7 +115,7 @@ void OpticalFresnel::calculateFresnelCoefficientsWithRoughness(const MultiLayer } -void OpticalFresnel::calculateX(const MultiLayer &sample, MultiLayerCoeff_t &coeff) +void OpticalFresnel::calculateX(const MultiLayer &sample, MultiLayerCoeff_t &coeff) const { // ratio of amplitudes of outgoing and incoming waves coeff[coeff.size()-1].X = complex_t(0, 0); @@ -127,7 +127,7 @@ void OpticalFresnel::calculateX(const MultiLayer &sample, MultiLayerCoeff_t &coe } } -void OpticalFresnel::calculateX2(const MultiLayer &sample, MultiLayerCoeff_t &coeff) +void OpticalFresnel::calculateX2(const MultiLayer &sample, MultiLayerCoeff_t &coeff) const { // ratio of amplitudes of outgoing and incoming waves in alternative conventions coeff[coeff.size()-1].X = complex_t(0, 0); @@ -149,7 +149,7 @@ void OpticalFresnel::calculateX2(const MultiLayer &sample, MultiLayerCoeff_t &co } } -void OpticalFresnel::calculateRT(const MultiLayer &sample, MultiLayerCoeff_t &coeff) +void OpticalFresnel::calculateRT(const MultiLayer &sample, MultiLayerCoeff_t &coeff) const { coeff[0].R = coeff[0].X; coeff[0].T = 1; @@ -163,7 +163,7 @@ void OpticalFresnel::calculateRT(const MultiLayer &sample, MultiLayerCoeff_t &co } } -void OpticalFresnel::calculateRT2(const MultiLayer &sample, MultiLayerCoeff_t &coeff) +void OpticalFresnel::calculateRT2(const MultiLayer &sample, MultiLayerCoeff_t &coeff) const { //complex_t ct0(0,0); diff --git a/Core/FormFactors/inc/FormFactorCrystal.h b/Core/FormFactors/inc/FormFactorCrystal.h index 11754d5ba2a..df8829c20b3 100644 --- a/Core/FormFactors/inc/FormFactorCrystal.h +++ b/Core/FormFactors/inc/FormFactorCrystal.h @@ -31,7 +31,7 @@ public: virtual FormFactorCrystal *clone() const; - virtual void setAmbientRefractiveIndex(complex_t refractive_index); + virtual void setAmbientRefractiveIndex(const complex_t &refractive_index); virtual complex_t evaluate(const cvector_t &k_i, const Bin1DCVector &k_f_bin, double alpha_i, double alpha_f) const; diff --git a/Core/FormFactors/inc/FormFactorCylinder.h b/Core/FormFactors/inc/FormFactorCylinder.h index 4103d8fb206..43995257e36 100644 --- a/Core/FormFactors/inc/FormFactorCylinder.h +++ b/Core/FormFactors/inc/FormFactorCylinder.h @@ -32,14 +32,15 @@ public: virtual complex_t evaluate_for_q(const cvector_t &q) const; +protected: + //! initialize pool parameters, i.e. register some of class members for later access via parameter pool + virtual void init_parameters(); private: FormFactorCylinder(const FormFactorCylinder &); FormFactorCylinder &operator=(const FormFactorCylinder &); - //! initialize pool parameters, i.e. register some of class members for later access via parameter pool - virtual void init_parameters(); // //! print class // void print(std::ostream &ostr) const; diff --git a/Core/FormFactors/inc/FormFactorDecoratorFactor.h b/Core/FormFactors/inc/FormFactorDecoratorFactor.h index 8ed3306d5c8..4b71515f395 100644 --- a/Core/FormFactors/inc/FormFactorDecoratorFactor.h +++ b/Core/FormFactors/inc/FormFactorDecoratorFactor.h @@ -20,7 +20,7 @@ class FormFactorDecoratorFactor : public IFormFactorDecorator { public: - FormFactorDecoratorFactor(IFormFactor *p_form_factor, complex_t factor); + FormFactorDecoratorFactor(IFormFactor *p_form_factor, const complex_t &factor); virtual FormFactorDecoratorFactor *clone() const; virtual ~FormFactorDecoratorFactor() {} @@ -37,7 +37,7 @@ private: }; inline FormFactorDecoratorFactor::FormFactorDecoratorFactor( - IFormFactor* p_form_factor, complex_t factor) + IFormFactor* p_form_factor, const complex_t &factor) : IFormFactorDecorator(p_form_factor) , m_factor(factor) { diff --git a/Core/FormFactors/inc/FormFactorDecoratorRefractiveIndex.h b/Core/FormFactors/inc/FormFactorDecoratorRefractiveIndex.h index c51089753fb..905a9f6d7d2 100644 --- a/Core/FormFactors/inc/FormFactorDecoratorRefractiveIndex.h +++ b/Core/FormFactors/inc/FormFactorDecoratorRefractiveIndex.h @@ -19,23 +19,23 @@ class FormFactorDecoratorRefractiveIndex : public FormFactorDecoratorFactor { public: - FormFactorDecoratorRefractiveIndex(IFormFactor *p_form_factor, complex_t refractive_index); + FormFactorDecoratorRefractiveIndex(IFormFactor *p_form_factor, const complex_t &refractive_index); ~FormFactorDecoratorRefractiveIndex(); FormFactorDecoratorRefractiveIndex *clone() const; - virtual void setAmbientRefractiveIndex(complex_t ambient_refractive_index); + virtual void setAmbientRefractiveIndex(const complex_t &ambient_refractive_index); private: FormFactorDecoratorRefractiveIndex(const FormFactorDecoratorRefractiveIndex &); FormFactorDecoratorRefractiveIndex &operator=(const FormFactorDecoratorRefractiveIndex &); - complex_t getRefractiveIndexFactor(complex_t ambient_index, complex_t particle_index); + complex_t getRefractiveIndexFactor(const complex_t &ambient_index, const complex_t &particle_index); complex_t m_refractive_index; }; inline FormFactorDecoratorRefractiveIndex::FormFactorDecoratorRefractiveIndex( - IFormFactor* p_form_factor, complex_t refractive_index) + IFormFactor* p_form_factor, const complex_t &refractive_index) : FormFactorDecoratorFactor(p_form_factor, getRefractiveIndexFactor(complex_t(1.0, 0.0), refractive_index)) , m_refractive_index(refractive_index) @@ -56,13 +56,13 @@ inline FormFactorDecoratorRefractiveIndex* FormFactorDecoratorRefractiveIndex::c } inline void FormFactorDecoratorRefractiveIndex::setAmbientRefractiveIndex( - complex_t ambient_refractive_index) + const complex_t &ambient_refractive_index) { m_factor = getRefractiveIndexFactor(ambient_refractive_index, m_refractive_index); } inline complex_t FormFactorDecoratorRefractiveIndex::getRefractiveIndexFactor( - complex_t ambient_index, complex_t particle_index) + const complex_t &ambient_index, const complex_t &particle_index) { return (ambient_index*ambient_index - particle_index*particle_index); } diff --git a/Core/FormFactors/inc/FormFactorEllipsoid.h b/Core/FormFactors/inc/FormFactorEllipsoid.h index eabe27db16c..b3687f0847e 100644 --- a/Core/FormFactors/inc/FormFactorEllipsoid.h +++ b/Core/FormFactors/inc/FormFactorEllipsoid.h @@ -38,9 +38,10 @@ public: virtual double getHeight() const { return m_height; } -protected: virtual complex_t evaluate_for_q(const cvector_t &q) const; + +protected: //! initialize pool parameters, i.e. register some of class members for later access via parameter pool virtual void init_parameters(); diff --git a/Core/FormFactors/inc/FormFactorWeighted.h b/Core/FormFactors/inc/FormFactorWeighted.h index a7abd5aec40..27befbce249 100644 --- a/Core/FormFactors/inc/FormFactorWeighted.h +++ b/Core/FormFactors/inc/FormFactorWeighted.h @@ -25,7 +25,7 @@ public: void addFormFactor(const IFormFactor &form_factor, double weight=1.0); - virtual void setAmbientRefractiveIndex(complex_t refractive_index); + virtual void setAmbientRefractiveIndex(const complex_t &refractive_index); virtual complex_t evaluate(const cvector_t &k_i, const Bin1DCVector &k_f_bin, double alpha_i, double alpha_f) const; diff --git a/Core/FormFactors/inc/IFormFactor.h b/Core/FormFactors/inc/IFormFactor.h index 01c8a4f20ab..276e37d3619 100644 --- a/Core/FormFactors/inc/IFormFactor.h +++ b/Core/FormFactors/inc/IFormFactor.h @@ -37,7 +37,7 @@ public: virtual IFormFactor *clone() const=0; //! pass the refractive index of the ambient material in which this particle is embedded - virtual void setAmbientRefractiveIndex(complex_t refractive_index) { (void)refractive_index; } + virtual void setAmbientRefractiveIndex(const complex_t &refractive_index) { (void)refractive_index; } //! calculate scattering amplitude for complex wavevector bin //! @param k_i incoming wavevector diff --git a/Core/FormFactors/inc/IFormFactorDecorator.h b/Core/FormFactors/inc/IFormFactorDecorator.h index 1d600533b83..7efe83a9c9f 100644 --- a/Core/FormFactors/inc/IFormFactorDecorator.h +++ b/Core/FormFactors/inc/IFormFactorDecorator.h @@ -30,7 +30,7 @@ public: virtual ~IFormFactorDecorator(); virtual IFormFactorDecorator *clone() const=0; - virtual void setAmbientRefractiveIndex(complex_t refractive_index); + virtual void setAmbientRefractiveIndex(const complex_t &refractive_index); virtual double getVolume() const; @@ -47,7 +47,7 @@ inline IFormFactorDecorator::~IFormFactorDecorator() delete mp_form_factor; } -inline void IFormFactorDecorator::setAmbientRefractiveIndex(complex_t refractive_index) +inline void IFormFactorDecorator::setAmbientRefractiveIndex(const complex_t &refractive_index) { if (mp_form_factor) mp_form_factor->setAmbientRefractiveIndex(refractive_index); } diff --git a/Core/FormFactors/src/FormFactorCrystal.cpp b/Core/FormFactors/src/FormFactorCrystal.cpp index cf609f3fb89..fdbfb3e2679 100644 --- a/Core/FormFactors/src/FormFactorCrystal.cpp +++ b/Core/FormFactors/src/FormFactorCrystal.cpp @@ -32,7 +32,7 @@ FormFactorCrystal* FormFactorCrystal::clone() const } void FormFactorCrystal::setAmbientRefractiveIndex( - complex_t refractive_index) + const complex_t &refractive_index) { mp_particle->setAmbientRefractiveIndex(refractive_index); mp_basis_form_factor->setAmbientRefractiveIndex(refractive_index); diff --git a/Core/FormFactors/src/FormFactorWeighted.cpp b/Core/FormFactors/src/FormFactorWeighted.cpp index de0ac0e029a..2b1ad987617 100644 --- a/Core/FormFactors/src/FormFactorWeighted.cpp +++ b/Core/FormFactors/src/FormFactorWeighted.cpp @@ -28,7 +28,7 @@ void FormFactorWeighted::addFormFactor(const IFormFactor& form_factor, m_weights.push_back(weight); } -void FormFactorWeighted::setAmbientRefractiveIndex(complex_t refractive_index) +void FormFactorWeighted::setAmbientRefractiveIndex(const complex_t &refractive_index) { for (size_t index=0; index<m_form_factors.size(); ++index) { m_form_factors[index]->setAmbientRefractiveIndex(refractive_index); diff --git a/Core/Geometry/inc/BasicVector3D.h b/Core/Geometry/inc/BasicVector3D.h index 3094343f61c..9482fae8851 100755 --- a/Core/Geometry/inc/BasicVector3D.h +++ b/Core/Geometry/inc/BasicVector3D.h @@ -16,7 +16,7 @@ //#include "CLHEP/Geometry/defs.h" //#include "CLHEP/Vector/ThreeVector.h" #include <cmath> -#include <iostream> +//#include <iostream> #include <complex> namespace Geometry { @@ -155,18 +155,18 @@ class Transform3D; /** * Sets x-component in cartesian coordinate system. */ - inline void setX(T a) { v_[0] = a; } + inline void setX(const T &a) { v_[0] = a; } /** * Sets y-component in cartesian coordinate system. */ - inline void setY(T a) { v_[1] = a; } + inline void setY(const T &a) { v_[1] = a; } /** * Sets z-component in cartesian coordinate system. */ - inline void setZ(T a) { v_[2] = a; } + inline void setZ(const T &a) { v_[2] = a; } /** * Sets components in cartesian coordinate system. */ - inline void set(T x1, T y1, T z1) { v_[0] = x1; v_[1] = y1; v_[2] = z1; } - inline void setXYZ(T x1, T y1, T z1) { v_[0] = x1; v_[1] = y1; v_[2] = z1; } + inline void set(const T &x1, const T &y1, const T &z1) { v_[0] = x1; v_[1] = y1; v_[2] = z1; } + inline void setXYZ(const T &x1, const T &y1, const T &z1) { v_[0] = x1; v_[1] = y1; v_[2] = z1; } // ------------------------------------------ // Cylindrical coordinate system: rho, phi, z diff --git a/Core/Geometry/src/Transform3D.cpp b/Core/Geometry/src/Transform3D.cpp index ff4cf7241a6..8bfac1e5ce6 100755 --- a/Core/Geometry/src/Transform3D.cpp +++ b/Core/Geometry/src/Transform3D.cpp @@ -198,11 +198,11 @@ namespace Geometry { if (xx_*(yy_*zz_-yz_*zy_) - xy_*(yx_*zz_-yz_*zx_) + xz_*(yx_*zy_-yy_*zx_) < 0) sz = -sz; - scale.setTransform(sx,0,0,0, 0,sy,0,0, 0,0,sz,0); - rotation.setTransform(xx_/sx,xy_/sy,xz_/sz,0, - yx_/sx,yy_/sy,yz_/sz,0, - zx_/sx,zy_/sy,zz_/sz,0); - translation.setTransform(1,0,0,dx_, 0,1,0,dy_, 0,0,1,dz_); + scale.setTransform(sx,0.0,0.0,0.0, 0.0,sy,0.0,0.0, 0.0,0.0,sz,0.0); + rotation.setTransform(xx_/sx,xy_/sy,xz_/sz,0.0, + yx_/sx,yy_/sy,yz_/sz,0.0, + zx_/sx,zy_/sy,zz_/sz,0.0); + translation.setTransform(1.0,0.0,0.0,dx_, 0.0,1.0,0.0,dy_, 0.0,0.0,1.0,dz_); } // ------------------------------------------------------------------------- @@ -215,7 +215,7 @@ namespace Geometry { (std::abs(yx_ - t.yx_) <= tolerance) && (std::abs(yy_ - t.yy_) <= tolerance) && (std::abs(yz_ - t.yz_) <= tolerance) && - (std::abs(dy_ - t.dy_) <= tolerance) && + (std::abs(dy_ - t.dy_) <= tolerance) && (std::abs(zx_ - t.zx_) <= tolerance) && (std::abs(zy_ - t.zy_) <= tolerance) && (std::abs(zz_ - t.zz_) <= tolerance) && diff --git a/Core/Samples/inc/HomogeneousMaterial.h b/Core/Samples/inc/HomogeneousMaterial.h index d5704f906fa..a1fa5115204 100644 --- a/Core/Samples/inc/HomogeneousMaterial.h +++ b/Core/Samples/inc/HomogeneousMaterial.h @@ -26,8 +26,8 @@ class HomogeneousMaterial : public IMaterial { public: HomogeneousMaterial(); - HomogeneousMaterial(complex_t refractive_index); - HomogeneousMaterial(const std::string &name, complex_t refractive_index); + HomogeneousMaterial(const complex_t &refractive_index); + HomogeneousMaterial(const std::string &name, const complex_t &refractive_index); HomogeneousMaterial(const std::string &name, double refractive_index_real, double refractive_index_imag ); HomogeneousMaterial(const HomogeneousMaterial &other); HomogeneousMaterial &operator=(const HomogeneousMaterial &other); diff --git a/Core/Samples/inc/InterferenceFunction2DParaCrystal.h b/Core/Samples/inc/InterferenceFunction2DParaCrystal.h index 128908e006d..3554e36ffde 100644 --- a/Core/Samples/inc/InterferenceFunction2DParaCrystal.h +++ b/Core/Samples/inc/InterferenceFunction2DParaCrystal.h @@ -48,6 +48,9 @@ public: //! add parameters from local pool to external pool and call recursion over direct children virtual std::string addParametersToExternalPool(std::string path, ParameterPool *external_pool, int copy_number=-1) const; protected: + //! initialize pool parameters, i.e. register some of class members for later access via parameter pool + virtual void init_parameters(); + void transformToPrincipalAxes(double qx, double qy, double gamma, double delta, double &q_pa_1, double &q_pa_2) const; double m_lattice_lengths[2]; double m_alpha_lattice; //!< Angle between lattice basis vectors @@ -62,9 +65,6 @@ private: InterferenceFunction2DParaCrystal(const InterferenceFunction2DParaCrystal &); InterferenceFunction2DParaCrystal &operator=(const InterferenceFunction2DParaCrystal &); - //! initialize pool parameters, i.e. register some of class members for later access via parameter pool - virtual void init_parameters(); - //! Calculate interference function for fixed rotation xi double interferenceForXi(double xi, void *params) const; diff --git a/Core/Samples/inc/Layer.h b/Core/Samples/inc/Layer.h index a335abe7b9a..cd71344cb55 100644 --- a/Core/Samples/inc/Layer.h +++ b/Core/Samples/inc/Layer.h @@ -62,12 +62,13 @@ public: virtual LayerDWBASimulation *createDWBASimulation() const { return 0; } protected: + //! initialize pool parameters, i.e. register some of class members for later access via parameter pool + virtual void init_parameters(); + Layer &operator=(const Layer &other); Layer(const Layer &other); private: - //! initialize pool parameters, i.e. register some of class members for later access via parameter pool - virtual void init_parameters(); //! print class void print(std::ostream &ostr) const; diff --git a/Core/Samples/inc/LayerInterface.h b/Core/Samples/inc/LayerInterface.h index a78d5b641db..b1ff3ad6abd 100644 --- a/Core/Samples/inc/LayerInterface.h +++ b/Core/Samples/inc/LayerInterface.h @@ -63,13 +63,15 @@ public: //! print class friend std::ostream &operator<<(std::ostream &ostr, const LayerInterface &m) { m.print(ostr); return ostr; } +protected: + //! print class + void print(std::ostream &ostr) const; + private: LayerInterface(); LayerInterface(const LayerInterface &); LayerInterface &operator=(const LayerInterface &); - //! print class - void print(std::ostream &ostr) const; LayerRoughness *m_roughness; //!< roughness of the interface const Layer *m_LayerTop; //!< pointer to the layer above interface diff --git a/Core/Samples/inc/MultiLayer.h b/Core/Samples/inc/MultiLayer.h index 6e36b81cedd..877bbe4ca12 100644 --- a/Core/Samples/inc/MultiLayer.h +++ b/Core/Samples/inc/MultiLayer.h @@ -100,6 +100,13 @@ public: //! look for the presence of DWBA terms (e.g. included particles) and return ISimulation if needed virtual MultiLayerDWBASimulation *createDWBASimulation() const; +protected: + //! initialize pool parameters, i.e. register some of class members for later access via parameter pool + virtual void init_parameters(); + //! print class + void print(std::ostream &ostr) const; + + private: //! copy constructor and assignment operator are hidden since there is a clone method MultiLayer(const MultiLayer &); @@ -125,11 +132,6 @@ private: //! check index of interface w.r.t. vector length inline size_t check_interface_index(size_t i_interface) const { return i_interface < m_interfaces.size() ? i_interface : throw OutOfBoundsException("Interface index is out of bounds"); } - //! initialize pool parameters, i.e. register some of class members for later access via parameter pool - virtual void init_parameters(); - - //! print class - void print(std::ostream &ostr) const; std::vector<Layer *> m_layers; ///< stack of layers [nlayers] std::vector<double > m_layers_z; ///< coordinate of layer's bottoms [nlayers] diff --git a/Core/Samples/inc/Particle.h b/Core/Samples/inc/Particle.h index a6d7d5e1bd2..21323ca56e5 100644 --- a/Core/Samples/inc/Particle.h +++ b/Core/Samples/inc/Particle.h @@ -28,8 +28,8 @@ class ParticleInfo; class Particle : public ICompositeSample { public: - Particle(complex_t refractive_index, IFormFactor* p_form_factor = 0); - Particle(complex_t refractive_index, const IFormFactor &p_form_factor); + Particle(const complex_t &refractive_index, IFormFactor* p_form_factor = 0); + Particle(const complex_t &refractive_index, const IFormFactor &p_form_factor); virtual ~Particle(); virtual Particle *clone() const; diff --git a/Core/Samples/src/HomogeneousMaterial.cpp b/Core/Samples/src/HomogeneousMaterial.cpp index d66cbdf40e0..25ac5942bf8 100644 --- a/Core/Samples/src/HomogeneousMaterial.cpp +++ b/Core/Samples/src/HomogeneousMaterial.cpp @@ -7,14 +7,14 @@ HomogeneousMaterial::HomogeneousMaterial() } -HomogeneousMaterial::HomogeneousMaterial(complex_t refractive_index) +HomogeneousMaterial::HomogeneousMaterial(const complex_t &refractive_index) : IMaterial("noname"), m_refractive_index(refractive_index) { } -HomogeneousMaterial::HomogeneousMaterial(const std::string &name, complex_t refractive_index) +HomogeneousMaterial::HomogeneousMaterial(const std::string &name, const complex_t &refractive_index) : IMaterial(name), m_refractive_index(refractive_index) { diff --git a/Core/Samples/src/Particle.cpp b/Core/Samples/src/Particle.cpp index 211ca42024b..3f540809dec 100644 --- a/Core/Samples/src/Particle.cpp +++ b/Core/Samples/src/Particle.cpp @@ -1,7 +1,7 @@ #include "Particle.h" #include "ParticleInfo.h" -Particle::Particle(complex_t refractive_index, IFormFactor *p_form_factor) +Particle::Particle(const complex_t &refractive_index, IFormFactor *p_form_factor) : m_ambient_refractive_index(complex_t(1.0, 0.0)) , m_refractive_index(refractive_index) , mp_form_factor(p_form_factor) @@ -10,7 +10,7 @@ Particle::Particle(complex_t refractive_index, IFormFactor *p_form_factor) if(mp_form_factor) registerChild(mp_form_factor); } -Particle::Particle(complex_t refractive_index, const IFormFactor &p_form_factor) +Particle::Particle(const complex_t &refractive_index, const IFormFactor &p_form_factor) : m_ambient_refractive_index(complex_t(1.0, 0.0)) , m_refractive_index(refractive_index) , mp_form_factor(p_form_factor.clone()) diff --git a/Core/Tools/inc/AxisBin.h b/Core/Tools/inc/AxisBin.h index 8e2f0e2614a..2a83a1297de 100644 --- a/Core/Tools/inc/AxisBin.h +++ b/Core/Tools/inc/AxisBin.h @@ -16,8 +16,8 @@ #include "IAxis.h" -#include <string> -#include <vector> +//#include <string> +//#include <vector> //- ------------------------------------------------------------------- //! @class BinAxis diff --git a/Core/Tools/inc/FitSuite.h b/Core/Tools/inc/FitSuite.h index 708485d7e18..09376b26397 100644 --- a/Core/Tools/inc/FitSuite.h +++ b/Core/Tools/inc/FitSuite.h @@ -83,14 +83,14 @@ public: FitSuiteParameters *getFitParameters() { return &m_fit_parameters; } //! if the last iteration is done (used by observers to print summary) - bool isLastIteration() { return m_is_last_iteration; } + bool isLastIteration() const { return m_is_last_iteration; } //! get current number of minimization function calls //int getNCall() { return m_n_call; } - int getNCall() { return m_function_chi2.getNCall(); } + size_t getNCall() const { return m_function_chi2.getNCall(); } //! get the number of current strategy - int getNStrategy() { return m_n_strategy; } + size_t getNStrategy() const { return m_n_strategy; } private: //! disabled copy constructor and assignment operator @@ -98,7 +98,7 @@ private: FitSuite(const FitSuite &); //! check if all prerequisites to run fit fit are filled - bool check_prerequisites(); + bool check_prerequisites() const; FitSuiteObjects m_fit_objects; //! kit which contains sets of <experiment,real_data,chi_module> to fit FitSuiteParameters m_fit_parameters; //! collection of fit parameters @@ -106,8 +106,8 @@ private: IMinimizer *m_minimizer; //! minimization engine bool m_is_last_iteration; //! set to true after last iteration complete - int m_n_call; //! current number of minimization function call - int m_n_strategy; //! current number of fit strategy + size_t m_n_call; //! current number of minimization function call + size_t m_n_strategy; //! current number of fit strategy FitSuiteChiSquaredFunction m_function_chi2; FitSuiteGradientFunction m_function_gradient; diff --git a/Core/Tools/inc/FitSuiteStrategy.h b/Core/Tools/inc/FitSuiteStrategy.h index caba8ad0963..4085f22aab8 100644 --- a/Core/Tools/inc/FitSuiteStrategy.h +++ b/Core/Tools/inc/FitSuiteStrategy.h @@ -132,7 +132,7 @@ public: }; //! generate noisy data - OutputData<double> *generateNoisyData(double noise_factor, const OutputData<double> &source); + OutputData<double> *generateNoisyData(double noise_factor, const OutputData<double> &source) const; private: int m_n_iterations; diff --git a/Core/Tools/inc/MathFunctions.h b/Core/Tools/inc/MathFunctions.h index 469a78eebbf..bc8f2497ed4 100644 --- a/Core/Tools/inc/MathFunctions.h +++ b/Core/Tools/inc/MathFunctions.h @@ -50,9 +50,9 @@ double Si(double value); double Sinc(double value); //! Complex Sinc function: \f$Sinc(x)\equiv\sin(x)/x\f$ -complex_t Sinc(complex_t value); +complex_t Sinc(const complex_t &value); -complex_t Laue(complex_t value, size_t N); +complex_t Laue(const complex_t &value, size_t N); enum TransformCase { ForwardFFT, BackwardFFT }; std::vector<complex_t > FastFourierTransform(const std::vector<complex_t > &data, TransformCase tcase); @@ -104,7 +104,7 @@ inline double MathFunctions::Sinc(double value) // Sin(x)/x return gsl_sf_sinc(value/M_PI); } -inline complex_t MathFunctions::Sinc(complex_t value) // Sin(x)/x +inline complex_t MathFunctions::Sinc(const complex_t &value) // Sin(x)/x { if(std::abs(value)<Numeric::double_epsilon) { return complex_t(1.0, 0.0); @@ -112,7 +112,7 @@ inline complex_t MathFunctions::Sinc(complex_t value) // Sin(x)/x return std::sin(value)/value; } -inline complex_t MathFunctions::Laue(complex_t value, size_t N) // Exp(iNx/2)*Sin((N+1)x)/Sin(x) +inline complex_t MathFunctions::Laue(const complex_t &value, size_t N) // Exp(iNx/2)*Sin((N+1)x)/Sin(x) { if (N==0) { return complex_t(1.0, 0.0); diff --git a/Core/Tools/inc/OutputData.h b/Core/Tools/inc/OutputData.h index 3a3954882fc..a62bed77b89 100644 --- a/Core/Tools/inc/OutputData.h +++ b/Core/Tools/inc/OutputData.h @@ -15,7 +15,7 @@ //! @date 01.04.2012 #include "AxisDouble.h" -#include "Exceptions.h" +//#include "Exceptions.h" #include "Types.h" #include "LLData.h" #include "OutputDataIterator.h" diff --git a/Core/Tools/inc/ParameterPool.h b/Core/Tools/inc/ParameterPool.h index 573d1d03fc3..bc2ad45d7d2 100644 --- a/Core/Tools/inc/ParameterPool.h +++ b/Core/Tools/inc/ParameterPool.h @@ -38,10 +38,10 @@ public: virtual ~ParameterPool(); //! simple clone - ParameterPool *clone(); + ParameterPool *clone() const; //! clone with adding preffix to every parameter key - ParameterPool *cloneWithPrefix(const std::string &prefix); + ParameterPool *cloneWithPrefix(const std::string &prefix) const; //! copy parameters of given pool to the external pool while adding prefix to local parameter keys void copyToExternalPool(const std::string &prefix, ParameterPool *external_pool) const; diff --git a/Core/Tools/inc/ProgramOptions.h b/Core/Tools/inc/ProgramOptions.h index ff8df8ea6b1..9f350bc1993 100644 --- a/Core/Tools/inc/ProgramOptions.h +++ b/Core/Tools/inc/ProgramOptions.h @@ -52,10 +52,10 @@ public: const bpo::variable_value& operator[] (const std::string &s) const; //! return true if option with given name has been set - bool find(std::string name){ return (m_variables_map.count(name.c_str()) ? true : false); } + bool find(std::string name) const { return (m_variables_map.count(name.c_str()) ? true : false); } //! return true if options are consistent (no conflicting options, no --help request, config file is parsed) - bool isConsistent() { return m_options_is_consistent; } + bool isConsistent() const { return m_options_is_consistent; } //! parsing command line arguments void parseCommandLine(int argc, char **argv); diff --git a/Core/Tools/inc/StochasticGaussian.h b/Core/Tools/inc/StochasticGaussian.h index 7691ad8e6d6..f0ee8560941 100644 --- a/Core/Tools/inc/StochasticGaussian.h +++ b/Core/Tools/inc/StochasticGaussian.h @@ -27,7 +27,7 @@ public: virtual void setToRandom(); virtual double probabilityDensity(double value) const; - double getStdDev() { return m_std_dev; } + double getStdDev() const { return m_std_dev; } virtual double getFWHM() const { return 2.*m_std_dev*std::sqrt(2.*std::log(2)); } diff --git a/Core/Tools/inc/Types.h b/Core/Tools/inc/Types.h index e7686c8f386..8d4a9db7e27 100644 --- a/Core/Tools/inc/Types.h +++ b/Core/Tools/inc/Types.h @@ -14,7 +14,7 @@ //! @author Scientific Computing Group at FRM II //! @date 01.04.2012 -#include <complex> +//#include <complex> #include <vector> #include "BasicVector3D.h" #include "Exceptions.h" diff --git a/Core/Tools/inc/Utils.h b/Core/Tools/inc/Utils.h index da1e4cf0fae..221ea6b69d0 100644 --- a/Core/Tools/inc/Utils.h +++ b/Core/Tools/inc/Utils.h @@ -57,7 +57,7 @@ public: int &operator[](std::string name) { return m_nstringmap[name]; } //! get current string - std::string get_current() { return m_current_string; } + std::string get_current() const { return m_current_string; } private: std::string m_current_string; diff --git a/Core/Tools/src/FitSuite.cpp b/Core/Tools/src/FitSuite.cpp index 1fe006431c0..f5913009fd1 100644 --- a/Core/Tools/src/FitSuite.cpp +++ b/Core/Tools/src/FitSuite.cpp @@ -105,7 +105,7 @@ void FitSuite::minimize() /* ************************************************************************* */ // run fit /* ************************************************************************* */ -bool FitSuite::check_prerequisites() +bool FitSuite::check_prerequisites() const { if( !m_minimizer ) throw LogicErrorException("FitSuite::check_prerequisites() -> Error! No minimizer found."); if( !m_fit_objects.size() ) throw LogicErrorException("FitSuite::check_prerequisites() -> Error! No experiment defined"); diff --git a/Core/Tools/src/FitSuiteStrategy.cpp b/Core/Tools/src/FitSuiteStrategy.cpp index daf0944df35..013da2998fb 100644 --- a/Core/Tools/src/FitSuiteStrategy.cpp +++ b/Core/Tools/src/FitSuiteStrategy.cpp @@ -227,7 +227,7 @@ void FitSuiteStrategyBootstrap::execute() // generate noisy data -OutputData<double> *FitSuiteStrategyBootstrap::generateNoisyData(double noise_factor, const OutputData<double> &source) +OutputData<double> *FitSuiteStrategyBootstrap::generateNoisyData(double noise_factor, const OutputData<double> &source) const { OutputData<double> *p_result = source.clone(); OutputData<double>::iterator it = p_result->begin(); diff --git a/Core/Tools/src/ParameterPool.cpp b/Core/Tools/src/ParameterPool.cpp index 434cb9d19e4..4c34057a145 100644 --- a/Core/Tools/src/ParameterPool.cpp +++ b/Core/Tools/src/ParameterPool.cpp @@ -22,12 +22,25 @@ ParameterPool::ParameterPool(const ParameterPool &other) m_map = other.m_map; } -ParameterPool *ParameterPool::clone() +ParameterPool *ParameterPool::clone() const { ParameterPool *new_pool = new ParameterPool(*this); return new_pool; } +/* ************************************************************************* */ +// Clone method that adds a prefix to parameter's keys +/* ************************************************************************* */ +ParameterPool *ParameterPool::cloneWithPrefix(const std::string &prefix) const +{ + ParameterPool *new_pool = new ParameterPool; + for(parametermap_t::const_iterator it=m_map.begin(); it!= m_map.end(); ++it) + { + new_pool->addParameter(prefix+it->first, it->second); + } + return new_pool; +} + /* ************************************************************************* */ // Clear the parameter container /* ************************************************************************* */ @@ -58,19 +71,6 @@ bool ParameterPool::addParameter(const std::string &name, parameter_t par) return m_map.insert(parametermap_t::value_type(name, par ) ).second; } -/* ************************************************************************* */ -// Clone method that adds a prefix to parameter's keys -/* ************************************************************************* */ -ParameterPool *ParameterPool::cloneWithPrefix(const std::string &prefix) -{ - ParameterPool *new_pool = new ParameterPool; - for(parametermap_t::iterator it=m_map.begin(); it!= m_map.end(); ++it) - { - new_pool->addParameter(prefix+it->first, it->second); - } - return new_pool; -} - /* ************************************************************************* */ // copy parameters of given pool to the external pool while adding prefix to // local parameter keys -- GitLab