//------------------------------------------------------------------------------
// <auto-generated />
//
// This file was automatically generated by SWIG (http://www.swig.org).
// Version 3.0.13
//
// Do not make changes to this file unless you know what you are doing--modify
// the SWIG interface file instead.
//------------------------------------------------------------------------------

namespace Xapian {

public class LatLongMetric : global::System.IDisposable {
  private global::System.Runtime.InteropServices.HandleRef swigCPtr;
  protected bool swigCMemOwn;

  internal LatLongMetric(global::System.IntPtr cPtr, bool cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
  }

  internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LatLongMetric obj) {
    return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
  }

  ~LatLongMetric() {
    Dispose();
  }

  public virtual void Dispose() {
    lock(this) {
      if (swigCPtr.Handle != global::System.IntPtr.Zero) {
        if (swigCMemOwn) {
          swigCMemOwn = false;
          XapianPINVOKE.delete_LatLongMetric(swigCPtr);
        }
        swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
      }
      global::System.GC.SuppressFinalize(this);
    }
  }

  public virtual double PointwiseDistance(LatLongCoord a, LatLongCoord b) {
    double ret = XapianPINVOKE.LatLongMetric_PointwiseDistance(swigCPtr, LatLongCoord.getCPtr(a), LatLongCoord.getCPtr(b));
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double Apply(LatLongCoords a, LatLongCoords b) {
    double ret = XapianPINVOKE.LatLongMetric_Apply__SWIG_0(swigCPtr, LatLongCoords.getCPtr(a), LatLongCoords.getCPtr(b));
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double Apply(LatLongCoords a, string b) {
    double ret = XapianPINVOKE.LatLongMetric_Apply__SWIG_1(swigCPtr, LatLongCoords.getCPtr(a), b);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double Apply(LatLongCoords a, string b_ptr, uint b_len) {
    double ret = XapianPINVOKE.LatLongMetric_Apply__SWIG_2(swigCPtr, LatLongCoords.getCPtr(a), b_ptr, b_len);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual string Name() {
    string ret = XapianPINVOKE.LatLongMetric_Name(swigCPtr);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public LatLongMetric() : this(XapianPINVOKE.new_LatLongMetric(), true) {
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    SwigDirectorConnect();
  }

  private void SwigDirectorConnect() {
    if (SwigDerivedClassHasMethod("PointwiseDistance", swigMethodTypes0))
      swigDelegate0 = new SwigDelegateLatLongMetric_0(SwigDirectorPointwiseDistance);
    if (SwigDerivedClassHasMethod("Name", swigMethodTypes1))
      swigDelegate1 = new SwigDelegateLatLongMetric_1(SwigDirectorName);
    XapianPINVOKE.LatLongMetric_director_connect(swigCPtr, swigDelegate0, swigDelegate1);
  }

  private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes) {
    global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
    bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(LatLongMetric));
    return hasDerivedMethod;
  }

  private double SwigDirectorPointwiseDistance(global::System.IntPtr a, global::System.IntPtr b) {
    return PointwiseDistance(new LatLongCoord(a, false), new LatLongCoord(b, false));
  }

  private string SwigDirectorName() {
    return Name();
  }

  public delegate double SwigDelegateLatLongMetric_0(global::System.IntPtr a, global::System.IntPtr b);
  public delegate string SwigDelegateLatLongMetric_1();

  private SwigDelegateLatLongMetric_0 swigDelegate0;
  private SwigDelegateLatLongMetric_1 swigDelegate1;

  private static global::System.Type[] swigMethodTypes0 = new global::System.Type[] { typeof(LatLongCoord), typeof(LatLongCoord) };
  private static global::System.Type[] swigMethodTypes1 = new global::System.Type[] {  };
}

}
