Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
EngineData Class Reference

Pricing engine description. More...

#include <ored/portfolio/enginedata.hpp>

+ Inheritance diagram for EngineData:
+ Collaboration diagram for EngineData:

Public Member Functions

 EngineData ()
 Default constructor. More...
 
Inspectors
bool hasProduct (const string &productName)
 
const string & model (const string &productName) const
 
const map< string, string > & modelParameters (const string &productName) const
 
const string & engine (const string &productName) const
 
const map< string, string > & engineParameters (const string &productName) const
 
const std::map< std::string, std::string > & globalParameters () const
 
vector< string > products () const
 Return all products. More...
 
Setters
string & model (const string &productName)
 
map< string, string > & modelParameters (const string &productName)
 
string & engine (const string &productName)
 
map< string, string > & engineParameters (const string &productName)
 
std::map< std::string, std::string > & globalParameters ()
 
void clear ()
 Clear all data. More...
 
- Public Member Functions inherited from XMLSerializable
virtual ~XMLSerializable ()
 
virtual void fromXML (XMLNode *node)=0
 
virtual XMLNodetoXML (XMLDocument &doc) const =0
 
void fromFile (const std::string &filename)
 
void toFile (const std::string &filename) const
 
void fromXMLString (const std::string &xml)
 Parse from XML string. More...
 
std::string toXMLString () const
 Parse from XML string. More...
 

Serialisation

map< string, string > model_
 
map< string, map< string, string > > modelParams_
 
map< string, string > engine_
 
map< string, map< string, string > > engineParams_
 
std::map< std::string, std::string > globalParams_
 
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (XMLDocument &doc) const override
 

Detailed Description

Pricing engine description.

Definition at line 41 of file enginedata.hpp.

Constructor & Destructor Documentation

◆ EngineData()

Default constructor.

Definition at line 44 of file enginedata.hpp.

44{}

Member Function Documentation

◆ hasProduct()

bool hasProduct ( const string &  productName)

Definition at line 118 of file enginedata.cpp.

118{ return (model_.find(productName) != model_.end()); }
map< string, string > model_
Definition: enginedata.hpp:80

◆ model() [1/2]

const string & model ( const string &  productName) const

Definition at line 49 of file enginedata.hpp.

49{ return model_.at(productName); }
+ Here is the caller graph for this function:

◆ modelParameters() [1/2]

const map< string, string > & modelParameters ( const string &  productName) const

Definition at line 50 of file enginedata.hpp.

50{ return modelParams_.at(productName); }
map< string, map< string, string > > modelParams_
Definition: enginedata.hpp:81
+ Here is the caller graph for this function:

◆ engine() [1/2]

const string & engine ( const string &  productName) const

Definition at line 51 of file enginedata.hpp.

51{ return engine_.at(productName); }
map< string, string > engine_
Definition: enginedata.hpp:82
+ Here is the caller graph for this function:

◆ engineParameters() [1/2]

const map< string, string > & engineParameters ( const string &  productName) const

Definition at line 52 of file enginedata.hpp.

52 {
53 return engineParams_.at(productName);
54 }
map< string, map< string, string > > engineParams_
Definition: enginedata.hpp:83
+ Here is the caller graph for this function:

◆ globalParameters() [1/2]

const std::map< std::string, std::string > & globalParameters ( ) const

Definition at line 55 of file enginedata.hpp.

55{ return globalParams_; }
std::map< std::string, std::string > globalParams_
Definition: enginedata.hpp:84

◆ products()

vector< string > products ( ) const

Return all products.

Definition at line 120 of file enginedata.cpp.

120 {
121 vector<string> res;
122 for (auto it : model_)
123 res.push_back(it.first);
124 return res;
125}
+ Here is the caller graph for this function:

◆ model() [2/2]

string & model ( const string &  productName)

Definition at line 63 of file enginedata.hpp.

63{ return model_[productName]; }

◆ modelParameters() [2/2]

map< string, string > & modelParameters ( const string &  productName)

Definition at line 64 of file enginedata.hpp.

64{ return modelParams_[productName]; }

◆ engine() [2/2]

string & engine ( const string &  productName)

Definition at line 65 of file enginedata.hpp.

65{ return engine_[productName]; }

◆ engineParameters() [2/2]

map< string, string > & engineParameters ( const string &  productName)

Definition at line 66 of file enginedata.hpp.

66{ return engineParams_[productName]; }

◆ globalParameters() [2/2]

std::map< std::string, std::string > & globalParameters ( )

Definition at line 67 of file enginedata.hpp.

67{ return globalParams_; }

◆ clear()

void clear ( )

Clear all data.

Definition at line 28 of file enginedata.cpp.

28 {
29 modelParams_.clear();
30 model_.clear();
31 engine_.clear();
32 engineParams_.clear();
33 globalParams_.clear();
34}

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 36 of file enginedata.cpp.

36 {
37 XMLUtils::checkNode(root, "PricingEngines");
38
39 // Get global parameters if there are any
40 if (XMLNode* node = XMLUtils::getChildNode(root, "GlobalParameters")) {
41 DLOG("Processing the GlobalParameters node");
42 globalParams_ = XMLUtils::getChildrenAttributesAndValues(node, "Parameter", "name", false);
43 }
44
45 for (XMLNode* node = XMLUtils::getChildNode(root, "Product"); node;
46 node = XMLUtils::getNextSibling(node, "Product")) {
47 std::string productName = XMLUtils::getAttribute(node, "type");
48
49 model_[productName] = XMLUtils::getChildValue(node, "Model");
50 DLOG("EngineData product=" << productName << " model=" << model_[productName]);
51
52 XMLNode* modelParams = XMLUtils::getChildNode(node, "ModelParameters");
53 map<string, string> modelParamMap;
54 for (XMLNode* paramNode = XMLUtils::getChildNode(modelParams, "Parameter"); paramNode;
55 paramNode = XMLUtils::getNextSibling(paramNode, "Parameter")) {
56 string paramName = XMLUtils::getAttribute(paramNode, "name");
57 string paramValue = XMLUtils::getNodeValue(paramNode);
58 modelParamMap[paramName] = paramValue;
59 DLOG("EngineData product=" << productName << " paramName=" << paramName << " paramValue=" << paramValue);
60 }
61 modelParams_[productName] = modelParamMap;
62
63 engine_[productName] = XMLUtils::getChildValue(node, "Engine");
64 DLOG("EngineData product=" << productName << " engine=" << engine_[productName]);
65
66 XMLNode* engineParams = XMLUtils::getChildNode(node, "EngineParameters");
67 map<string, string> engineParamMap;
68 for (XMLNode* paramNode = XMLUtils::getChildNode(engineParams, "Parameter"); paramNode;
69 paramNode = XMLUtils::getNextSibling(paramNode, "Parameter")) {
70 string paramName = XMLUtils::getAttribute(paramNode, "name");
71 string paramValue = XMLUtils::getNodeValue(paramNode);
72 engineParamMap[paramName] = paramValue;
73 DLOG("EngineData product=" << productName << " paramName=" << paramName << " paramValue=" << paramValue);
74 }
75 engineParams_[productName] = engineParamMap;
76 }
77}
static string getAttribute(XMLNode *node, const string &attrName)
Definition: xmlutils.cpp:419
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static map< string, string > getChildrenAttributesAndValues(XMLNode *parent, const string &names, const string &attributeName, bool mandatory=false)
Definition: xmlutils.cpp:365
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 string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
Definition: xmlutils.cpp:484
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 79 of file enginedata.cpp.

79 {
80
81 XMLNode* pricingEnginesNode = doc.allocNode("PricingEngines");
82
83 // Add global parameters to XML
84 XMLNode* globalParamsNode = XMLUtils::addChild(doc, pricingEnginesNode, "GlobalParameters");
85 for (const auto& kv : globalParams_) {
86 XMLNode* n = doc.allocNode("Parameter", kv.second);
87 XMLUtils::addAttribute(doc, n, "name", kv.first);
88 XMLUtils::appendNode(globalParamsNode, n);
89 TLOG("Added pair [" << kv.first << "," << kv.second << "] to the GlobalParameters node");
90 }
91
92 for (auto modelIterator = model_.begin(); modelIterator != model_.end(); modelIterator++) {
93
94 XMLNode* productNode = XMLUtils::addChild(doc, pricingEnginesNode, "Product");
95 XMLUtils::addAttribute(doc, productNode, "type", modelIterator->first);
96 auto engineIterator = engine_.find(modelIterator->first);
97 XMLUtils::addChild(doc, productNode, "Model", modelIterator->second);
98 XMLUtils::addChild(doc, productNode, "Engine", engineIterator->second);
99 XMLNode* modelParametersNode = XMLUtils::addChild(doc, productNode, "ModelParameters");
100 for (auto modelParamsIterator = modelParams_.find(modelIterator->first)->second.begin();
101 modelParamsIterator != modelParams_.find(modelIterator->first)->second.end(); modelParamsIterator++) {
102 XMLNode* parameterNode = doc.allocNode("Parameter", modelParamsIterator->second);
103 XMLUtils::appendNode(modelParametersNode, parameterNode);
104 XMLUtils::addAttribute(doc, parameterNode, "name", modelParamsIterator->first);
105 }
106 XMLNode* engineParametersNode = XMLUtils::addChild(doc, productNode, "EngineParameters");
107 for (auto engineParamsIterator = engineParams_.find(modelIterator->first)->second.begin();
108 engineParamsIterator != engineParams_.find(modelIterator->first)->second.end(); engineParamsIterator++) {
109 XMLNode* parameterNode = doc.allocNode("Parameter", engineParamsIterator->second);
110 XMLUtils::appendNode(engineParametersNode, parameterNode);
111 XMLUtils::addAttribute(doc, parameterNode, "name", engineParamsIterator->first);
112 }
113 }
114 return pricingEnginesNode;
115}
static void addAttribute(XMLDocument &doc, XMLNode *node, const string &attrName, const string &attrValue)
Definition: xmlutils.cpp:412
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
#define TLOG(text)
Logging Macro (Level = Data)
Definition: log.hpp:556
+ Here is the call graph for this function:

Member Data Documentation

◆ model_

map<string, string> model_
private

Definition at line 80 of file enginedata.hpp.

◆ modelParams_

map<string, map<string, string> > modelParams_
private

Definition at line 81 of file enginedata.hpp.

◆ engine_

map<string, string> engine_
private

Definition at line 82 of file enginedata.hpp.

◆ engineParams_

map<string, map<string, string> > engineParams_
private

Definition at line 83 of file enginedata.hpp.

◆ globalParams_

std::map<std::string, std::string> globalParams_
private

Definition at line 84 of file enginedata.hpp.