Skip to content

Commit b02996f

Browse files
pcaspersjenkins
authored andcommitted
QPR-11568 move calibration instruments to init function
1 parent 80d68d5 commit b02996f

8 files changed

Lines changed: 12 additions & 45 deletions

File tree

OREAnalytics/orea/app/initbuilders.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
#include <orea/app/initbuilders.hpp>
2020

21+
#include <ored/model/calibrationinstrumentfactory.hpp>
22+
#include <ored/model/calibrationinstruments/cpicapfloor.hpp>
23+
#include <ored/model/calibrationinstruments/yoycapfloor.hpp>
24+
#include <ored/model/calibrationinstruments/yoyswap.hpp>
2125
#include <ored/portfolio/commoditylegdata.hpp>
2226
#include <ored/portfolio/durationadjustedcmslegdata.hpp>
2327
#include <ored/portfolio/equityfxlegdata.hpp>
@@ -30,6 +34,10 @@
3034
#define REG_LEGDATA(NAME, CLASS) \
3135
ore::data::LegDataFactory::instance().addBuilder(NAME, &ore::data::createLegData<CLASS>);
3236

37+
#define REG_CALIBRATION_INSTR(NAME, CLASS) \
38+
ore::data::CalibrationInstrumentFactory::instance().addBuilder(NAME, \
39+
&ore::data::createCalibrationInstrument<CLASS>);
40+
3341
namespace ore::analytics {
3442

3543
void initBuilders() {
@@ -60,6 +68,10 @@ void initBuilders() {
6068
REG_LEGDATA("CommodityFloating", ore::data::CommodityFloatingLegData)
6169
REG_LEGDATA("DurationAdjustedCMS", ore::data::DurationAdjustedCmsLegData)
6270
REG_LEGDATA("EquityMargin", ore::data::EquityMarginLegData)
71+
72+
REG_CALIBRATION_INSTR("CpiCapFloor", ore::data::CpiCapFloor);
73+
REG_CALIBRATION_INSTR("YoYCapFloor", ore::data::YoYCapFloor);
74+
REG_CALIBRATION_INSTR("YoYSwap", ore::data::YoYSwap);
6375
}
6476

6577
} // namespace ore::analytics

OREData/ored/model/calibrationinstrumentfactory.hpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -95,38 +95,5 @@ class CalibrationInstrumentFactory
9595
map_type map_;
9696
};
9797

98-
/*! Calibration instrument registration class
99-
100-
This class is used in any class derived from \c CalibrationInstrument to register itself with the
101-
\c CalibrationInstrumentFactory so that it can be built via a call to
102-
<code>CalibrationInstrumentFactory::instance().build(const std::string& instrumentType)</code>.
103-
104-
As a concrete example, a \c CpiCapFloor class derived from \c CalibrationInstrument should have the following form
105-
in order to register it with the \c CalibrationInstrumentFactory:
106-
107-
In cpicapfloor.hpp
108-
\code{.cpp}
109-
class CpiCapFloor : public CalibrationInstrument {
110-
public:
111-
private:
112-
static CalibrationInstrumentRegister<CpiCapFloor> reg_;
113-
}
114-
\endcode
115-
116-
In cpicapfloor.cpp
117-
\code{.cpp}
118-
CalibrationInstrumentRegister<CpiCapFloor> CpiCapFloor::reg_("CpiCapFloor");
119-
\endcode
120-
121-
\ingroup models
122-
*/
123-
template <class T> struct CalibrationInstrumentRegister {
124-
public:
125-
CalibrationInstrumentRegister(const std::string& instrumentType) {
126-
CalibrationInstrumentFactory::instance().addBuilder(
127-
instrumentType, &createCalibrationInstrument<T>);
128-
}
129-
};
130-
13198
}
13299
}

OREData/ored/model/calibrationinstruments/cpicapfloor.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ using QuantLib::Period;
2727
namespace ore {
2828
namespace data {
2929

30-
CalibrationInstrumentRegister<CpiCapFloor> CpiCapFloor::reg_("CpiCapFloor");
31-
3230
CpiCapFloor::CpiCapFloor() : CalibrationInstrument("CpiCapFloor"), type_(CapFloor::Floor) {}
3331

3432
CpiCapFloor::CpiCapFloor(CapFloor::Type type,

OREData/ored/model/calibrationinstruments/cpicapfloor.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ class CpiCapFloor : public CalibrationInstrument {
6464
QuantLib::CapFloor::Type type_;
6565
boost::variant<QuantLib::Date, QuantLib::Period> maturity_;
6666
boost::shared_ptr<BaseStrike> strike_;
67-
68-
static CalibrationInstrumentRegister<CpiCapFloor> reg_;
6967
};
7068

7169
} // namespace data

OREData/ored/model/calibrationinstruments/yoycapfloor.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ using QuantLib::YoYInflationCapFloor;
2626
namespace ore {
2727
namespace data {
2828

29-
CalibrationInstrumentRegister<YoYCapFloor> YoYCapFloor::reg_("YoYCapFloor");
30-
3129
YoYCapFloor::YoYCapFloor()
3230
: CalibrationInstrument("YoYCapFloor"), type_(YoYInflationCapFloor::Floor) {}
3331

OREData/ored/model/calibrationinstruments/yoycapfloor.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ class YoYCapFloor : public CalibrationInstrument {
6161
QuantLib::YoYInflationCapFloor::Type type_;
6262
QuantLib::Period tenor_;
6363
boost::shared_ptr<BaseStrike> strike_;
64-
65-
static CalibrationInstrumentRegister<YoYCapFloor> reg_;
6664
};
6765

6866
}

OREData/ored/model/calibrationinstruments/yoyswap.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ using QuantLib::Period;
2525
namespace ore {
2626
namespace data {
2727

28-
CalibrationInstrumentRegister<YoYSwap> YoYSwap::reg_("YoYSwap");
29-
3028
YoYSwap::YoYSwap() : CalibrationInstrument("YoYSwap") {}
3129

3230
YoYSwap::YoYSwap(const Period& tenor)

OREData/ored/model/calibrationinstruments/yoyswap.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ class YoYSwap : public CalibrationInstrument {
5353

5454
private:
5555
QuantLib::Period tenor_;
56-
57-
static CalibrationInstrumentRegister<YoYSwap> reg_;
5856
};
5957

6058
}

0 commit comments

Comments
 (0)