diff --git a/Base/Types/CloneableVector.h b/Base/Types/CloneableVector.h index 55f218111d1c6882db5992e56894b2441cc91353..7a284d60ddd40fa7cf9aaa5a6ead7deac336fc8a 100644 --- a/Base/Types/CloneableVector.h +++ b/Base/Types/CloneableVector.h @@ -37,14 +37,25 @@ template <class T> class CloneableVector : public std::vector<std::unique_ptr<T> public: CloneableVector() {} - CloneableVector(const CloneableVector& other) + CloneableVector(const CloneableVector& other) { copyOther(other); } + CloneableVector& operator=(const CloneableVector& other) + { + if (this != &other) { + super::clear(); + copyOther(other); + } + return *this; + } + void push_back(T* t) { super::emplace_back(std::unique_ptr<T>(t)); } + void emplace_back(std::unique_ptr<T>&& t) { super::emplace_back(t); } + +private: + void copyOther(const CloneableVector& other) { super::reserve(other.size()); for (const std::unique_ptr<T>& t : other) super::emplace_back(t->clone()); } - void push_back(T* t) { super::emplace_back(std::unique_ptr<T>(t)); } - void emplace_back(std::unique_ptr<T>&& t) { super::emplace_back(t); } }; #endif // BORNAGAIN_BASE_TYPES_CLONEABLEVECTOR_H diff --git a/Device/Data/OutputData.h b/Device/Data/OutputData.h index 7924913a22f79d43fd040d7ac543c00de2add798..ca6df60903b7146348d35c15d5c1f8d0d47060de 100644 --- a/Device/Data/OutputData.h +++ b/Device/Data/OutputData.h @@ -17,7 +17,7 @@ #include "Base/Axis/FixedBinAxis.h" #include "Base/Py/PyObject.h" -#include "Base/Types/SafePointerVector.h" +#include "Base/Types/CloneableVector.h" #include "Base/Utils/Assert.h" #include "Base/Utils/ThreadInfo.h" #include "Device/Data/LLData.h" @@ -228,7 +228,7 @@ private: //! checks if given axis name exists bool axisNameExists(const std::string& axis_name) const; - SafePointerVector<IAxis> m_value_axes; + CloneableVector<IAxis> m_value_axes; LLData<T>* m_ll_data; }; diff --git a/Device/ProDetector/DetectorMask.cpp b/Device/ProDetector/DetectorMask.cpp index 1965506e1ab00534fda1070c7e5209ed5ed29b96..e080f0c41fcace0e1bf3adbd4dd2edd3031289ef 100644 --- a/Device/ProDetector/DetectorMask.cpp +++ b/Device/ProDetector/DetectorMask.cpp @@ -97,7 +97,7 @@ const IShape2D* DetectorMask::getMaskShape(size_t mask_index, bool& mask_value) if (mask_index >= numberOfMasks()) return nullptr; mask_value = m_mask_of_shape[mask_index]; - return m_shapes[mask_index]; + return m_shapes[mask_index].get(); } void DetectorMask::process_masks() @@ -113,7 +113,7 @@ void DetectorMask::process_masks() // setting mask to the data starting from last shape added bool is_masked(false); for (size_t i_shape = m_shapes.size(); i_shape > 0; --i_shape) { - const IShape2D* shape = m_shapes[i_shape - 1]; + const IShape2D* shape = m_shapes[i_shape - 1].get(); if (shape->contains(binx, biny)) { if (m_mask_of_shape[i_shape - 1]) is_masked = true; diff --git a/Device/ProDetector/DetectorMask.h b/Device/ProDetector/DetectorMask.h index 0c944fcc9077a15d127f05d5c7964029491e132f..4e57dcfe6ea3a7398c3d3f616265f8a3b17be7df 100644 --- a/Device/ProDetector/DetectorMask.h +++ b/Device/ProDetector/DetectorMask.h @@ -61,7 +61,7 @@ public: private: void process_masks(); - SafePointerVector<IShape2D> m_shapes; + CloneableVector<IShape2D> m_shapes; std::vector<bool> m_mask_of_shape; OutputData<bool> m_mask_data; int m_number_of_masked_channels; diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i index 9d026badf75de98bbcf7fa515a54e5900971d935..61a466c17b4dcca5839a3ea788ad8ba68c8fbd48 100644 --- a/auto/Wrap/doxygenDevice.i +++ b/auto/Wrap/doxygenDevice.i @@ -2757,13 +2757,13 @@ Returns true if area defined by two bins is inside or on border of polygon (more // File: namespace_0d11.xml -// File: namespace_0d30.xml +// File: namespace_0d28.xml -// File: namespace_0d53.xml +// File: namespace_0d51.xml -// File: namespace_0d61.xml +// File: namespace_0d59.xml // File: namespace_0d90.xml @@ -3064,12 +3064,6 @@ make Swappable // File: RectangularDetector_8h.xml -// File: RegionOfInterest_8cpp.xml - - -// File: RegionOfInterest_8h.xml - - // File: SimpleUnitConverters_8cpp.xml @@ -3223,6 +3217,12 @@ make Swappable // File: DetectorMask_8h.xml +// File: RegionOfInterest_8cpp.xml + + +// File: RegionOfInterest_8h.xml + + // File: ConvolutionDetectorResolution_8cpp.xml