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

namespace QuantLib {

public class CPISwap : Swap {
  private global::System.Runtime.InteropServices.HandleRef swigCPtr;
  private bool swigCMemOwnDerived;

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

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

  public CPISwap(Swap.Type type, double nominal, bool subtractInflationNominal, double spread, DayCounter floatDayCount, Schedule floatSchedule, BusinessDayConvention floatRoll, uint fixingDays, IborIndex floatIndex, double fixedRate, double baseCPI, DayCounter fixedDayCount, Schedule fixedSchedule, BusinessDayConvention fixedRoll, Period observationLag, ZeroInflationIndex fixedIndex, CPI.InterpolationType observationInterpolation, double inflationNominal) : this(NQuantLibcPINVOKE.new_CPISwap__SWIG_0((int)type, nominal, subtractInflationNominal, spread, DayCounter.getCPtr(floatDayCount), Schedule.getCPtr(floatSchedule), (int)floatRoll, fixingDays, IborIndex.getCPtr(floatIndex), fixedRate, baseCPI, DayCounter.getCPtr(fixedDayCount), Schedule.getCPtr(fixedSchedule), (int)fixedRoll, Period.getCPtr(observationLag), ZeroInflationIndex.getCPtr(fixedIndex), (int)observationInterpolation, inflationNominal), true) {
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
  }

  public CPISwap(Swap.Type type, double nominal, bool subtractInflationNominal, double spread, DayCounter floatDayCount, Schedule floatSchedule, BusinessDayConvention floatRoll, uint fixingDays, IborIndex floatIndex, double fixedRate, double baseCPI, DayCounter fixedDayCount, Schedule fixedSchedule, BusinessDayConvention fixedRoll, Period observationLag, ZeroInflationIndex fixedIndex, CPI.InterpolationType observationInterpolation) : this(NQuantLibcPINVOKE.new_CPISwap__SWIG_1((int)type, nominal, subtractInflationNominal, spread, DayCounter.getCPtr(floatDayCount), Schedule.getCPtr(floatSchedule), (int)floatRoll, fixingDays, IborIndex.getCPtr(floatIndex), fixedRate, baseCPI, DayCounter.getCPtr(fixedDayCount), Schedule.getCPtr(fixedSchedule), (int)fixedRoll, Period.getCPtr(observationLag), ZeroInflationIndex.getCPtr(fixedIndex), (int)observationInterpolation), true) {
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
  }

  public CPISwap(Swap.Type type, double nominal, bool subtractInflationNominal, double spread, DayCounter floatDayCount, Schedule floatSchedule, BusinessDayConvention floatRoll, uint fixingDays, IborIndex floatIndex, double fixedRate, double baseCPI, DayCounter fixedDayCount, Schedule fixedSchedule, BusinessDayConvention fixedRoll, Period observationLag, ZeroInflationIndex fixedIndex) : this(NQuantLibcPINVOKE.new_CPISwap__SWIG_2((int)type, nominal, subtractInflationNominal, spread, DayCounter.getCPtr(floatDayCount), Schedule.getCPtr(floatSchedule), (int)floatRoll, fixingDays, IborIndex.getCPtr(floatIndex), fixedRate, baseCPI, DayCounter.getCPtr(fixedDayCount), Schedule.getCPtr(fixedSchedule), (int)fixedRoll, Period.getCPtr(observationLag), ZeroInflationIndex.getCPtr(fixedIndex)), true) {
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
  }

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

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

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

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

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

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

}

}
