summaryrefslogtreecommitdiffstats
path: root/cpp_layer
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2017-02-22 16:38:02 -0500
committerGuillaume Horel <guillaume.horel@gmail.com>2017-02-22 16:38:02 -0500
commit8baef999da28d8a51734994219514e20fe92a2d2 (patch)
treec3a1be6900fbc1036a2a887d43f10e4279a0591a /cpp_layer
parentc373a9512d9cecd9d94497f0637d763ce7cfe9e5 (diff)
downloadpyisda-cpp.tar.gz
switch to C++cpp
Diffstat (limited to 'cpp_layer')
-rw-r--r--cpp_layer/curve.hpp42
1 files changed, 42 insertions, 0 deletions
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 <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;
+};