From 8baef999da28d8a51734994219514e20fe92a2d2 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Wed, 22 Feb 2017 16:38:02 -0500 Subject: switch to C++ --- cpp_layer/curve.hpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 cpp_layer/curve.hpp (limited to 'cpp_layer/curve.hpp') diff --git a/cpp_layer/curve.hpp b/cpp_layer/curve.hpp new file mode 100644 index 0000000..8e54216 --- /dev/null +++ b/cpp_layer/curve.hpp @@ -0,0 +1,42 @@ +#include +typedef long TDate; + +class CurveObject { +public: + CurveObject(TDate baseDate, std::vector dates, std::vector rates, + double basis, long dayCountConv) { + _ptr = JpmcdsMakeTCurve(baseDate, dates.data(), rates.data(), dates.size(), + basis, dayCountConv); + } + CurveObject(TCurve* ptr) { + _ptr = ptr; + } + CurveObject(const CurveObject& other) { + _ptr = JpmcdsCopyCurve(other._ptr); + } + CurveObject(CurveObject&& other) : _ptr(other._ptr) { + other._ptr = nullptr; + } + CurveObject& operator=(const CurveObject& other) { + if( this != &other) { + JpmcdsFreeTCurve(_ptr); + _ptr = JpmcdsCopyCurve(other._ptr); + } + return *this; + } + CurveObject& operator=(CurveObject&& other) { + if( this != &other) { + JpmcdsFreeTCurve(_ptr); + _ptr = other._ptr; + other._ptr = nullptr; + } + return *this; + } + ~CurveObject() { + if(_ptr != nullptr) { + JpmcdsFreeTCurve(_ptr); + } + } +private: + TCurve* _ptr; +}; -- cgit v1.2.3-70-g09d2