//------------------------------------------------------------------------------
// <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 QuantLib {

public class CdsOption : Option {
  private global::System.Runtime.InteropServices.HandleRef swigCPtr;
  private bool swigCMemOwnDerived;

  internal CdsOption(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NQuantLibcPINVOKE.CdsOption_SWIGSmartPtrUpcast(cPtr), true) {
    swigCMemOwnDerived = cMemoryOwn;
    swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
  }

  internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CdsOption obj) {
    return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
  }

  protected override void Dispose(bool disposing) {
    lock(this) {
      if (swigCPtr.Handle != global::System.IntPtr.Zero) {
        if (swigCMemOwnDerived) {
          swigCMemOwnDerived = false;
          NQuantLibcPINVOKE.delete_CdsOption(swigCPtr);
        }
        swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
      }
      base.Dispose(disposing);
    }
  }

  public CdsOption(CreditDefaultSwap swap, Exercise exercise, bool knocksOut) : this(NQuantLibcPINVOKE.new_CdsOption__SWIG_0(CreditDefaultSwap.getCPtr(swap), Exercise.getCPtr(exercise), knocksOut), true) {
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
  }

  public CdsOption(CreditDefaultSwap swap, Exercise exercise) : this(NQuantLibcPINVOKE.new_CdsOption__SWIG_1(CreditDefaultSwap.getCPtr(swap), Exercise.getCPtr(exercise)), true) {
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
  }

  public double atmRate() {
    double ret = NQuantLibcPINVOKE.CdsOption_atmRate(swigCPtr);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double riskyAnnuity() {
    double ret = NQuantLibcPINVOKE.CdsOption_riskyAnnuity(swigCPtr);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double impliedVolatility(double price, YieldTermStructureHandle termStructure, DefaultProbabilityTermStructureHandle arg2, double recoveryRate, double accuracy, uint maxEvaluations, double minVol, double maxVol) {
    double ret = NQuantLibcPINVOKE.CdsOption_impliedVolatility__SWIG_0(swigCPtr, price, YieldTermStructureHandle.getCPtr(termStructure), DefaultProbabilityTermStructureHandle.getCPtr(arg2), recoveryRate, accuracy, maxEvaluations, minVol, maxVol);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double impliedVolatility(double price, YieldTermStructureHandle termStructure, DefaultProbabilityTermStructureHandle arg2, double recoveryRate, double accuracy, uint maxEvaluations, double minVol) {
    double ret = NQuantLibcPINVOKE.CdsOption_impliedVolatility__SWIG_1(swigCPtr, price, YieldTermStructureHandle.getCPtr(termStructure), DefaultProbabilityTermStructureHandle.getCPtr(arg2), recoveryRate, accuracy, maxEvaluations, minVol);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double impliedVolatility(double price, YieldTermStructureHandle termStructure, DefaultProbabilityTermStructureHandle arg2, double recoveryRate, double accuracy, uint maxEvaluations) {
    double ret = NQuantLibcPINVOKE.CdsOption_impliedVolatility__SWIG_2(swigCPtr, price, YieldTermStructureHandle.getCPtr(termStructure), DefaultProbabilityTermStructureHandle.getCPtr(arg2), recoveryRate, accuracy, maxEvaluations);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double impliedVolatility(double price, YieldTermStructureHandle termStructure, DefaultProbabilityTermStructureHandle arg2, double recoveryRate, double accuracy) {
    double ret = NQuantLibcPINVOKE.CdsOption_impliedVolatility__SWIG_3(swigCPtr, price, YieldTermStructureHandle.getCPtr(termStructure), DefaultProbabilityTermStructureHandle.getCPtr(arg2), recoveryRate, accuracy);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double impliedVolatility(double price, YieldTermStructureHandle termStructure, DefaultProbabilityTermStructureHandle arg2, double recoveryRate) {
    double ret = NQuantLibcPINVOKE.CdsOption_impliedVolatility__SWIG_4(swigCPtr, price, YieldTermStructureHandle.getCPtr(termStructure), DefaultProbabilityTermStructureHandle.getCPtr(arg2), recoveryRate);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}
