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

Base class for reference data. More...

#include <ored/portfolio/referencedata.hpp>

+ Inheritance diagram for ReferenceDatum:
+ Collaboration diagram for ReferenceDatum:

Public Member Functions

 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...
 

Private Attributes

std::string type_
 
std::string id_
 
QuantLib::Date validFrom_
 

Detailed Description

Base class for reference data.

Each reference datum object is a subclass of this base and has it's own accessor functions. Instances of ReferenceDatum can be gotten from the ReferenceDataManager below, and then cast up as required. Each instance should be uniquely identified by it's type (which defines it's subclass, e.g. "Bond" for BondReferenceDatum) and it's id, which is a string. Here it can be any string but in applications there can be a naming scheme like ISIN for Bonds.

Definition at line 47 of file referencedata.hpp.

Constructor & Destructor Documentation

◆ ReferenceDatum() [1/3]

Default Constructor.

Definition at line 50 of file referencedata.hpp.

50: validFrom_(QuantLib::Date::minDate()) {}

◆ ReferenceDatum() [2/3]

ReferenceDatum ( const std::string &  type,
const std::string &  id 
)

Base class constructor.

Definition at line 52 of file referencedata.hpp.

53 : type_(type), id_(id), validFrom_(QuantLib::Date::minDate()) {}
const std::string & type() const
getters

◆ ReferenceDatum() [3/3]

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

Base class constructor.

Definition at line 55 of file referencedata.hpp.

56 : type_(type), id_(id), validFrom_(validFrom) {}
const QuantLib::Date & validFrom() const

Member Function Documentation

◆ setType()

void setType ( const string &  type)

setters

Definition at line 59 of file referencedata.hpp.

59{ type_ = type; }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setId()

void setId ( const string &  id)

Definition at line 60 of file referencedata.hpp.

60{ id_ = id; }
const std::string & id() const
+ Here is the call graph for this function:

◆ setValidFrom()

void setValidFrom ( const QuantLib::Date &  validFrom)

Definition at line 61 of file referencedata.hpp.

+ Here is the call graph for this function:

◆ type()

const std::string & type ( ) const

getters

Definition at line 64 of file referencedata.hpp.

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

◆ id()

const std::string & id ( ) const

Definition at line 65 of file referencedata.hpp.

65{ return id_; }
+ Here is the caller graph for this function:

◆ validFrom()

const QuantLib::Date & validFrom ( ) const

Definition at line 66 of file referencedata.hpp.

66{ return validFrom_; }
+ Here is the caller graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Reimplemented in BondReferenceDatum, CreditIndexReferenceDatum, IndexReferenceDatum, CurrencyHedgedEquityIndexReferenceDatum, PortfolioBasketReferenceDatum, CreditReferenceDatum, EquityReferenceDatum, and BondBasketReferenceDatum.

Definition at line 31 of file referencedata.cpp.

31 {
32 XMLUtils::checkNode(node, "ReferenceDatum");
33 type_ = XMLUtils::getChildValue(node, "Type", true);
34 id_ = XMLUtils::getAttribute(node, "id");
35 std::string dateStr = XMLUtils::getAttribute(node, "validFrom");
36 if (!dateStr.empty()) {
37 validFrom_ = parseDate(dateStr);
38 } else {
39 validFrom_ = QuantLib::Date::minDate();
40 }
41}
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 string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
+ 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.

Reimplemented in BondReferenceDatum, CreditIndexReferenceDatum, IndexReferenceDatum, CurrencyHedgedEquityIndexReferenceDatum, PortfolioBasketReferenceDatum, CreditReferenceDatum, EquityReferenceDatum, and BondBasketReferenceDatum.

Definition at line 43 of file referencedata.cpp.

43 {
44 XMLNode* node = doc.allocNode("ReferenceDatum");
45 QL_REQUIRE(node, "Failed to create ReferenceDatum node");
46 XMLUtils::addAttribute(doc, node, "id", id_);
47 XMLUtils::addChild(doc, node, "Type", type_);
48 if (validFrom_ > QuantLib::Date::minDate()) {
49 XMLUtils::addAttribute(doc, node, "validFrom", to_string(validFrom_));
50 }
51 return node;
52}
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
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
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ type_

std::string type_
private

Definition at line 72 of file referencedata.hpp.

◆ id_

std::string id_
private

Definition at line 73 of file referencedata.hpp.

◆ validFrom_

QuantLib::Date validFrom_
private

Definition at line 74 of file referencedata.hpp.