Skip to content

Commit

Permalink
Re #12033 Override accessors to NumericAxis data unused in RefAxis.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonHeybrock committed Jul 2, 2015
1 parent 91d29f9 commit 0cf79e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/API/inc/MantidAPI/NumericAxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ class MANTID_API_DLL NumericAxis : public Axis {
const std::size_t &verticalIndex = 0) const;
/// Set the value at a specific index
virtual void setValue(const std::size_t &index, const double &value);
size_t indexOfValue(const double value) const;
virtual size_t indexOfValue(const double value) const;
virtual bool operator==(const Axis &) const;
virtual bool equalWithinTolerance(const Axis &axis2,
const double tolerance) const;
std::string label(const std::size_t &index) const;
/// Create bin boundaries from the point values
virtual std::vector<double> createBinBoundaries() const;
/// Return a const reference to the values
const std::vector<double> &getValues() const;
virtual const std::vector<double> &getValues() const;
/// returns min value defined on axis
double getMin() const { return m_values.front(); }
/// returns max value defined on axis
Expand Down
13 changes: 13 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/RefAxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ class MANTID_API_DLL RefAxis : public NumericAxis {
virtual bool operator==(const Axis &) const;
virtual bool equalWithinTolerance(const Axis &axis2,
const double tolerance) const;
// We must override these to prevent access to NumericAxis::m_values and
// m_edges, which are unused by RefAxis and thus do not hold sensible values.
virtual size_t indexOfValue(const double value) const {
UNUSED_ARG(value)
throw std::runtime_error("Calling indexOfValue() on RefAxis is forbidden.");
}
virtual std::vector<double> createBinBoundaries() const {
throw std::runtime_error(
"Calling createBinBoundaries() on RefAxis is forbidden.");
}
virtual const std::vector<double> &getValues() const {
throw std::runtime_error("Calling getValues() on RefAxis is forbidded.");
}

This comment has been minimized.

Copy link
@quantumsteve

quantumsteve Jul 2, 2015

Contributor

Either move the implementation of these member functions into RefAxis.cpp or move the implementation of RefAxis::getMin() andRefAxis::getMax()` into the header file. I believe the former is preferred unless there is a strong performance reason to do otherwise.

virtual double getMin() const;
virtual double getMax() const;

Expand Down

0 comments on commit 0cf79e1

Please sign in to comment.