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

Credit index reference data, contains a set of index constituents. More...

#include <ored/portfolio/referencedata.hpp>

+ Inheritance diagram for CreditIndexReferenceDatum:
+ Collaboration diagram for CreditIndexReferenceDatum:

Public Member Functions

 CreditIndexReferenceDatum ()
 
 CreditIndexReferenceDatum (const std::string &name)
 
 CreditIndexReferenceDatum (const string &id, const QuantLib::Date &validFrom)
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
void add (const CreditIndexConstituent &c)
 Add a constituent. The constituent is not added if already present. More...
 
const std::set< CreditIndexConstituent > & constituents () const
 Get all of the underlying constituents. More...
 
const std::string & indexFamily () const
 
void setIndexFamily (const std::string &indexFamily)
 
- 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...
 

Static Public Attributes

static constexpr const char * TYPE = "CreditIndex"
 

Private Attributes

std::set< CreditIndexConstituentconstituents_
 
std::string indexFamily_
 

Detailed Description

Credit index reference data, contains a set of index constituents.

Definition at line 184 of file referencedata.hpp.

Constructor & Destructor Documentation

◆ CreditIndexReferenceDatum() [1/3]

Definition at line 201 of file referencedata.cpp.

201{}

◆ CreditIndexReferenceDatum() [2/3]

CreditIndexReferenceDatum ( const std::string &  name)

Definition at line 203 of file referencedata.cpp.

static constexpr const char * TYPE
ReferenceDatum()
Default Constructor.
string name

◆ CreditIndexReferenceDatum() [3/3]

CreditIndexReferenceDatum ( const string &  id,
const QuantLib::Date &  validFrom 
)

Definition at line 205 of file referencedata.cpp.

const QuantLib::Date & validFrom() const

Member Function Documentation

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Reimplemented from ReferenceDatum.

Definition at line 208 of file referencedata.cpp.

208 {
209
211
212 XMLNode* cird = XMLUtils::getChildNode(node, "CreditIndexReferenceData");
213 QL_REQUIRE(cird, "Expected a CreditIndexReferenceData node.");
214
215 indexFamily_ = XMLUtils::getChildValue(cird, "IndexFamily", false);
216
217 constituents_.clear();
218
219 for (XMLNode* child = XMLUtils::getChildNode(cird, "Underlying"); child;
220 child = XMLUtils::getNextSibling(child, "Underlying")) {
221 CreditIndexConstituent c;
222 c.fromXML(child);
223 add(c);
224 }
225}
std::set< CreditIndexConstituent > constituents_
void add(const CreditIndexConstituent &c)
Add a constituent. The constituent is not added if already present.
void fromXML(XMLNode *node) override
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
+ Here is the call graph for this function:

◆ toXML()

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

Reimplemented from ReferenceDatum.

Definition at line 227 of file referencedata.cpp.

227 {
228
229 XMLNode* node = ReferenceDatum::toXML(doc);
230 XMLNode* cird = XMLUtils::addChild(doc, node, "CreditIndexReferenceData");
231
232 XMLUtils::addChild(doc, cird, "IndexFamily", indexFamily_);
233
234 for (auto c : constituents_) {
235 auto cNode = c.toXML(doc);
236 XMLUtils::appendNode(cird, cNode);
237 }
238
239 return node;
240}
XMLNode * toXML(ore::data::XMLDocument &doc) const override
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
+ Here is the call graph for this function:

◆ add()

void add ( const CreditIndexConstituent c)

Add a constituent. The constituent is not added if already present.

Definition at line 242 of file referencedata.cpp.

242 {
243 auto it = constituents_.find(c);
244 if (it != constituents_.end()) {
245 DLOG("Constituent " << c.name() << " not added to credit index " << id() << " because already present.");
246 } else {
247 constituents_.insert(c);
248 DLOG("Constituent " << c.name() << " added to credit index " << id() << ".");
249 }
250}
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ constituents()

const set< CreditIndexConstituent > & constituents ( ) const

Get all of the underlying constituents.

Definition at line 252 of file referencedata.cpp.

252{ return constituents_; }

◆ indexFamily()

const std::string & indexFamily ( ) const

Definition at line 203 of file referencedata.hpp.

203{ return indexFamily_; }
+ Here is the caller graph for this function:

◆ setIndexFamily()

void setIndexFamily ( const std::string &  indexFamily)

Definition at line 205 of file referencedata.hpp.

const std::string & indexFamily() const
+ Here is the call graph for this function:

Member Data Documentation

◆ TYPE

constexpr const char* TYPE = "CreditIndex"
staticconstexpr

Definition at line 186 of file referencedata.hpp.

◆ constituents_

std::set<CreditIndexConstituent> constituents_
private

Definition at line 208 of file referencedata.hpp.

◆ indexFamily_

std::string indexFamily_
private

Definition at line 209 of file referencedata.hpp.