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

Serializable obejct holding barrier data. More...

#include <ored/portfolio/barrierdata.hpp>

+ Inheritance diagram for BarrierData:
+ Collaboration diagram for BarrierData:

Public Member Functions

 BarrierData ()
 Default constructor. More...
 
 BarrierData (std::string barrierType, std::vector< double > levels, double rebate, std::vector< ore::data::TradeBarrier > tradeBarriers, std::string style="")
 Constructor. More...
 
Inspectors
const std::string & type () const
 
double rebate () const
 
const std::string & rebateCurrency () const
 
const std::string & rebatePayTime () const
 
std::vector< ore::data::TradeBarrierlevels () const
 
const std::string & style () const
 
bool initialized () const
 
- 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

bool initialized_
 
std::string type_
 
std::vector< double > levels_
 
double rebate_
 
std::vector< ore::data::TradeBarriertradeBarriers_
 
std::string rebateCurrency_
 
std::string rebatePayTime_
 
std::string style_
 
virtual void fromXML (ore::data::XMLNode *node) override
 
virtual ore::data::XMLNodetoXML (ore::data::XMLDocument &doc) const override
 

Detailed Description

Serializable obejct holding barrier data.

Definition at line 34 of file barrierdata.hpp.

Constructor & Destructor Documentation

◆ BarrierData() [1/2]

Default constructor.

Definition at line 37 of file barrierdata.hpp.

◆ BarrierData() [2/2]

BarrierData ( std::string  barrierType,
std::vector< double >  levels,
double  rebate,
std::vector< ore::data::TradeBarrier tradeBarriers,
std::string  style = "" 
)

Constructor.

Definition at line 39 of file barrierdata.hpp.

41 : initialized_(true), type_(barrierType), levels_(levels), rebate_(rebate), tradeBarriers_(tradeBarriers),
42 style_(style) {}
double rebate() const
Definition: barrierdata.hpp:47
std::vector< double > levels_
Definition: barrierdata.hpp:64
std::vector< ore::data::TradeBarrier > tradeBarriers_
Definition: barrierdata.hpp:66
std::vector< ore::data::TradeBarrier > levels() const
Definition: barrierdata.hpp:50
const std::string & style() const
Definition: barrierdata.hpp:51

Member Function Documentation

◆ type()

const std::string & type ( ) const

Definition at line 46 of file barrierdata.hpp.

46{ return type_; }
+ Here is the caller graph for this function:

◆ rebate()

double rebate ( ) const

Definition at line 47 of file barrierdata.hpp.

47{ return rebate_; }
+ Here is the caller graph for this function:

◆ rebateCurrency()

const std::string & rebateCurrency ( ) const

Definition at line 48 of file barrierdata.hpp.

48{ return rebateCurrency_; }
std::string rebateCurrency_
Definition: barrierdata.hpp:67

◆ rebatePayTime()

const std::string & rebatePayTime ( ) const

Definition at line 49 of file barrierdata.hpp.

49{ return rebatePayTime_; }
std::string rebatePayTime_
Definition: barrierdata.hpp:68

◆ levels()

std::vector< ore::data::TradeBarrier > levels ( ) const

Definition at line 50 of file barrierdata.hpp.

50{ return tradeBarriers_; }
+ Here is the caller graph for this function:

◆ style()

const std::string & style ( ) const

Definition at line 51 of file barrierdata.hpp.

51{ return style_; }
+ Here is the caller graph for this function:

◆ initialized()

bool initialized ( ) const

Definition at line 52 of file barrierdata.hpp.

52{ return initialized_; }
+ Here is the caller graph for this function:

◆ fromXML()

void fromXML ( ore::data::XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 25 of file barrierdata.cpp.

25 {
26 XMLUtils::checkNode(node, "BarrierData");
27 type_ = XMLUtils::getChildValue(node, "Type", true);
28 style_ = XMLUtils::getChildValue(node, "Style", false);
29 XMLNode* levelData = XMLUtils::getChildNode(node, "LevelData");
30 if (levelData) {
31 vector<XMLNode*> lvls = XMLUtils::getChildrenNodes(levelData, "Level");
32 for (auto& n : lvls) {
33 TradeBarrier barrier;
34 barrier.fromXML(n);
35 tradeBarriers_.push_back(barrier);
36 levels_.push_back(XMLUtils::getChildValueAsDouble(n, "Value", true));
37 }
38 } else {
39 levels_ = XMLUtils::getChildrenValuesAsDoubles(node, "Levels", "Level");
40 for (Size i = 0; i < levels_.size(); i++)
41 tradeBarriers_.push_back(TradeBarrier(levels_[i], ""));
42 }
43 rebate_ = XMLUtils::getChildValueAsDouble(node, "Rebate", false);
44 rebateCurrency_ = XMLUtils::getChildValue(node, "RebateCurrency", false);
45 rebatePayTime_ = XMLUtils::getChildValue(node, "RebatePayTime", false);
46 initialized_ = true;
47}
static vector< Real > getChildrenValuesAsDoubles(XMLNode *node, const string &names, const string &name, bool mandatory=false)
Definition: xmlutils.cpp:319
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
Definition: xmlutils.cpp:428
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
Definition: xmlutils.cpp:286
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
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

XMLNode * toXML ( ore::data::XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 49 of file barrierdata.cpp.

49 {
50 XMLNode* node = doc.allocNode("BarrierData");
51 XMLUtils::addChild(doc, node, "Type", type_);
52 if (!style_.empty())
53 XMLUtils::addChild(doc, node, "Style", style_);
54 XMLUtils::addChild(doc, node, "Rebate", rebate_);
55 XMLUtils::addChildren(doc, node, "Levels", "Level", levels_);
56 if (!rebateCurrency_.empty())
57 XMLUtils::addChild(doc, node, "RebateCurrency", rebateCurrency_);
58 if (!rebatePayTime_.empty())
59 XMLUtils::addChild(doc, node, "RebatePayTime", rebatePayTime_);
60 return node;
61}
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static void addChildren(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values)
Definition: xmlutils.cpp:502
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ initialized_

bool initialized_
private

Definition at line 62 of file barrierdata.hpp.

◆ type_

std::string type_
private

Definition at line 63 of file barrierdata.hpp.

◆ levels_

std::vector<double> levels_
private

Definition at line 64 of file barrierdata.hpp.

◆ rebate_

double rebate_
private

Definition at line 65 of file barrierdata.hpp.

◆ tradeBarriers_

std::vector<ore::data::TradeBarrier> tradeBarriers_
private

Definition at line 66 of file barrierdata.hpp.

◆ rebateCurrency_

std::string rebateCurrency_
private

Definition at line 67 of file barrierdata.hpp.

◆ rebatePayTime_

std::string rebatePayTime_
private

Definition at line 68 of file barrierdata.hpp.

◆ style_

std::string style_
private

Definition at line 69 of file barrierdata.hpp.