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

namespace OSGeo.OGR {

using System;
using System.Runtime.InteropServices;

public class Layer : IDisposable {
  private HandleRef swigCPtr;
  protected object swigCMemOwner;

  internal Layer(IntPtr cPtr, object cMemoryOwner) {
    swigCMemOwner = cMemoryOwner;
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(Layer obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }
  internal static HandleRef getCPtrAndDisown(Layer obj, object cMemoryOwner) {
    obj.swigCMemOwner = cMemoryOwner;
    return getCPtr(obj);
  }

  public virtual void Dispose() {
  lock(this) {
      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwner == null) {
        swigCMemOwner = new object();
        throw new MethodAccessException("C++ destructor does not have public access");
      }
      swigCPtr = new HandleRef(null, IntPtr.Zero);
      GC.SuppressFinalize(this);
    }
  }

  public int GetRefCount() {
    int ret = ogrPINVOKE.Layer_GetRefCount(swigCPtr);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void SetSpatialFilter(Geometry filter) {
    ogrPINVOKE.Layer_SetSpatialFilter(swigCPtr, Geometry.getCPtr(filter));
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
  }

  public void SetSpatialFilterRect(double minx, double miny, double maxx, double maxy) {
    ogrPINVOKE.Layer_SetSpatialFilterRect(swigCPtr, minx, miny, maxx, maxy);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
  }

  public Geometry GetSpatialFilter() {
    IntPtr cPtr = ogrPINVOKE.Layer_GetSpatialFilter(swigCPtr);
    Geometry ret = (cPtr == IntPtr.Zero) ? null : new Geometry(cPtr, false? null : this);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetAttributeFilter(string filter_string) {
    int ret = ogrPINVOKE.Layer_SetAttributeFilter(swigCPtr, filter_string);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void ResetReading() {
    ogrPINVOKE.Layer_ResetReading(swigCPtr);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
  }

  public string GetName() {
    string ret = ogrPINVOKE.Layer_GetName(swigCPtr);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public Feature GetFeature(int fid) {
    IntPtr cPtr = ogrPINVOKE.Layer_GetFeature(swigCPtr, fid);
    Feature ret = (cPtr == IntPtr.Zero) ? null : new Feature(cPtr, true? null : this);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public Feature GetNextFeature() {
    IntPtr cPtr = ogrPINVOKE.Layer_GetNextFeature(swigCPtr);
    Feature ret = (cPtr == IntPtr.Zero) ? null : new Feature(cPtr, true? null : this);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetNextByIndex(int new_index) {
    int ret = ogrPINVOKE.Layer_SetNextByIndex(swigCPtr, new_index);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetFeature(Feature feature) {
    int ret = ogrPINVOKE.Layer_SetFeature(swigCPtr, Feature.getCPtr(feature));
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int CreateFeature(Feature feature) {
    int ret = ogrPINVOKE.Layer_CreateFeature(swigCPtr, Feature.getCPtr(feature));
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int DeleteFeature(int fid) {
    int ret = ogrPINVOKE.Layer_DeleteFeature(swigCPtr, fid);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SyncToDisk() {
    int ret = ogrPINVOKE.Layer_SyncToDisk(swigCPtr);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public FeatureDefn GetLayerDefn() {
    IntPtr cPtr = ogrPINVOKE.Layer_GetLayerDefn(swigCPtr);
    FeatureDefn ret = (cPtr == IntPtr.Zero) ? null : new FeatureDefn(cPtr, false? null : this);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int GetFeatureCount(int force) {
    int ret = ogrPINVOKE.Layer_GetFeatureCount(swigCPtr, force);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int GetExtent(Envelope extent, int force) {
    int ret = ogrPINVOKE.Layer_GetExtent(swigCPtr, Envelope.getCPtr(extent), force);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public bool TestCapability(string cap) {
    bool ret = ogrPINVOKE.Layer_TestCapability(swigCPtr, cap);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int CreateField(FieldDefn field_def, int approx_ok) {
    int ret = ogrPINVOKE.Layer_CreateField(swigCPtr, FieldDefn.getCPtr(field_def), approx_ok);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int StartTransaction() {
    int ret = ogrPINVOKE.Layer_StartTransaction(swigCPtr);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int CommitTransaction() {
    int ret = ogrPINVOKE.Layer_CommitTransaction(swigCPtr);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int RollbackTransaction() {
    int ret = ogrPINVOKE.Layer_RollbackTransaction(swigCPtr);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public SpatialReference GetSpatialRef() {
    IntPtr cPtr = ogrPINVOKE.Layer_GetSpatialRef(swigCPtr);
    SpatialReference ret = (cPtr == IntPtr.Zero) ? null : new SpatialReference(cPtr, false? null : this);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public long GetFeatureRead() {
    long res = ogrPINVOKE.Layer_GetFeatureRead(swigCPtr);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return res;
}

}

}
