Commit fb06466b authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Pass boost::optional by value

parent bede0de5
......@@ -423,7 +423,7 @@ void PredictPeaks::calculateQAndAddToOutput(const V3D &hkl,
V3D q = orientedUB * hkl * (2.0 * M_PI * m_qConventionFactor);
// Create the peak using the Q in the lab framewith all its info:
Peak p(m_inst, q, boost::optional<double>());
Peak p(m_inst, q);
/* The constructor calls setQLabFrame, which already calls findDetector, which
is expensive. It's not necessary to call it again, instead it's enough to
......
......@@ -119,9 +119,9 @@ public:
for (int i = 0; i < m_masterPeaks->getNumberPeaks(); i++) {
IPeak &peak = m_masterPeaks->getPeak(i);
Mantid::Kernel::V3D v(1, 0, 0);
peak.setQSampleFrame(v, boost::optional<double>()); // Overwrite all Q
// samples to be
// co-linear.
peak.setQSampleFrame(v); // Overwrite all Q
// samples to be
// co-linear.
}
TS_ASSERT_THROWS(doTest(6, "1, 2, 3, 4, 5, 6", 14.131, 19.247, 8.606, 90.0,
......
......@@ -26,13 +26,13 @@ public:
friend class PeakColumn;
Peak();
Peak(Geometry::Instrument_const_sptr m_inst, Mantid::Kernel::V3D QLabFrame,
boost::optional<double> detectorDistance = boost::optional<double>());
Peak(const Geometry::Instrument_const_sptr &m_inst,
const Mantid::Kernel::V3D &QLabFrame,
boost::optional<double> detectorDistance = boost::none);
Peak(const Geometry::Instrument_const_sptr &m_inst,
const Mantid::Kernel::V3D &QSampleFrame,
const Mantid::Kernel::Matrix<double> &goniometer,
const boost::optional<double> &detectorDistance =
boost::optional<double>());
boost::optional<double> detectorDistance = boost::none);
Peak(Geometry::Instrument_const_sptr m_inst, int m_detectorID,
double m_Wavelength);
Peak(Geometry::Instrument_const_sptr m_inst, int m_detectorID,
......@@ -45,8 +45,8 @@ public:
/// Copy constructor
Peak(const Peak &other);
Peak(Peak &&) = default;
Peak &operator=(Peak &&) = default;
Peak(Peak &&) noexcept;
Peak &operator=(Peak &&) noexcept;
// Construct a peak from a reference to the interface
......@@ -87,12 +87,12 @@ public:
Mantid::Kernel::V3D getDetectorPosition() const override;
Mantid::Kernel::V3D getDetectorPositionNoCheck() const override;
void setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame,
const boost::optional<double> &detectorDistance =
boost::optional<double>()) override;
void setQLabFrame(const Mantid::Kernel::V3D &QLabFrame,
const boost::optional<double> &detectorDistance =
boost::optional<double>()) override;
void setQSampleFrame(
const Mantid::Kernel::V3D &QSampleFrame,
boost::optional<double> detectorDistance = boost::none) override;
void
setQLabFrame(const Mantid::Kernel::V3D &QLabFrame,
boost::optional<double> detectorDistance = boost::none) override;
void setWavelength(double wavelength) override;
double getWavelength() const override;
......
......@@ -106,9 +106,9 @@ public:
Peak &getPeak(int peakNum) override;
const Peak &getPeak(int peakNum) const override;
Geometry::IPeak *createPeak(Kernel::V3D QLabFrame,
boost::optional<double> detectorDistance =
boost::optional<double>()) const override;
Geometry::IPeak *createPeak(
Kernel::V3D QLabFrame,
boost::optional<double> detectorDistance = boost::none) const override;
std::vector<std::pair<std::string, std::string>>
peakInfo(Kernel::V3D qFrame, bool labCoords) const override;
......
......@@ -45,7 +45,7 @@ Peak::Peak()
*/
Peak::Peak(const Geometry::Instrument_const_sptr &m_inst,
const Mantid::Kernel::V3D &QLabFrame,
const boost::optional<double> &detectorDistance)
boost::optional<double> detectorDistance)
: m_H(0), m_K(0), m_L(0), m_intensity(0), m_sigmaIntensity(0),
m_binCount(0), m_GoniometerMatrix(3, 3, true),
m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0),
......@@ -72,7 +72,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst,
Peak::Peak(const Geometry::Instrument_const_sptr &m_inst,
const Mantid::Kernel::V3D &QSampleFrame,
const Mantid::Kernel::Matrix<double> &goniometer,
const boost::optional<double> &detectorDistance)
boost::optional<double> detectorDistance)
: m_H(0), m_K(0), m_L(0), m_intensity(0), m_sigmaIntensity(0),
m_binCount(0), m_GoniometerMatrix(goniometer),
m_InverseGoniometerMatrix(goniometer), m_runNumber(0), m_monitorCount(0),
......@@ -231,6 +231,9 @@ Peak::Peak(const Geometry::IPeak &ipeak)
}
}
Peak::Peak(Peak &&) noexcept = default;
Peak &Peak::operator=(Peak &&) noexcept = default;
//----------------------------------------------------------------------------------------------
/** Set the incident wavelength of the neutron. Calculates the energy from this.
* Assumes elastic scattering.
......@@ -495,7 +498,7 @@ Mantid::Kernel::V3D Peak::getQSampleFrame() const {
* Used to give a valid TOF. You do NOT need to explicitly set this.
*/
void Peak::setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame,
const boost::optional<double> &detectorDistance) {
boost::optional<double> detectorDistance) {
V3D Qlab = m_GoniometerMatrix * QSampleFrame;
this->setQLabFrame(Qlab, detectorDistance);
}
......@@ -517,7 +520,7 @@ void Peak::setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame,
* ray trace to find the intersecing detector.
*/
void Peak::setQLabFrame(const Mantid::Kernel::V3D &QLabFrame,
const boost::optional<double> &detectorDistance) {
boost::optional<double> detectorDistance) {
// Clear out the detector = we can't know them
m_detectorID = -1;
m_det = IDetector_sptr();
......@@ -922,7 +925,7 @@ void Peak::setPeakShape(Mantid::Geometry::PeakShape *shape) {
* @param shape : Desired shape
*/
void Peak::setPeakShape(Mantid::Geometry::PeakShape_const_sptr shape) {
this->m_peakShape = shape;
this->m_peakShape = std::move(shape);
}
/**
......
......@@ -50,12 +50,10 @@ public:
virtual Mantid::Kernel::V3D getQSampleFrame() const = 0;
virtual bool findDetector() = 0;
virtual void
setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame,
const boost::optional<double> &detectorDistance) = 0;
virtual void
setQLabFrame(const Mantid::Kernel::V3D &QLabFrame,
const boost::optional<double> &detectorDistance) = 0;
virtual void setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame,
boost::optional<double> detectorDistance) = 0;
virtual void setQLabFrame(const Mantid::Kernel::V3D &QLabFrame,
boost::optional<double> detectorDistance) = 0;
virtual void setWavelength(double wavelength) = 0;
virtual double getWavelength() const = 0;
......
......@@ -18,7 +18,7 @@ Mantid::Geometry::PeakShape_sptr getPeakShape(IPeak &peak) {
}
void setQLabFrame1(IPeak &peak, Mantid::Kernel::V3D qLabFrame) {
// Set the q lab frame. No explicit detector distance.
return peak.setQLabFrame(qLabFrame, boost::optional<double>());
return peak.setQLabFrame(qLabFrame, boost::none);
}
void setQLabFrame2(IPeak &peak, Mantid::Kernel::V3D qLabFrame,
double distance) {
......@@ -28,7 +28,7 @@ void setQLabFrame2(IPeak &peak, Mantid::Kernel::V3D qLabFrame,
void setQSampleFrame1(IPeak &peak, Mantid::Kernel::V3D qSampleFrame) {
// Set the qsample frame. No explicit detector distance.
return peak.setQSampleFrame(qSampleFrame, boost::optional<double>());
return peak.setQSampleFrame(qSampleFrame, boost::none);
}
void setQSampleFrame2(IPeak &peak, Mantid::Kernel::V3D qSampleFrame,
......
......@@ -26,8 +26,7 @@ IPeak *createPeakHKL(IPeaksWorkspace &self, const object &data) {
/// Create a peak via it's QLab value from a list or numpy array
IPeak *createPeakQLab(IPeaksWorkspace &self, const object &data) {
return self.createPeak(
Mantid::PythonInterface::Converters::PyObjectToV3D(data)(),
boost::optional<double>());
Mantid::PythonInterface::Converters::PyObjectToV3D(data)(), boost::none);
}
/// Create a peak via it's QLab value from a list or numpy array
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment