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

namespace OSGeo.GDAL {

using System;
using System.Runtime.InteropServices;

public class Dataset : MajorObject {
  private HandleRef swigCPtr;

  internal Dataset(IntPtr cPtr, object cMemoryOwner) : base(gdalPINVOKE.DatasetUpcast(cPtr), cMemoryOwner) {
    swigCPtr = new HandleRef(this, cPtr);
  }

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

  ~Dataset() {
    Dispose();
  }

  public override void Dispose() {
  lock(this) {
      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwner == null) {
        swigCMemOwner = new object();
        gdalPINVOKE.delete_Dataset(swigCPtr);
      }
      swigCPtr = new HandleRef(null, IntPtr.Zero);
      GC.SuppressFinalize(this);
      base.Dispose();
    }
  }

  public int RasterXSize {
    get {
      int ret = gdalPINVOKE.Dataset_RasterXSize_get(swigCPtr);
      if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
      return ret;
    } 
  }

  public int RasterYSize {
    get {
      int ret = gdalPINVOKE.Dataset_RasterYSize_get(swigCPtr);
      if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
      return ret;
    } 
  }

  public int RasterCount {
    get {
      int ret = gdalPINVOKE.Dataset_RasterCount_get(swigCPtr);
      if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
      return ret;
    } 
  }

  public Driver GetDriver() {
    IntPtr cPtr = gdalPINVOKE.Dataset_GetDriver(swigCPtr);
    Driver ret = (cPtr == IntPtr.Zero) ? null : new Driver(cPtr, false? null : this);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public Band GetRasterBand(int nBand) {
    IntPtr cPtr = gdalPINVOKE.Dataset_GetRasterBand(swigCPtr, nBand);
    Band ret = (cPtr == IntPtr.Zero) ? null : new Band(cPtr, false? null : this);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public string GetProjection() {
    string ret = gdalPINVOKE.Dataset_GetProjection(swigCPtr);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public string GetProjectionRef() {
    string ret = gdalPINVOKE.Dataset_GetProjectionRef(swigCPtr);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetProjection(string prj) {
    int ret = gdalPINVOKE.Dataset_SetProjection(swigCPtr, prj);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void GetGeoTransform(double[] argout) {
    gdalPINVOKE.Dataset_GetGeoTransform(swigCPtr, argout);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
  }

  public int SetGeoTransform(double[] argin) {
    int ret = gdalPINVOKE.Dataset_SetGeoTransform(swigCPtr, argin);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int BuildOverviews(string resampling, int overviewlist) {
    int ret = gdalPINVOKE.Dataset_BuildOverviews(swigCPtr, resampling, overviewlist);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int GetGCPCount() {
    int ret = gdalPINVOKE.Dataset_GetGCPCount(swigCPtr);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public string GetGCPProjection() {
    string ret = gdalPINVOKE.Dataset_GetGCPProjection(swigCPtr);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void GetGCPs(SWIGTYPE_p_int nGCPs, SWIGTYPE_p_p_GDAL_GCP pGCPs) {
    gdalPINVOKE.Dataset_GetGCPs(swigCPtr, SWIGTYPE_p_int.getCPtr(nGCPs), SWIGTYPE_p_p_GDAL_GCP.getCPtr(pGCPs));
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
  }

  public int SetGCPs(int nGCPs, GCP pGCPs, string pszGCPProjection) {
    int ret = gdalPINVOKE.Dataset_SetGCPs(swigCPtr, nGCPs, GCP.getCPtr(pGCPs), pszGCPProjection);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void FlushCache() {
    gdalPINVOKE.Dataset_FlushCache(swigCPtr);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
  }

  public int AddBand(int datatype, string[] options) {
    int ret = gdalPINVOKE.Dataset_AddBand(swigCPtr, datatype, new gdalPINVOKE.StringListMarshal(options)._ar);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_len, SWIGTYPE_p_int buf_xsize, SWIGTYPE_p_int buf_ysize, SWIGTYPE_p_int buf_type, int band_list) {
    int ret = gdalPINVOKE.Dataset_WriteRaster(swigCPtr, xoff, yoff, xsize, ysize, buf_len, SWIGTYPE_p_int.getCPtr(buf_xsize), SWIGTYPE_p_int.getCPtr(buf_ysize), SWIGTYPE_p_int.getCPtr(buf_type), band_list);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int ReadRaster(int xoff, int yoff, int xsize, int ysize, SWIGTYPE_p_int buf_xsize, SWIGTYPE_p_int buf_ysize, SWIGTYPE_p_int buf_type, int band_list) {
    int ret = gdalPINVOKE.Dataset_ReadRaster(swigCPtr, xoff, yoff, xsize, ysize, SWIGTYPE_p_int.getCPtr(buf_xsize), SWIGTYPE_p_int.getCPtr(buf_ysize), SWIGTYPE_p_int.getCPtr(buf_type), band_list);
    if (gdalPINVOKE.SWIGPendingException.Pending) throw gdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}
