//------------------------------------------------------------------------------
// <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 CapFloor : Instrument {
  private global::System.Runtime.InteropServices.HandleRef swigCPtr;
  private bool swigCMemOwnDerived;

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

  internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CapFloor 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_CapFloor(swigCPtr);
        }
        swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
      }
      base.Dispose(disposing);
    }
  }

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess, double accuracy, uint maxEvaluations, double minVol, double maxVol, VolatilityType type, double displacement) {
    double ret = NQuantLibcPINVOKE.CapFloor_impliedVolatility__SWIG_0(swigCPtr, price, YieldTermStructureHandle.getCPtr(disc), guess, accuracy, maxEvaluations, minVol, maxVol, (int)type, displacement);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess, double accuracy, uint maxEvaluations, double minVol, double maxVol, VolatilityType type) {
    double ret = NQuantLibcPINVOKE.CapFloor_impliedVolatility__SWIG_1(swigCPtr, price, YieldTermStructureHandle.getCPtr(disc), guess, accuracy, maxEvaluations, minVol, maxVol, (int)type);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess, double accuracy, uint maxEvaluations, double minVol, double maxVol) {
    double ret = NQuantLibcPINVOKE.CapFloor_impliedVolatility__SWIG_2(swigCPtr, price, YieldTermStructureHandle.getCPtr(disc), guess, accuracy, maxEvaluations, minVol, maxVol);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess, double accuracy, uint maxEvaluations, double minVol) {
    double ret = NQuantLibcPINVOKE.CapFloor_impliedVolatility__SWIG_3(swigCPtr, price, YieldTermStructureHandle.getCPtr(disc), guess, accuracy, maxEvaluations, minVol);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess, double accuracy, uint maxEvaluations) {
    double ret = NQuantLibcPINVOKE.CapFloor_impliedVolatility__SWIG_4(swigCPtr, price, YieldTermStructureHandle.getCPtr(disc), guess, accuracy, maxEvaluations);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess, double accuracy) {
    double ret = NQuantLibcPINVOKE.CapFloor_impliedVolatility__SWIG_5(swigCPtr, price, YieldTermStructureHandle.getCPtr(disc), guess, accuracy);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess) {
    double ret = NQuantLibcPINVOKE.CapFloor_impliedVolatility__SWIG_6(swigCPtr, price, YieldTermStructureHandle.getCPtr(disc), guess);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public Leg floatingLeg() {
    Leg ret = new Leg(NQuantLibcPINVOKE.CapFloor_floatingLeg(swigCPtr), false);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public DoubleVector capRates() {
    DoubleVector ret = new DoubleVector(NQuantLibcPINVOKE.CapFloor_capRates(swigCPtr), false);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public DoubleVector floorRates() {
    DoubleVector ret = new DoubleVector(NQuantLibcPINVOKE.CapFloor_floorRates(swigCPtr), false);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public Date startDate() {
    Date ret = new Date(NQuantLibcPINVOKE.CapFloor_startDate(swigCPtr), true);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public Date maturityDate() {
    Date ret = new Date(NQuantLibcPINVOKE.CapFloor_maturityDate(swigCPtr), true);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public CapFloor.Type type() {
    CapFloor.Type ret = (CapFloor.Type)NQuantLibcPINVOKE.CapFloor_type(swigCPtr);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double atmRate(YieldTermStructure discountCurve) {
    double ret = NQuantLibcPINVOKE.CapFloor_atmRate(swigCPtr, YieldTermStructure.getCPtr(discountCurve));
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

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

  public DoubleVector optionletsPrice() {
    DoubleVector ret = new DoubleVector(NQuantLibcPINVOKE.CapFloor_optionletsPrice(swigCPtr), true);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public DoubleVector optionletsVega() {
    DoubleVector ret = new DoubleVector(NQuantLibcPINVOKE.CapFloor_optionletsVega(swigCPtr), true);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public DoubleVector optionletsDelta() {
    DoubleVector ret = new DoubleVector(NQuantLibcPINVOKE.CapFloor_optionletsDelta(swigCPtr), true);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public DoubleVector optionletsDiscountFactor() {
    DoubleVector ret = new DoubleVector(NQuantLibcPINVOKE.CapFloor_optionletsDiscountFactor(swigCPtr), true);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public DoubleVector optionletsAtmForward() {
    DoubleVector ret = new DoubleVector(NQuantLibcPINVOKE.CapFloor_optionletsAtmForward(swigCPtr), true);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public DoubleVector optionletsStdDev() {
    DoubleVector ret = new DoubleVector(NQuantLibcPINVOKE.CapFloor_optionletsStdDev(swigCPtr), true);
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public enum Type {
    Cap,
    Floor,
    Collar
  }

}

}
