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

namespace clucene.net {

using System;
using System.Runtime.InteropServices;

public class IndexSearcher : Searcher {
  private HandleRef swigCPtr;

  internal IndexSearcher(IntPtr cPtr, bool cMemoryOwn) : base(libCLcsharpPINVOKE.IndexSearcherUpcast(cPtr), cMemoryOwn) {
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(IndexSearcher obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }

  ~IndexSearcher() {
    Dispose();
  }

  public override void Dispose() {
    if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
      swigCMemOwn = false;
      libCLcsharpPINVOKE.delete_IndexSearcher(swigCPtr);
    }
    swigCPtr = new HandleRef(null, IntPtr.Zero);
    GC.SuppressFinalize(this);
    base.Dispose();
  }

  public IndexSearcher(string path) : this(libCLcsharpPINVOKE.new_IndexSearcher__SWIG_0(path), true) {
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public IndexSearcher(Directory directory) : this(libCLcsharpPINVOKE.new_IndexSearcher__SWIG_1(Directory.getCPtr(directory)), true) {
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public IndexSearcher(IndexReader r) : this(libCLcsharpPINVOKE.new_IndexSearcher__SWIG_2(IndexReader.getCPtr(r)), true) {
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public IndexReader getReader() {
    IntPtr cPtr = libCLcsharpPINVOKE.IndexSearcher_getReader(swigCPtr);
    IndexReader ret = (cPtr == IntPtr.Zero) ? null : new IndexReader(cPtr, false);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}
