Skip to content
Snippets Groups Projects
Commit 33939ee8 authored by Bhuvan Bezawada's avatar Bhuvan Bezawada
Browse files

Made copy/move constructors private

re #23145
parent 61278c87
No related merge requests found
...@@ -51,12 +51,6 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> ...@@ -51,12 +51,6 @@ Code Documentation is available at: <http://doxygen.mantidproject.org>
class MANTID_GEOMETRY_DLL DetectorInfoItem { class MANTID_GEOMETRY_DLL DetectorInfoItem {
public: public:
// Provide copy and move constructors
DetectorInfoItem(const DetectorInfoItem &other) = default;
DetectorInfoItem &operator=(const DetectorInfoItem &rhs) = default;
DetectorInfoItem(DetectorInfoItem &&other) = default;
DetectorInfoItem &operator=(DetectorInfoItem &&rhs) = default;
// Methods that can be accessed via the iterator // Methods that can be accessed via the iterator
bool isMonitor() const { return m_detectorInfo->isMonitor(m_index); } bool isMonitor() const { return m_detectorInfo->isMonitor(m_index); }
...@@ -83,6 +77,12 @@ private: ...@@ -83,6 +77,12 @@ private:
DetectorInfoItem(const DetectorInfo &detectorInfo, const size_t index) DetectorInfoItem(const DetectorInfo &detectorInfo, const size_t index)
: m_detectorInfo(&detectorInfo), m_index(index) {} : m_detectorInfo(&detectorInfo), m_index(index) {}
// Provide copy and move constructors
DetectorInfoItem(const DetectorInfoItem &other) = default;
DetectorInfoItem &operator=(const DetectorInfoItem &rhs) = default;
DetectorInfoItem(DetectorInfoItem &&other) = default;
DetectorInfoItem &operator=(DetectorInfoItem &&rhs) = default;
// Non-owning pointer. A reference makes the class unable to define an // Non-owning pointer. A reference makes the class unable to define an
// assignment operator that we need. // assignment operator that we need.
const DetectorInfo *m_detectorInfo; const DetectorInfo *m_detectorInfo;
......
...@@ -55,20 +55,23 @@ class DetectorInfoPythonIterator { ...@@ -55,20 +55,23 @@ class DetectorInfoPythonIterator {
public: public:
explicit DetectorInfoPythonIterator(const DetectorInfo &detectorInfo) explicit DetectorInfoPythonIterator(const DetectorInfo &detectorInfo)
: m_begin(detectorInfo.begin()), m_end(detectorInfo.end()), : m_begin(detectorInfo.begin()), m_end(detectorInfo.end()),
m_current(*m_begin) {} m_firstOrDone(true) {}
const DetectorInfoItem &next() { const DetectorInfoItem &next() {
if (m_begin == m_end) { if (!m_firstOrDone) {
++m_begin;
} else {
m_firstOrDone = false;
objects::stop_iteration_error(); objects::stop_iteration_error();
} }
m_current = *m_begin++;
return m_current; return *m_begin;
} }
private: private:
DetectorInfoIterator m_begin; DetectorInfoIterator m_begin;
DetectorInfoIterator m_end; DetectorInfoIterator m_end;
DetectorInfoItem m_current; bool m_firstOrDone;
}; };
} // namespace Geometry } // namespace Geometry
......
...@@ -12,7 +12,7 @@ using namespace boost::python; ...@@ -12,7 +12,7 @@ using namespace boost::python;
void export_DetectorInfoItem() { void export_DetectorInfoItem() {
// Export to Python // Export to Python
class_<DetectorInfoItem>("DetectorInfoItem", no_init) class_<DetectorInfoItem, boost::noncopyable>("DetectorInfoItem", no_init)
.add_property("isMonitor", &DetectorInfoItem::isMonitor) .add_property("isMonitor", &DetectorInfoItem::isMonitor)
.add_property("isMasked", &DetectorInfoItem::isMasked) .add_property("isMasked", &DetectorInfoItem::isMasked)
.add_property("twoTheta", &DetectorInfoItem::twoTheta) .add_property("twoTheta", &DetectorInfoItem::twoTheta)
......
...@@ -22,5 +22,5 @@ void export_DetectorInfoPythonIterator() { ...@@ -22,5 +22,5 @@ void export_DetectorInfoPythonIterator() {
#endif #endif
, ,
&DetectorInfoPythonIterator::next, &DetectorInfoPythonIterator::next,
return_value_policy<copy_const_reference>()); return_value_policy<reference_existing_object>());
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment