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

Serializable Commodity Position Data. More...

#include <ored/portfolio/commodityposition.hpp>

+ Inheritance diagram for CommodityPositionData:
+ Collaboration diagram for CommodityPositionData:

Public Member Functions

 CommodityPositionData ()
 
 CommodityPositionData (const Real quantity, const std::vector< CommodityUnderlying > &underlyings)
 
Real quantity () const
 
const std::vector< CommodityUnderlying > & underlyings () const
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (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

Real quantity_ = QuantLib::Null<Real>()
 
std::vector< CommodityUnderlyingunderlyings_
 

Detailed Description

Serializable Commodity Position Data.

Definition at line 34 of file commodityposition.hpp.

Constructor & Destructor Documentation

◆ CommodityPositionData() [1/2]

Definition at line 36 of file commodityposition.hpp.

36{}

◆ CommodityPositionData() [2/2]

CommodityPositionData ( const Real  quantity,
const std::vector< CommodityUnderlying > &  underlyings 
)

Definition at line 37 of file commodityposition.hpp.

const std::vector< CommodityUnderlying > & underlyings() const
std::vector< CommodityUnderlying > underlyings_

Member Function Documentation

◆ quantity()

Real quantity ( ) const

Definition at line 40 of file commodityposition.hpp.

40{ return quantity_; }
+ Here is the caller graph for this function:

◆ underlyings()

const std::vector< CommodityUnderlying > & underlyings ( ) const

Definition at line 41 of file commodityposition.hpp.

41{ return underlyings_; }
+ Here is the caller graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 27 of file commodityposition.cpp.

27 {
28 XMLUtils::checkNode(node, "CommodityPositionData");
29 quantity_ = XMLUtils::getChildValueAsDouble(node, "Quantity", true);
30 auto c = XMLUtils::getChildrenNodes(node, "Underlying");
31 underlyings_.clear();
32 for (auto const n : c) {
33 underlyings_.push_back(CommodityUnderlying());
34 underlyings_.back().fromXML(n);
35 }
36}
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 38 of file commodityposition.cpp.

38 {
39 XMLNode* n = doc.allocNode("CommodityPositionData");
40 XMLUtils::addChild(doc, n, "Quantity", quantity_);
41 for (auto& u : underlyings_) {
42 XMLUtils::appendNode(n, u.toXML(doc));
43 }
44 return n;
45}
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
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:

Member Data Documentation

◆ quantity_

Real quantity_ = QuantLib::Null<Real>()
private

Definition at line 47 of file commodityposition.hpp.

◆ underlyings_

std::vector<CommodityUnderlying> underlyings_
private

Definition at line 48 of file commodityposition.hpp.