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

#include <ored/portfolio/underlying.hpp>

+ Inheritance diagram for UnderlyingBuilder:
+ Collaboration diagram for UnderlyingBuilder:

Public Member Functions

 UnderlyingBuilder (const std::string &nodeName="Underlying", const std::string &basicUnderlyingNodeName="Name")
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
const QuantLib::ext::shared_ptr< Underlying > & underlying ()
 
- 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

const std::string nodeName_
 
const std::string basicUnderlyingNodeName_
 
QuantLib::ext::shared_ptr< Underlyingunderlying_
 

Detailed Description

Definition at line 258 of file underlying.hpp.

Constructor & Destructor Documentation

◆ UnderlyingBuilder()

UnderlyingBuilder ( const std::string &  nodeName = "Underlying",
const std::string &  basicUnderlyingNodeName = "Name" 
)
explicit

Definition at line 260 of file underlying.hpp.

262 : nodeName_(nodeName), basicUnderlyingNodeName_(basicUnderlyingNodeName) {}
const std::string nodeName_
Definition: underlying.hpp:269
const std::string basicUnderlyingNodeName_
Definition: underlying.hpp:269

Member Function Documentation

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 305 of file underlying.cpp.

305 {
307 underlying_ = QuantLib::ext::make_shared<BasicUnderlying>();
308 } else if (XMLUtils::getNodeName(node) == nodeName_) {
309 string type = XMLUtils::getChildValue(node, "Type", true);
310 if (type == "Equity")
311 underlying_ = QuantLib::ext::make_shared<EquityUnderlying>();
312 else if (type == "Commodity")
313 underlying_ = QuantLib::ext::make_shared<CommodityUnderlying>();
314 else if (type == "FX")
315 underlying_ = QuantLib::ext::make_shared<FXUnderlying>();
316 else if (type == "InterestRate")
317 underlying_ = QuantLib::ext::make_shared<InterestRateUnderlying>();
318 else if (type == "Inflation")
319 underlying_ = QuantLib::ext::make_shared<InflationUnderlying>();
320 else if (type == "Credit")
321 underlying_ = QuantLib::ext::make_shared<CreditUnderlying>();
322 else if (type == "Bond")
323 underlying_ = QuantLib::ext::make_shared<BondUnderlying>();
324 else {
325 QL_FAIL("Unknown Underlying type " << type);
326 }
327 } else {
328 QL_FAIL("Need either a " << basicUnderlyingNodeName_ << " or " << nodeName_ << " node for Underlying.");
329 }
330 QL_REQUIRE(underlying_ != nullptr, "UnderlyingBuilder: underlying_ is null, this is unexpected");
331 underlying_->setNodeName(nodeName_);
332 underlying_->setBasicUnderlyingNodeName(basicUnderlyingNodeName_);
333 underlying_->fromXML(node);
334}
QuantLib::ext::shared_ptr< Underlying > underlying_
Definition: underlying.hpp:270
static string getNodeName(XMLNode *n)
Get and set a node's name.
Definition: xmlutils.cpp:473
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
+ 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 336 of file underlying.cpp.

336{ return NULL; }

◆ underlying()

const QuantLib::ext::shared_ptr< Underlying > & underlying ( )

Definition at line 266 of file underlying.hpp.

266{ return underlying_; };
+ Here is the caller graph for this function:

Member Data Documentation

◆ nodeName_

const std::string nodeName_
private

Definition at line 269 of file underlying.hpp.

◆ basicUnderlyingNodeName_

const std::string basicUnderlyingNodeName_
private

Definition at line 269 of file underlying.hpp.

◆ underlying_

QuantLib::ext::shared_ptr<Underlying> underlying_
private

Definition at line 270 of file underlying.hpp.