diff --git a/Core/Algorithms/inc/DiffuseDWBASimulation.h b/Core/Algorithms/inc/DiffuseDWBASimulation.h index 1b62023288d1fb3542f1048f2d89d58b11356a6c..ff3c5fbfb94c0de116d85f66ebabdd5e123a2467 100644 --- a/Core/Algorithms/inc/DiffuseDWBASimulation.h +++ b/Core/Algorithms/inc/DiffuseDWBASimulation.h @@ -35,6 +35,7 @@ protected: double m_surface_density; SafePointerVector<DiffuseParticleInfo> m_np_infos; struct DiffuseFormFactorTerm { + DiffuseFormFactorTerm() : m_form_factors(), m_probabilities(), m_factor(0.0) { } ~DiffuseFormFactorTerm(); std::vector<IFormFactor *> m_form_factors; std::vector<double> m_probabilities; diff --git a/Core/Algorithms/inc/Mask.h b/Core/Algorithms/inc/Mask.h index 2075bea1be9c050ad34e9862bf065638ca79baba..acffc00babd8c105d198a98a292f3ad29f298830 100644 --- a/Core/Algorithms/inc/Mask.h +++ b/Core/Algorithms/inc/Mask.h @@ -16,13 +16,11 @@ #include "MaskCoordinateFunction.h" -//#include <cstddef> - //- ------------------------------------------------------------------- //! @class Mask //! @brief Definition of base class for masking OutputData elements //- ------------------------------------------------------------------- -class Mask +class Mask : public ICloneable { public: template <class TValue, class TContainer> friend class OutputDataIterator; diff --git a/Core/Algorithms/inc/MaskCoordinateFunction.h b/Core/Algorithms/inc/MaskCoordinateFunction.h index de3251fc1501c3d18d33ad698ddd2b7d02bb2e9c..d9a436cba1f634280fedb9d5c2e240392700e36b 100644 --- a/Core/Algorithms/inc/MaskCoordinateFunction.h +++ b/Core/Algorithms/inc/MaskCoordinateFunction.h @@ -15,8 +15,9 @@ //! @date Nov 20, 2012 #include <cstddef> +#include "ICloneable.h" -class MaskCoordinateFunction +class MaskCoordinateFunction : public ICloneable { public: MaskCoordinateFunction(size_t rank); diff --git a/Core/Algorithms/inc/MultiLayerDWBASimulation.h b/Core/Algorithms/inc/MultiLayerDWBASimulation.h index 8326ef942a9d2fec05f77aacdb33f4cb8353d729..95558587881185f5bd9a5abaa59291dc4f882b6d 100644 --- a/Core/Algorithms/inc/MultiLayerDWBASimulation.h +++ b/Core/Algorithms/inc/MultiLayerDWBASimulation.h @@ -16,6 +16,7 @@ #include "LayerDWBASimulation.h" +#include <set> #include <map> class MultiLayer; diff --git a/Core/Algorithms/src/Beam.cpp b/Core/Algorithms/src/Beam.cpp index fc8d8c3de43d8cb9932e7178e21b3e3a1c1e3c4f..02d3d2ecfa32fceda1a6cd9401119cd938453440 100644 --- a/Core/Algorithms/src/Beam.cpp +++ b/Core/Algorithms/src/Beam.cpp @@ -4,17 +4,15 @@ /* ************************************************************************* */ // c-tors, assignment operators, swap /* ************************************************************************* */ -Beam::Beam() : m_intensity(1.0) +Beam::Beam() : m_central_k(), m_intensity(1.0) { setName("Beam"); init_parameters(); } -Beam::Beam(const Beam &other) : IParameterized() +Beam::Beam(const Beam &other) : IParameterized(), m_central_k(other.m_central_k), m_intensity(other.m_intensity) { setName(other.getName()); - m_central_k = other.m_central_k; - m_intensity = other.m_intensity; init_parameters(); } diff --git a/Core/Algorithms/src/Detector.cpp b/Core/Algorithms/src/Detector.cpp index dba08b873fb86a4bf0ec8938eabfcf9a35c5ce6f..1d7ee25f11765e74eea286c5d16d740afd3518d3 100644 --- a/Core/Algorithms/src/Detector.cpp +++ b/Core/Algorithms/src/Detector.cpp @@ -7,7 +7,7 @@ // c-tors, assignment operators, swap /* ************************************************************************* */ Detector::Detector() -: mp_detector_resolution(0) +: m_axes(), mp_detector_resolution(0) { setName("Detector"); init_parameters(); @@ -15,10 +15,9 @@ Detector::Detector() Detector::Detector(const Detector &other) : IParameterized() -, mp_detector_resolution(0) +, m_axes(other.m_axes), mp_detector_resolution(0) { setName(other.getName()); - m_axes = other.m_axes; if(other.mp_detector_resolution) mp_detector_resolution = other.mp_detector_resolution->clone(); init_parameters(); } diff --git a/Core/Algorithms/src/Experiment.cpp b/Core/Algorithms/src/Experiment.cpp index c8d6e65fd0127f919b6fc1d1ead0e35e37e479f8..cb8015f0e22b109e12a945601bb37401c3ef59f4 100644 --- a/Core/Algorithms/src/Experiment.cpp +++ b/Core/Algorithms/src/Experiment.cpp @@ -1,64 +1,71 @@ #include "Experiment.h" + Experiment::Experiment() -: IParameterized("Experiment") -, mp_sample(0) -, mp_sample_builder(0) -, m_is_normalized(false) -, mp_options(0) + : IParameterized("Experiment") + , mp_sample(0) + , mp_sample_builder(0) + , m_detector() + , m_beam() + , m_intensity_map() + , m_is_normalized(false) + , mp_options(0) { //setName("Experiment"); init_parameters(); } -Experiment::Experiment(const Experiment &other) : IParameterized(other), ICloneable() +Experiment::Experiment(const Experiment &other) + : IParameterized(other), ICloneable() , mp_sample(0) - , mp_sample_builder(0) - , m_is_normalized(false) - , mp_options(0) + , mp_sample_builder(other.mp_sample_builder) + , m_detector(other.m_detector) + , m_beam(other.m_beam) + , m_intensity_map() + , m_is_normalized(other.m_is_normalized) + , mp_options(other.mp_options) { if(other.mp_sample) mp_sample = other.mp_sample->clone(); - mp_sample_builder = other.mp_sample_builder; // sample builder owned by the user - m_detector = other.m_detector; - m_beam = other.m_beam; - m_intensity_map.copyFrom(other.m_intensity_map); - m_is_normalized = other.m_is_normalized; - mp_options = other.mp_options; // program options are owned by the user init_parameters(); } - Experiment::Experiment(const ProgramOptions *p_options) -: IParameterized("Experiment") -, mp_sample(0) -, mp_sample_builder(0) -, m_is_normalized(false) -, mp_options(p_options) + : IParameterized("Experiment") + , mp_sample(0) + , mp_sample_builder(0) + , m_detector() + , m_beam() + , m_intensity_map() + , m_is_normalized(false) + , mp_options(p_options) { -// setName("Experiment"); init_parameters(); } Experiment::Experiment(const ISample &p_sample, const ProgramOptions *p_options) -: IParameterized("Experiment") -, mp_sample(p_sample.clone()) -, mp_sample_builder(0) -, m_is_normalized(false) -, mp_options(p_options) + : IParameterized("Experiment") + , mp_sample(p_sample.clone()) + , mp_sample_builder(0) + , m_detector() + , m_beam() + , m_intensity_map() + , m_is_normalized(false) + , mp_options(p_options) { -// setName("Experiment"); init_parameters(); } Experiment::Experiment(const ISampleBuilder* p_sample_builder, const ProgramOptions *p_options) -: IParameterized("Experiment") -, mp_sample(0) -, mp_sample_builder(p_sample_builder) -, m_is_normalized(false) -, mp_options(p_options) + : IParameterized("Experiment") + , mp_sample(0) + , mp_sample_builder(p_sample_builder) + , m_detector() + , m_beam() + , m_intensity_map() + , m_is_normalized(false) + , mp_options(p_options) { - //setName("Experiment"); init_parameters(); } diff --git a/Core/Algorithms/src/IChiSquaredModule.cpp b/Core/Algorithms/src/IChiSquaredModule.cpp index 112d3db7e5a9b177e3b52406c7f5a21058175fc0..635d3a92a4e2ad6e0a2aba925e75050d8cda1c42 100644 --- a/Core/Algorithms/src/IChiSquaredModule.cpp +++ b/Core/Algorithms/src/IChiSquaredModule.cpp @@ -18,7 +18,8 @@ IChiSquaredModule::IChiSquaredModule() IChiSquaredModule::IChiSquaredModule(const IChiSquaredModule &other) - : mp_real_data(0) + : ICloneable() + , mp_real_data(0) , mp_simulation_data(0) , mp_weights(0) , mp_squared_function(0) diff --git a/Core/Core.pro b/Core/Core.pro index c9f283ed50ed4d8803b7848f33cf9b367dc74a7e..143d54dbc96b588bac84eab2291706fd554fec61 100644 --- a/Core/Core.pro +++ b/Core/Core.pro @@ -104,6 +104,7 @@ SOURCES += \ Tools/src/FitParameter.cpp \ Tools/src/FitParameterLinked.cpp \ Tools/src/FitSuite.cpp \ + Tools/src/FitSuiteFunctions.cpp \ Tools/src/FitSuiteObjects.cpp \ Tools/src/FitSuiteParameters.cpp \ Tools/src/FitSuiteStrategy.cpp \ @@ -123,8 +124,7 @@ SOURCES += \ Tools/src/StochasticGaussian.cpp \ Tools/src/StochasticSampledParameter.cpp \ Tools/src/Types.cpp \ - Tools/src/Utils.cpp \ - Tools/src/FitSuiteFunctions.cpp + Tools/src/Utils.cpp HEADERS += \ Algorithms/inc/Beam.h \ @@ -237,6 +237,7 @@ HEADERS += \ Tools/inc/Bin.h \ Tools/inc/Convolve.h \ Tools/inc/Coordinate3D.h \ + Tools/inc/CoreOptionsDescription.h \ Tools/inc/DoubleToComplexInterpolatingFunction.h \ Tools/inc/DoubleToComplexMap.h \ Tools/inc/Exceptions.h \ @@ -244,11 +245,13 @@ HEADERS += \ Tools/inc/FitParameter.h \ Tools/inc/FitParameterLinked.h \ Tools/inc/FitSuite.h \ + Tools/inc/FitSuiteFunctions.h \ Tools/inc/FitSuiteObjects.h \ Tools/inc/FitSuiteParameters.h \ Tools/inc/FitSuiteStrategy.h \ Tools/inc/IAxis.h \ Tools/inc/IChangeable.h \ + Tools/inc/ICloneable.h \ Tools/inc/IDoubleToComplexFunction.h \ Tools/inc/IFactory.h \ Tools/inc/IMinimizer.h \ @@ -271,16 +274,15 @@ HEADERS += \ Tools/inc/ParameterPool.h \ Tools/inc/ProgramOptions.h \ Tools/inc/RealParameterWrapper.h \ - Tools/inc/TRange.h \ + Tools/inc/SafePointerVector.h \ Tools/inc/StochasticDiracDelta.h \ Tools/inc/StochasticGaussian.h \ Tools/inc/StochasticSampledParameter.h \ + Tools/inc/TRange.h \ Tools/inc/Types.h \ Tools/inc/Units.h \ Tools/inc/Utils.h \ - Tools/inc/CoreOptionsDescription.h \ - Tools/inc/FitSuiteFunctions.h \ - Tools/inc/ICloneable.h + Tools/inc/FastVector.h INCLUDEPATH += ./Algorithms/inc ./FormFactors/inc ./Geometry/inc ./Samples/inc ./Tools/inc DEPENDPATH += ./Algorithms/inc ./FormFactors/inc ./Geometry/inc ./Samples/inc ./Tools/inc diff --git a/Core/Geometry/src/Transform3D.cpp b/Core/Geometry/src/Transform3D.cpp index 8bfac1e5ce681004676661296d7ab09397b26939..7411252c59d85b216d84d0524f75a06f96716e4f 100755 --- a/Core/Geometry/src/Transform3D.cpp +++ b/Core/Geometry/src/Transform3D.cpp @@ -71,6 +71,9 @@ namespace Geometry { const Point3D<double> & to0, const Point3D<double> & to1, const Point3D<double> & to2) + : xx_(1), xy_(0), xz_(0), dx_(0), + yx_(0), yy_(1), yz_(0), dy_(0), + zx_(0), zy_(0), zz_(1), dz_(0) /*********************************************************************** * * * Name: Transform3D::Transform3D Date: 24.09.96 * diff --git a/Core/Samples/inc/Lattice.h b/Core/Samples/inc/Lattice.h index 5420d818681935359553a10ed3c503fd73c52d03..58c8ed915ea9d36a6012f48590bd1b872e78e9b9 100644 --- a/Core/Samples/inc/Lattice.h +++ b/Core/Samples/inc/Lattice.h @@ -18,6 +18,7 @@ #include "Coordinate3D.h" #include "ISelectionRule.h" #include "TRange.h" +#include "FastVector.h" #include <vector> diff --git a/Core/Tools/inc/Bin.h b/Core/Tools/inc/Bin.h index c492f011c54002a7578bc6eab855a9202c137797..a2a0e5bbaf8aad9f707b9810a74494eca91b6ff6 100644 --- a/Core/Tools/inc/Bin.h +++ b/Core/Tools/inc/Bin.h @@ -36,14 +36,14 @@ struct Bin1D //- ------------------------------------------------------------------- struct Bin1DCVector { - Bin1DCVector() {} + Bin1DCVector() : m_q_lower(), m_q_upper() {} Bin1DCVector(const cvector_t &lower, const cvector_t &upper) : m_q_lower(lower), m_q_upper(upper) {} Bin1DCVector(double wavelength, const Bin1D &alpha_bin, const Bin1D &phi_bin); - cvector_t m_q_lower; //!< lower bound of the bin - cvector_t m_q_upper; //!< upper bound of the bin cvector_t getMidPoint() const { return (m_q_lower + m_q_upper)/2.0; } cvector_t getDelta() const { return m_q_upper - m_q_lower; } + cvector_t m_q_lower; //!< lower bound of the bin + cvector_t m_q_upper; //!< upper bound of the bin }; //! equality operator for bins @@ -60,7 +60,7 @@ inline bool operator!=(const Bin1D &left, const Bin1D &right) { } //! creation on Bin1DCVector from alpha and phi bins -inline Bin1DCVector::Bin1DCVector(double wavelength, const Bin1D &alpha_bin, const Bin1D &phi_bin) +inline Bin1DCVector::Bin1DCVector(double wavelength, const Bin1D &alpha_bin, const Bin1D &phi_bin) : m_q_lower(), m_q_upper() { m_q_lower.setLambdaAlphaPhi(wavelength, alpha_bin.m_lower, phi_bin.m_lower); m_q_upper.setLambdaAlphaPhi(wavelength, alpha_bin.m_upper, phi_bin.m_upper); diff --git a/Core/Tools/inc/DoubleToComplexMap.h b/Core/Tools/inc/DoubleToComplexMap.h index f77f645b32c0e4e715d7913d3cb2d3105a8faa6f..37329e00dd9585876766a7701f6c417c8f7f40bc 100644 --- a/Core/Tools/inc/DoubleToComplexMap.h +++ b/Core/Tools/inc/DoubleToComplexMap.h @@ -1,8 +1,9 @@ #ifndef DOUBLETOCOMPLEXUNORDEREDMAP_H #define DOUBLETOCOMPLEXUNORDEREDMAP_H -#include "Exceptions.h" -#include "Types.h" +//#include "Exceptions.h" +//#include "Types.h" +#include "Utils.h" #include "IDoubleToComplexFunction.h" @@ -14,7 +15,7 @@ class DoubleToComplexMap : public IDoubleToComplexMap { public: - typedef UnorderedMap<double, complex_t> container_t; + typedef Utils::UnorderedMap<double, complex_t> container_t; DoubleToComplexMap(){} DoubleToComplexMap(const container_t &value_map) : m_value_map(value_map) {} @@ -34,7 +35,7 @@ private: class DoubleToPairOfComplexMap : public IDoubleToPairOfComplexMap { public: - typedef UnorderedMap<double, complexpair_t> container_t; + typedef Utils::UnorderedMap<double, complexpair_t> container_t; DoubleToPairOfComplexMap(){} DoubleToPairOfComplexMap(const container_t &value_map) : m_value_map(value_map) {} diff --git a/Core/Tools/inc/FastVector.h b/Core/Tools/inc/FastVector.h new file mode 100644 index 0000000000000000000000000000000000000000..403fa674e8517d8bbc7605cc1b56905d486e1092 --- /dev/null +++ b/Core/Tools/inc/FastVector.h @@ -0,0 +1,54 @@ +#ifndef FASTVECTOR_H +#define FASTVECTOR_H + + +#include "Types.h" +#include <iostream> + +/* ************************************************************************* */ +// container for holding kvectors with optimised location/deallocation +/* ************************************************************************* */ +class KVectorContainer { +public: + typedef std::vector<kvector_t > container_t; + typedef container_t::const_iterator const_iterator; + KVectorContainer(int buff_size = 3) : m_current_position(0), m_max_buff_size(buff_size), m_buffer() + { + m_buffer.reserve(m_max_buff_size); + for(size_t i=0; i<m_max_buff_size; ++i) m_buffer.push_back(kvector_t(0.0, 0.0, 0.0)); + } + + inline void push_back(const kvector_t &k) { + if(m_current_position == m_max_buff_size) { + std::cout << "KVectorContainer::push_back() -> Info. Increasing size of the buffer from " << m_max_buff_size; + m_max_buff_size *=2; + std::cout << " to " << m_max_buff_size << std::endl; + m_buffer.resize(m_max_buff_size); + } + m_buffer[m_current_position][0] = k[0]; + m_buffer[m_current_position][1] = k[1]; + m_buffer[m_current_position][2] = k[2]; + m_current_position++; + } + + inline void clear() { m_current_position = 0; } + + inline size_t size() { return m_current_position; } + + void print() { + for(size_t i=0; i<m_max_buff_size; ++i) std::cout << i << " " << m_buffer[i] << std::endl; + std::cout << "size:" << size() << std::endl; + } + + const_iterator begin() const { return m_buffer.begin(); } + const_iterator end() const { return m_buffer.begin()+m_current_position; } + + +private: + size_t m_current_position; + size_t m_max_buff_size; + container_t m_buffer; +}; + + +#endif // FASTVECTOR_H diff --git a/Core/Tools/inc/FitSuiteFunctions.h b/Core/Tools/inc/FitSuiteFunctions.h index a16b3cbeff6892a0bdd05bed96ec50ee77bb7637..5e7baa411311bc0f450307281633e736c96e44e9 100644 --- a/Core/Tools/inc/FitSuiteFunctions.h +++ b/Core/Tools/inc/FitSuiteFunctions.h @@ -16,6 +16,8 @@ #include <vector> +#include <cstddef> +using std::size_t; class FitSuite; diff --git a/Core/Tools/inc/INamed.h b/Core/Tools/inc/INamed.h index 9d7f036693a0e04d18f40bfd384a422ca4ee30ad..e3fd929577149013e484a7afa0603379cf9bb56d 100644 --- a/Core/Tools/inc/INamed.h +++ b/Core/Tools/inc/INamed.h @@ -24,8 +24,8 @@ class INamed { public: - INamed() {} - INamed(const std::string &name) : m_name(name) { } + INamed() : m_name(), m_title() {} + INamed(const std::string &name) : m_name(name), m_title() { } INamed(const std::string &name, const std::string &title) : m_name(name), m_title(title) { } virtual ~INamed(){} diff --git a/Core/Tools/inc/IParameterized.h b/Core/Tools/inc/IParameterized.h index d40c999820e01cd7bc800ce297940bc2d8a94ccd..4cdead755cb7935b632ad835749e3cd057c635fb 100644 --- a/Core/Tools/inc/IParameterized.h +++ b/Core/Tools/inc/IParameterized.h @@ -23,7 +23,7 @@ class IParameterized : public INamed { public: IParameterized(); - IParameterized(const std::string &name) : INamed(name){} + IParameterized(const std::string &name); IParameterized(const IParameterized &other); IParameterized &operator=(const IParameterized &other); virtual ~IParameterized() {} diff --git a/Core/Tools/inc/LLData.h b/Core/Tools/inc/LLData.h index 592c53b9f61304c9758feb11cf1fe188b5c22d64..7835240236c9259c90d75e616ff76fc6340b39d3 100644 --- a/Core/Tools/inc/LLData.h +++ b/Core/Tools/inc/LLData.h @@ -67,10 +67,10 @@ private: }; // Global helper functions for arithmetic -template <class T> LLData<T> &operator+(const LLData<T> &left, const LLData<T> &right); -template <class T> LLData<T> &operator-(const LLData<T> &left, const LLData<T> &right); -template <class T> LLData<T> &operator*(const LLData<T> &left, const LLData<T> &right); -template <class T> LLData<T> &operator/(const LLData<T> &left, const LLData<T> &right); +template <class T> LLData<T> operator+(const LLData<T> &left, const LLData<T> &right); +template <class T> LLData<T> operator-(const LLData<T> &left, const LLData<T> &right); +template <class T> LLData<T> operator*(const LLData<T> &left, const LLData<T> &right); +template <class T> LLData<T> operator/(const LLData<T> &left, const LLData<T> &right); // Global helper functions for comparison template <class T> bool HaveSameDimensions(const LLData<T> &left, const LLData<T> &right); @@ -276,28 +276,28 @@ template<class T> void LLData<T>::swapContents(LLData<T> &other) std::swap(this->m_data_array, other.m_data_array); } -template<class T> LLData<T> &operator+(const LLData<T>& left, const LLData<T>& right) +template<class T> LLData<T> operator+(const LLData<T>& left, const LLData<T>& right) { LLData<T> *p_result = new LLData<T>(left); (*p_result) += right; return *p_result; } -template<class T> LLData<T> &operator-(const LLData<T>& left, const LLData<T>& right) +template<class T> LLData<T> operator-(const LLData<T>& left, const LLData<T>& right) { LLData<T> *p_result = new LLData<T>(left); (*p_result) -= right; return *p_result; } -template<class T> LLData<T> &operator*(const LLData<T>& left, const LLData<T>& right) +template<class T> LLData<T> operator*(const LLData<T>& left, const LLData<T>& right) { LLData<T> *p_result = new LLData<T>(left); (*p_result) *= right; return *p_result; } -template<class T> LLData<T> &operator/(const LLData<T>& left, const LLData<T>& right) +template<class T> LLData<T> operator/(const LLData<T>& left, const LLData<T>& right) { LLData<T> *p_result = new LLData<T>(left); (*p_result) /= right; diff --git a/Core/Tools/inc/OutputData.h b/Core/Tools/inc/OutputData.h index a62bed77b8975aaaacc40e442972c2e6717b8690..7b33ddc78ecaec372863556fb664e5e70e3e4fa0 100644 --- a/Core/Tools/inc/OutputData.h +++ b/Core/Tools/inc/OutputData.h @@ -214,7 +214,8 @@ private: /* ***************************************************************************/ template <class T> OutputData<T>::OutputData() -: mp_ll_data(0) +: m_value_axes() +, mp_ll_data(0) , mp_mask(0) { allocate(); diff --git a/Core/Tools/inc/ParameterPool.h b/Core/Tools/inc/ParameterPool.h index a94d3a4aa9457a3f4b379f7bdfe3f0bdeba74b6d..7c04f9eabc2a8cc7c258d65f47b854161075e2b1 100644 --- a/Core/Tools/inc/ParameterPool.h +++ b/Core/Tools/inc/ParameterPool.h @@ -31,7 +31,7 @@ public: typedef RealParameterWrapper parameter_t; typedef std::map<std::string, parameter_t > parametermap_t; - ParameterPool() {} + ParameterPool() : m_map() {} virtual ~ParameterPool() {} //! simple clone diff --git a/Core/Tools/inc/RealParameterWrapper.h b/Core/Tools/inc/RealParameterWrapper.h index 5ef4fd3d8c27ea2470bd2c8ff6463dabe6514f3c..8ed171c9c3d0468ed78920e4f0a996ed977d4040 100644 --- a/Core/Tools/inc/RealParameterWrapper.h +++ b/Core/Tools/inc/RealParameterWrapper.h @@ -28,7 +28,7 @@ public: //! type of the signal parameter can emmit typedef boost::signal<void ()> signal_t; - explicit RealParameterWrapper(double *par) : m_data(par) {} + explicit RealParameterWrapper(double *par) : m_data(par), m_signal() {} RealParameterWrapper(const RealParameterWrapper &other ); RealParameterWrapper &operator=(const RealParameterWrapper &other); ~RealParameterWrapper(){} diff --git a/Core/Tools/inc/SafePointerVector.h b/Core/Tools/inc/SafePointerVector.h index ac6fc21ed96980d3a22f85f0e43754badbfe2aa9..6ae4143d39bacacc4db0be9ffa7d092393b7b8d3 100644 --- a/Core/Tools/inc/SafePointerVector.h +++ b/Core/Tools/inc/SafePointerVector.h @@ -51,7 +51,7 @@ private: std::vector<T *> m_pointers; }; -template<class T> SafePointerVector<T>::SafePointerVector() +template<class T> SafePointerVector<T>::SafePointerVector() : m_pointers() { } diff --git a/Core/Tools/inc/TRange.h b/Core/Tools/inc/TRange.h index 6ab79366235bcc54a1ca13cb2f9acadf43188191..f6a6397a1e9b8ec17f5f222b5fa1e01adc06f77c 100644 --- a/Core/Tools/inc/TRange.h +++ b/Core/Tools/inc/TRange.h @@ -18,6 +18,7 @@ template <class T> class TRange { public: TRange(T min, T max) : m_min(min), m_max(max) {} + virtual ~TRange(){} T getMin() const { return m_min; } T getMax() const { return m_max; } diff --git a/Core/Tools/inc/Types.h b/Core/Tools/inc/Types.h index 8d4a9db7e27b8b94fa44c102bd56577116508b66..6f290738093dd8554094fd315917dc8df900a013 100644 --- a/Core/Tools/inc/Types.h +++ b/Core/Tools/inc/Types.h @@ -14,12 +14,10 @@ //! @author Scientific Computing Group at FRM II //! @date 01.04.2012 -//#include <complex> +#include <cstddef> #include <vector> #include "BasicVector3D.h" -#include "Exceptions.h" -#include <boost/unordered_map.hpp> - +using std::size_t; typedef std::complex<double > complex_t; typedef Geometry::BasicVector3D<double> kvector_t; @@ -29,244 +27,4 @@ typedef std::vector<vdouble1d_t > vdouble2d_t; typedef std::pair<complex_t, complex_t > complexpair_t; -/* ************************************************************************* */ -// container for holding kvectors with optimised location/deallocation -/* ************************************************************************* */ -class KVectorContainer { -public: - typedef std::vector<kvector_t > container_t; - typedef container_t::const_iterator const_iterator; - KVectorContainer(int buff_size = 3) : m_current_position(0), m_max_buff_size(buff_size) - { - m_buffer.reserve(m_max_buff_size); - for(size_t i=0; i<m_max_buff_size; ++i) m_buffer.push_back(kvector_t(0.0, 0.0, 0.0)); - } - - inline void push_back(const kvector_t &k) { - if(m_current_position == m_max_buff_size) { - std::cout << "KVectorContainer::push_back() -> Info. Increasing size of the buffer from " << m_max_buff_size; - m_max_buff_size *=2; - std::cout << " to " << m_max_buff_size << std::endl; - m_buffer.resize(m_max_buff_size); - } - m_buffer[m_current_position][0] = k[0]; - m_buffer[m_current_position][1] = k[1]; - m_buffer[m_current_position][2] = k[2]; - m_current_position++; - } - - inline void clear() { m_current_position = 0; } - - inline size_t size() { return m_current_position; } - - void print() { - for(size_t i=0; i<m_max_buff_size; ++i) std::cout << i << " " << m_buffer[i] << std::endl; - std::cout << "size:" << size() << std::endl; - } - - const_iterator begin() const { return m_buffer.begin(); } - const_iterator end() const { return m_buffer.begin()+m_current_position; } - - -private: - size_t m_current_position; - size_t m_max_buff_size; - container_t m_buffer; -}; - - -/* ************************************************************************* */ -// unordered map of values -/* ************************************************************************* */ -template<class Key, class Object > -class UnorderedMap -{ -public: - typedef boost::unordered_map<Key, Object > container_t; - typedef typename container_t::iterator iterator; - typedef typename container_t::const_iterator const_iterator; - - UnorderedMap() {} - virtual ~UnorderedMap(){} - - //UnorderedMap *clone() { return new UnorderedMap(m_value_map); } - - const_iterator begin() { return m_value_map.begin(); } - const_iterator end() { return m_value_map.end(); } - const Object &find(const Key &key) const - { - const_iterator pos = m_value_map.find(key); - if(pos != m_value_map.end() ) { - return (*pos).second; - } else { - throw RuntimeErrorException("UnorderedMap::find() -> Error! Can't find the object"); - } - } - - size_t size() { return m_value_map.size(); } - Object & operator[] (const Key &key) { return m_value_map[key]; } - -private: - UnorderedMap &operator=(const UnorderedMap &); - - container_t m_value_map; -}; - - -//// we need forward declaration here to be able to redefine ostream as friend -//template<typename T> class KVector; -//template<typename T> std::ostream& operator<< (std::ostream& o, const KVector<T>& ); - -//template<typename T> -//class KVector { -//public: -// KVector() : m_x(0), m_y(0), m_z(0) {} -// KVector(T x, T y, T z) : m_x(x), m_y(y), m_z(z) {} -// void setMagThetaPhi(T mag, T theta, T phi) -// { -// T amag = std::abs(mag); -// m_x = amag * std::sin(theta) * std::cos(phi); -// m_y = amag * std::sin(theta) * std::sin(phi); -// m_z = amag * std::cos(theta); -// // m_mag2 = m_x*m_x + m_y*m_y + m_z*m_z; -// } - -// void setXYZ(T x, T y, T z) { m_x = x; m_y = y; m_z = z; } - -// void setLambdaAlphaPhi(T lambda, T alpha, T phi) -// { -// T k = 2.*M_PI/lambda; -// m_x = k*std::cos(alpha) * std::cos(phi); -// m_y = k*std::cos(alpha) * std::sin(phi); -// m_z = k*std::sin(alpha); -// // m_mag2 = m_x*m_x + m_y*m_y + m_z*m_z; -// } -// inline T x() const { return m_x; } -// inline T y() const { return m_y; } -// inline T z() const { return m_z; } -// inline T mag() const { return std::sqrt(mag2()); } -// inline T mag2() const { return m_x*m_x+m_y*m_y+m_z*m_z; } -// inline T magxy() const { return std::sqrt(m_x*m_x+m_y*m_y); } - -// KVector<T> &operator=(const KVector<T> &other); -// KVector<T> &operator+=(const KVector<T> &other); -// KVector<T> &operator-=(const KVector<T> &other); -// friend std::ostream &operator<< <> (std::ostream &ostr, KVector<T> const &k); - -// static KVector<T> LambdaAlphaPhi(T lambda, T alpha, T phi) -// { -// KVector<T> k; k.setLambdaAlphaPhi(lambda, alpha, phi); -// return k; -// } - -//private: -// T m_x; -// T m_y; -// T m_z; -// // T m_mag2; -//}; - -//template<typename T> KVector<T> operator+(const KVector<T> &a, const KVector<T> &b); -//template<typename T> KVector<T> operator-(const KVector<T> &a, const KVector<T> &b); - - -//template<typename T> KVector<T> operator+(const KVector<T> &a, const KVector<T> &b) -//{ -// KVector<T> target = a; -// target += b; -// return target; -//} - -//template<typename T> KVector<T> operator-(const KVector<T> &a, const KVector<T> &b) -//{ -// KVector<T> target = a; -// target -= b; -// return target; -//} - - - - -//typedef KVector<double> kvector_t; - -//#include "Point3D.h" -//#include "BasicVector3D.h" -//#include "Vector3D.h" -//#include "Transform3D.h" - -//typedef Geometry::Point3D<double > point3d_t; -//typedef Geometry::BasicVector3D<double > basicvector3d_t; -//typedef Geometry::Vector3D<double > vector3d_t; - - -////typedef KVector<complex_t> complex_vector_t; -//// -////inline complex_vector_t getComplexVector(kvector_t real_vector) -////{ -//// return complex_vector_t(complex_t(real_vector.x()), -//// complex_t(real_vector.y()), complex_t(real_vector.z())); -////} - -//inline kvector_t CrossProduct(const kvector_t vectorLeft, const kvector_t vectorRight) -//{ -// double x = vectorLeft.y()*vectorRight.z() - vectorLeft.z()*vectorRight.y(); -// double y = vectorLeft.z()*vectorRight.x() - vectorLeft.x()*vectorRight.z(); -// double z = vectorLeft.x()*vectorRight.y() - vectorLeft.y()*vectorRight.x(); -// return kvector_t(x, y, z); -//} - -//inline double DotProduct(const kvector_t left, const kvector_t right) -//{ -// return left.x()*right.x() + left.y()*right.y() + left.z()*right.z(); -//} - -//inline kvector_t operator*(double scalar, kvector_t vector) -//{ -// double x = scalar*vector.x(); -// double y = scalar*vector.y(); -// double z = scalar*vector.z(); -// return kvector_t(x, y, z); -//} - -//inline kvector_t -//operator+(const kvector_t & v) { return v; } - -//inline kvector_t -//operator+(const kvector_t & a,const kvector_t & b) { -// return kvector_t(a.x()+b.x(), a.y()+b.y(), a.z()+b.z()); -//} - -//inline kvector_t -//operator-(const kvector_t & v) { -// return kvector_t(-v.x(), -v.y(), -v.z()); -//} - -//inline kvector_t -//operator-(const kvector_t & a,const kvector_t & b) { -// return kvector_t(a.x()-b.x(), a.y()-b.y(), a.z()-b.z()); -//} - -////inline kvector_t -////operator*(const kvector_t & v, double a) { -//// return kvector_t(v.x()*a, v.y()*a, v.z()*a); -////} - -//inline double -//operator*(const kvector_t & a,const kvector_t & b) { -// return DotProduct(a,b); -//} - -////inline kvector_t -////operator*(double a, const kvector_t & v) { -//// return kvector_t(a*v.x(), a*v.y(), a*v.z()); -////} - -////inline kvector_t -////operator/(const kvector_t & v, double a) { -//// return kvector_t(v.x()/a, v.y()/a, v.z()/a); -////} - - - - #endif // TYPES_H diff --git a/Core/Tools/inc/Utils.h b/Core/Tools/inc/Utils.h index 221ea6b69d02fe6dce92e39e8474a86c74a8fc20..82686a59387c976dfcf8b2f5adb74357dedd609c 100644 --- a/Core/Tools/inc/Utils.h +++ b/Core/Tools/inc/Utils.h @@ -19,7 +19,8 @@ #include <map> #include <iostream> #include <sstream> - +#include "Exceptions.h" +#include <boost/unordered_map.hpp> namespace Utils { @@ -110,6 +111,44 @@ inline std::string AdjustStringLength(std::string name, int length) } +/* ************************************************************************* */ +// unordered map of values +/* ************************************************************************* */ +template<class Key, class Object > +class UnorderedMap +{ +public: + typedef boost::unordered_map<Key, Object > container_t; + typedef typename container_t::iterator iterator; + typedef typename container_t::const_iterator const_iterator; + + UnorderedMap() {} + virtual ~UnorderedMap(){} + + //UnorderedMap *clone() { return new UnorderedMap(m_value_map); } + + const_iterator begin() { return m_value_map.begin(); } + const_iterator end() { return m_value_map.end(); } + const Object &find(const Key &key) const + { + const_iterator pos = m_value_map.find(key); + if(pos != m_value_map.end() ) { + return (*pos).second; + } else { + throw RuntimeErrorException("UnorderedMap::find() -> Error! Can't find the object"); + } + } + + size_t size() { return m_value_map.size(); } + Object & operator[] (const Key &key) { return m_value_map[key]; } + +private: + UnorderedMap &operator=(const UnorderedMap &); + + container_t m_value_map; +}; + + } diff --git a/Core/Tools/src/AxisDouble.cpp b/Core/Tools/src/AxisDouble.cpp index e9cc93c80702776b2b15269bf1b2e9ca650adc21..95bded963ea1e995e22ea1016aafb6f62f888f4c 100644 --- a/Core/Tools/src/AxisDouble.cpp +++ b/Core/Tools/src/AxisDouble.cpp @@ -3,7 +3,7 @@ #include "Numeric.h" #include "Exceptions.h" -//#include <algorithm> +#include <algorithm> AxisDouble::AxisDouble(std::string name) : IAxis(name) diff --git a/Core/Tools/src/IParameterized.cpp b/Core/Tools/src/IParameterized.cpp index bdc3db3681d6f9f54be72964cc365763aa863ffd..3a6cc5229649f2bdd3c953917385bb6b1f2d6f34 100644 --- a/Core/Tools/src/IParameterized.cpp +++ b/Core/Tools/src/IParameterized.cpp @@ -1,27 +1,28 @@ #include "IParameterized.h" #include "Utils.h" -IParameterized::IParameterized() -{ -} /* ************************************************************************* */ -// copy constructor -// we are consciously not copying parameter pool, it should be done in derived class +// c-tors /* ************************************************************************* */ -IParameterized::IParameterized(const IParameterized &other) : INamed(other) +IParameterized::IParameterized() : m_parameters(), m_status() +{ +} + +IParameterized::IParameterized(const std::string &name) : INamed(name), m_parameters(), m_status() +{ +} + +IParameterized::IParameterized(const IParameterized &other) : INamed(other), m_parameters(), m_status() { } -/* ************************************************************************* */ -// assignment operator -// we are consciously not copying parameter pool, it should be done in derived class -/* ************************************************************************* */ IParameterized &IParameterized::operator=(const IParameterized &other) { if( this != &other) { INamed::operator=(other); + // parameters are not copied } return *this; } diff --git a/shared.pri b/shared.pri index aff348993cbe198e7f2459cff75f64eafd8e4073..fe1e0038494364496722b4e5577ce0507194303d 100644 --- a/shared.pri +++ b/shared.pri @@ -116,7 +116,7 @@ CONFIG(GPERFTOOLS) { LIBS += -L/opt/local/lib -lprofiler -ltcmalloc } -CONFIG+=PEDANTIC +#CONFIG+=PEDANTIC CONFIG(PEDANTIC) { QMAKE_CXXFLAGS_RELEASE += -Weffc++ QMAKE_CXXFLAGS_DEBUG += -Weffc++