Program Listing for File euclidean_dist.hpp

Return to documentation for file (rcppsw/spatial/euclidean_dist.hpp)

#pragma once

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include "rcppsw/spatial/measurement.hpp"

/*******************************************************************************
 * Namespaces/Decls
 ******************************************************************************/
namespace rcppsw::spatial {

/*******************************************************************************
 * Class Definitions
 ******************************************************************************/
class euclidean_dist final : public measurement<double, struct euclidean_dist_tag> {
 public:
  static euclidean_dist make(const double& value);

  explicit euclidean_dist(const double& v) : measurement(v) {}
  ~euclidean_dist(void) override = default;
  euclidean_dist(const euclidean_dist&) = default;

  euclidean_dist operator*(double rhs) const {
    return euclidean_dist(v() * rhs);
  }
  euclidean_dist operator/(double rhs) const {
    return euclidean_dist(v() / rhs);
  }
  euclidean_dist operator-(double rhs) const {
    return euclidean_dist(v() - rhs);
  }
  euclidean_dist operator+(double rhs) const {
    return euclidean_dist(v() + rhs);
  }


  euclidean_dist operator*(const euclidean_dist& rhs) const {
    return euclidean_dist(v() * rhs.v());
  }
  euclidean_dist operator/(const euclidean_dist& rhs) const {
    return euclidean_dist(v() / rhs.v());
  }
  euclidean_dist operator-(const euclidean_dist& rhs) const {
    return euclidean_dist(v() - rhs.v());
  }
  euclidean_dist operator+(const euclidean_dist& rhs) const {
    return euclidean_dist(v() + rhs.v());
  }

  euclidean_dist& operator-=(double rhs) {
    set(v() - rhs);
    return *this;
  }
  euclidean_dist& operator+=(double rhs) {
    set(v() + rhs);
    return *this;
  }
  euclidean_dist& operator=(const euclidean_dist& rhs) {
    set(rhs.v());
    return *this;
  }
  euclidean_dist& operator+=(const euclidean_dist& rhs) {
    set(v() + rhs.v());
    return *this;
  }
};

/*******************************************************************************
 * Operators
 ******************************************************************************/
euclidean_dist operator*(double lhs, const euclidean_dist& rhs);
euclidean_dist operator/(double lhs, const euclidean_dist& rhs);
euclidean_dist operator-(double lhs, const euclidean_dist& rhs);
euclidean_dist operator+(double lhs, const euclidean_dist& rhs);
bool operator<=(double lhs, const euclidean_dist& rhs) RCPPSW_PURE;
bool operator<(double lhs, const euclidean_dist& rhs) RCPPSW_PURE;

} /* namespace rcppsw::spatial */