Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
modeldata.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
20
21using std::string;
22using std::vector;
23
24namespace ore {
25namespace data {
26
28 : calibrationType_(CalibrationType::None) {}
29
31 const vector<CalibrationBasket>& calibrationBaskets)
32 : calibrationType_(calibrationType), calibrationBaskets_(calibrationBaskets) {}
33
35 return calibrationType_;
36}
37
38const vector<CalibrationBasket>& ModelData::calibrationBaskets() const {
40}
41
43
44 calibrationType_ = parseCalibrationType(XMLUtils::getChildValue(node, "CalibrationType", true));
45
46 if (XMLNode* n = XMLUtils::getChildNode(node, "CalibrationBaskets")) {
47 for (XMLNode* cn = XMLUtils::getChildNode(n, "CalibrationBasket"); cn;
48 cn = XMLUtils::getNextSibling(cn, "CalibrationBasket")) {
50 cb.fromXML(cn);
51 calibrationBaskets_.push_back(cb);
52 }
53 }
54}
55
56void ModelData::append(XMLDocument& doc, XMLNode* node) const {
57
58 XMLUtils::addGenericChild(doc, node, "CalibrationType", calibrationType_);
59
60 if (!calibrationBaskets_.empty()) {
61 XMLNode* cbsNode = doc.allocNode("CalibrationBaskets");
62 for (const CalibrationBasket& cb : calibrationBaskets_) {
63 XMLUtils::appendNode(cbsNode, cb.toXML(doc));
64 }
65 XMLUtils::appendNode(node, cbsNode);
66 }
67}
68
69}
70}
void fromXML(XMLNode *node) override
CalibrationType calibrationType_
Definition: modeldata.hpp:59
CalibrationType calibrationType() const
Definition: modeldata.cpp:34
virtual void append(XMLDocument &doc, XMLNode *node) const
Method used by toXML in derived classes to add the members here to a node.
Definition: modeldata.cpp:56
void fromXML(XMLNode *node) override
Definition: modeldata.cpp:42
std::vector< CalibrationBasket > calibrationBaskets_
Definition: modeldata.hpp:66
ModelData()
Default constructor.
Definition: modeldata.cpp:27
const std::vector< CalibrationBasket > & calibrationBaskets() const
Definition: modeldata.cpp:38
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static void addGenericChild(XMLDocument &doc, XMLNode *n, const char *name, const T &value)
Adds <Name>p1,p2,p3</Name>
Definition: xmlutils.hpp:137
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
Definition: xmlutils.cpp:484
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
@ data
Definition: log.hpp:77
base class for holding model data
CalibrationType
Supported calibration types.
Definition: irmodeldata.hpp:46
CalibrationType parseCalibrationType(const string &s)
Convert calibration type string into enumerated class value.
Definition: irmodeldata.cpp:47
Serializable Credit Default Swap.
Definition: namespaces.docs:23