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

Base class for indices - lets see if we can keep this, they might diverge too much... More...

#include <ored/portfolio/referencedata.hpp>

+ Inheritance diagram for IndexReferenceDatum:
+ Collaboration diagram for IndexReferenceDatum:

Public Member Functions

void fromXML (XMLNode *node) override
 
XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
const map< string, double > underlyings () const
 
void setUnderlyings (const std::map< string, double > &data)
 
void addUnderlying (const string &name, double weight)
 
- Public Member Functions inherited from ReferenceDatum
 ReferenceDatum ()
 Default Constructor. More...
 
 ReferenceDatum (const std::string &type, const std::string &id)
 Base class constructor. More...
 
 ReferenceDatum (const std::string &type, const std::string &id, const QuantLib::Date &validFrom)
 Base class constructor. More...
 
void setType (const string &type)
 setters More...
 
void setId (const string &id)
 
void setValidFrom (const QuantLib::Date &validFrom)
 
const std::string & type () const
 getters More...
 
const std::string & id () const
 
const QuantLib::Date & validFrom () const
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
- 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...
 

Protected Member Functions

 IndexReferenceDatum ()
 
 IndexReferenceDatum (const string &type, const string &id)
 
 IndexReferenceDatum (const string &type, const string &id, const QuantLib::Date &validFrom)
 

Private Attributes

std::map< std::string, double > data_
 

Detailed Description

Base class for indices - lets see if we can keep this, they might diverge too much...

Definition at line 226 of file referencedata.hpp.

Constructor & Destructor Documentation

◆ IndexReferenceDatum() [1/3]

IndexReferenceDatum ( )
protected

Definition at line 228 of file referencedata.hpp.

228{}

◆ IndexReferenceDatum() [2/3]

IndexReferenceDatum ( const string &  type,
const string &  id 
)
protected

Definition at line 229 of file referencedata.hpp.

229: ReferenceDatum(type, id) {}
const std::string & type() const
getters
ReferenceDatum()
Default Constructor.

◆ IndexReferenceDatum() [3/3]

IndexReferenceDatum ( const string &  type,
const string &  id,
const QuantLib::Date &  validFrom 
)
protected

Definition at line 230 of file referencedata.hpp.

231 : ReferenceDatum(type, id, validFrom) {}
const QuantLib::Date & validFrom() const

Member Function Documentation

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Reimplemented from ReferenceDatum.

Definition at line 255 of file referencedata.cpp.

255 {
257 XMLNode* innerNode = XMLUtils::getChildNode(node, type() + "ReferenceData");
258 QL_REQUIRE(innerNode, "No " + type() + "ReferenceData node");
259
260 // clear map
261 data_.clear();
262
263 // and populate it...
264 for (XMLNode* child = XMLUtils::getChildNode(innerNode, "Underlying"); child;
265 child = XMLUtils::getNextSibling(child, "Underlying")) {
266 string name = XMLUtils::getChildValue(child, "Name", true);
267 double weight = XMLUtils::getChildValueAsDouble(child, "Weight", true);
268 addUnderlying(name, weight);
269 }
270}
std::map< std::string, double > data_
void addUnderlying(const string &name, double weight)
void fromXML(XMLNode *node) override
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
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
Definition: xmlutils.cpp:484
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
string name
+ Here is the call graph for this function:

◆ toXML()

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

Reimplemented from ReferenceDatum.

Definition at line 272 of file referencedata.cpp.

272 {
273 XMLNode* node = ReferenceDatum::toXML(doc);
274 XMLNode* rdNode = XMLUtils::addChild(doc, node, type() + "ReferenceData");
275
276 for (auto d : data_) {
277 XMLNode* underlyingNode = XMLUtils::addChild(doc, rdNode, "Underlying");
278 XMLUtils::addChild(doc, underlyingNode, "Name", d.first);
279 XMLUtils::addChild(doc, underlyingNode, "Weight", d.second);
280 }
281
282 return node;
283}
XMLNode * toXML(ore::data::XMLDocument &doc) const override
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
+ Here is the call graph for this function:

◆ underlyings()

const map< string, double > underlyings ( ) const

Definition at line 238 of file referencedata.hpp.

238{ return data_; }

◆ setUnderlyings()

void setUnderlyings ( const std::map< string, double > &  data)

Definition at line 240 of file referencedata.hpp.

240{ data_ = data; }
@ data
Definition: log.hpp:77

◆ addUnderlying()

void addUnderlying ( const string &  name,
double  weight 
)

Definition at line 242 of file referencedata.hpp.

242{ data_[name]+=weight; }
+ Here is the caller graph for this function:

Member Data Documentation

◆ data_

std::map<std::string, double> data_
private

Definition at line 245 of file referencedata.hpp.