/* ----------------------------------------------------------------------------
 * 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.
 * ----------------------------------------------------------------------------- */

package org.gdal.ogr;

import org.gdal.osr.SpatialReference;

public class DataSource {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  protected DataSource(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(DataSource obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      ogrJNI.delete_DataSource(swigCPtr);
    }
    swigCPtr = 0;
  }

  protected static long getCPtrAndDisown(DataSource obj) {
    if (obj != null) obj.swigCMemOwn= false;
    return getCPtr(obj);
  }

  public String getName() {
    return ogrJNI.DataSource_name_get(swigCPtr, this);
  }

  public int GetRefCount() {
    return ogrJNI.DataSource_GetRefCount(swigCPtr, this);
  }

  public int GetSummaryRefCount() {
    return ogrJNI.DataSource_GetSummaryRefCount(swigCPtr, this);
  }

  public int GetLayerCount() {
    return ogrJNI.DataSource_GetLayerCount(swigCPtr, this);
  }

  public Driver GetDriver() {
    long cPtr = ogrJNI.DataSource_GetDriver(swigCPtr, this);
    return (cPtr == 0) ? null : new Driver(cPtr, false);
  }

  public String GetName() {
    return ogrJNI.DataSource_GetName(swigCPtr, this);
  }

  public int DeleteLayer(int index) {
    return ogrJNI.DataSource_DeleteLayer(swigCPtr, this, index);
  }

  public Layer CreateLayer(String name, SpatialReference reference, int geom_type, java.util.Vector options) {
    long cPtr = ogrJNI.DataSource_CreateLayer(swigCPtr, this, name, SpatialReference.getCPtr(reference), reference, geom_type, options);
    return (cPtr == 0) ? null : new Layer(cPtr, false);
  }

  public Layer CopyLayer(Layer src_layer, String new_name, java.util.Vector options) {
    long cPtr = ogrJNI.DataSource_CopyLayer(swigCPtr, this, Layer.getCPtr(src_layer), src_layer, new_name, options);
    return (cPtr == 0) ? null : new Layer(cPtr, false);
  }

  public Layer GetLayerByIndex(int index) {
    long cPtr = ogrJNI.DataSource_GetLayerByIndex(swigCPtr, this, index);
    return (cPtr == 0) ? null : new Layer(cPtr, false);
  }

  public Layer GetLayerByName(String layer_name) {
    long cPtr = ogrJNI.DataSource_GetLayerByName(swigCPtr, this, layer_name);
    return (cPtr == 0) ? null : new Layer(cPtr, false);
  }

  public boolean TestCapability(String cap) {
    return ogrJNI.DataSource_TestCapability(swigCPtr, this, cap);
  }

  public Layer ExecuteSQL(String statement, Geometry geom, String dialect) {
    long cPtr = ogrJNI.DataSource_ExecuteSQL(swigCPtr, this, statement, Geometry.getCPtr(geom), geom, dialect);
    return (cPtr == 0) ? null : new Layer(cPtr, true);
  }

  public void ReleaseResultSet(Layer layer) {
    ogrJNI.DataSource_ReleaseResultSet(swigCPtr, this, Layer.getCPtrAndDisown(layer), layer);
  }

}
