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

namespace libsbml {

public class Callback : global::System.IDisposable {
	private HandleRef swigCPtr;
	protected bool swigCMemOwn;
	
	internal Callback(IntPtr cPtr, bool cMemoryOwn)
	{
		swigCMemOwn = cMemoryOwn;
		swigCPtr    = new HandleRef(this, cPtr);
	}
	
	internal static HandleRef getCPtr(Callback obj)
	{
		return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
	}
	
	internal static HandleRef getCPtrAndDisown (Callback obj)
	{
		HandleRef ptr = new HandleRef(null, IntPtr.Zero);
		
		if (obj != null)
		{
			ptr             = obj.swigCPtr;
			obj.swigCMemOwn = false;
		}
		
		return ptr;
	}

  ~Callback() {
    Dispose(false);
  }

  public void Dispose() {
    Dispose(true);
    global::System.GC.SuppressFinalize(this);
  }

  protected virtual void Dispose(bool disposing) {
    lock(this) {
      if (swigCPtr.Handle != global::System.IntPtr.Zero) {
        if (swigCMemOwn) {
          swigCMemOwn = false;
          libsbmlPINVOKE.delete_Callback(swigCPtr);
        }
        swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
      }
    }
  }

  
/**
	 * The processing function to be implemented by the callback
	 * 
	 * In order to stop processing return a value other than 
	 * LIBSBML_OPERATION_SUCCESS. 
	 * 
	 * @return LIBSBML_OPERATION_SUCCESS to continue the operations
	 *         any other value to stop
	 */ public new
 int process(SBMLDocument doc) {
    int ret = (SwigDerivedClassHasMethod("process", swigMethodTypes0) ? libsbmlPINVOKE.Callback_processSwigExplicitCallback(swigCPtr, SBMLDocument.getCPtr(doc)) : libsbmlPINVOKE.Callback_process(swigCPtr, SBMLDocument.getCPtr(doc)));
    return ret;
  }

  public Callback() : this(libsbmlPINVOKE.new_Callback(), true) {
    SwigDirectorConnect();
  }

  private void SwigDirectorConnect() {
    if (SwigDerivedClassHasMethod("process", swigMethodTypes0))
      swigDelegate0 = new SwigDelegateCallback_0(SwigDirectorMethodprocess);
    libsbmlPINVOKE.Callback_director_connect(swigCPtr, swigDelegate0);
  }

  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(Callback));
    return hasDerivedMethod;
  }

  private int SwigDirectorMethodprocess(global::System.IntPtr doc) {
    return process((doc == global::System.IntPtr.Zero) ? null : new SBMLDocument(doc, false));
  }

  public delegate int SwigDelegateCallback_0(global::System.IntPtr doc);

  private SwigDelegateCallback_0 swigDelegate0;

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

}
