summaryrefslogtreecommitdiffstats
path: root/cpp_layer/curve.hpp
blob: 8e54216edafc25f8aafb6ed3cf498919f1e99899 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <vector>
typedef long TDate;

class CurveObject {
public:
    CurveObject(TDate baseDate, std::vector<TDate> dates, std::vector<double> 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;
};