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

#include <ored/portfolio/scriptedtrade.hpp>

+ Inheritance diagram for ScriptedTradeEventData:
+ Collaboration diagram for ScriptedTradeEventData:

Public Types

enum class  Type { Value , Array , Derived }
 

Public Member Functions

 ScriptedTradeEventData ()
 
 ScriptedTradeEventData (const std::string &name, const std::string &date)
 
 ScriptedTradeEventData (const std::string &name, const ScheduleData &schedule)
 
 ScriptedTradeEventData (const std::string &name, const std::string &baseSchedule, const std::string &shift, const std::string &calendar, const std::string &convention)
 
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
Type type () const
 
const std::string & name () const
 
const std::string & value () const
 
const ScheduleDataschedule () const
 
const std::string & baseSchedule () const
 
const std::string & shift () const
 
const std::string & calendar () const
 
const std::string & convention () const
 
const bool hasData ()
 
- 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

Type type_
 
std::string name_
 
std::string value_
 
ScheduleData schedule_
 
std::string baseSchedule_
 
std::string shift_
 
std::string calendar_
 
std::string convention_
 

Detailed Description

Definition at line 33 of file scriptedtrade.hpp.

Member Enumeration Documentation

◆ Type

enum class Type
strong

Constructor & Destructor Documentation

◆ ScriptedTradeEventData() [1/4]

Definition at line 37 of file scriptedtrade.hpp.

◆ ScriptedTradeEventData() [2/4]

ScriptedTradeEventData ( const std::string &  name,
const std::string &  date 
)

Definition at line 39 of file scriptedtrade.hpp.

◆ ScriptedTradeEventData() [3/4]

ScriptedTradeEventData ( const std::string &  name,
const ScheduleData schedule 
)

Definition at line 42 of file scriptedtrade.hpp.

◆ ScriptedTradeEventData() [4/4]

ScriptedTradeEventData ( const std::string &  name,
const std::string &  baseSchedule,
const std::string &  shift,
const std::string &  calendar,
const std::string &  convention 
)

Member Function Documentation

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 417 of file scriptedtrade.cpp.

417 {
418 XMLUtils::checkNode(node, "Event");
419 name_ = XMLUtils::getChildValue(node, "Name", true);
420 if (XMLNode* v = XMLUtils::getChildNode(node, "Value")) {
423 } else if (XMLNode* v = XMLUtils::getChildNode(node, "ScheduleData")) {
426 } else if (XMLNode* v = XMLUtils::getChildNode(node, "DerivedSchedule")) {
428 baseSchedule_ = XMLUtils::getChildValue(v, "BaseSchedule", true);
429 shift_ = XMLUtils::getChildValue(v, "Shift", true);
430 calendar_ = XMLUtils::getChildValue(v, "Calendar", true);
431 convention_ = XMLUtils::getChildValue(v, "Convention", true);
432 } else {
433 QL_FAIL("Expected Value or ScheduleData node");
434 }
435}
virtual void fromXML(XMLNode *node) override
Definition: schedule.cpp:179
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
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
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

Implements XMLSerializable.

Definition at line 437 of file scriptedtrade.cpp.

437 {
438 XMLNode* n = doc.allocNode("Event");
439 XMLUtils::addChild(doc, n, "Name", name_);
440 if (type_ == Type::Value) {
441 XMLUtils::addChild(doc, n, "Value", value_);
442 } else if (type_ == Type::Array) {
444 } else if (type_ == Type::Derived) {
445 XMLNode* d = doc.allocNode("DerivedSchedule");
446 XMLUtils::addChild(doc, d, "BaseSchedule", baseSchedule_);
447 XMLUtils::addChild(doc, d, "Shift", shift_);
448 XMLUtils::addChild(doc, d, "Calendar", calendar_);
449 XMLUtils::addChild(doc, d, "Convention", convention_);
451 } else {
452 QL_FAIL("ScriptedTradeEventData::toXML(): unexpected ScriptedTradeEventData::Type");
453 }
454 return n;
455}
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: schedule.cpp:198
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
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:

◆ type()

Type type ( ) const

Definition at line 53 of file scriptedtrade.hpp.

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

◆ name()

const std::string & name ( ) const

Definition at line 54 of file scriptedtrade.hpp.

54{ return name_; }
+ Here is the caller graph for this function:

◆ value()

const std::string & value ( ) const

Definition at line 55 of file scriptedtrade.hpp.

55{ return value_; }

◆ schedule()

const ScheduleData & schedule ( ) const

Definition at line 56 of file scriptedtrade.hpp.

56{ return schedule_; }
+ Here is the caller graph for this function:

◆ baseSchedule()

const std::string & baseSchedule ( ) const

Definition at line 57 of file scriptedtrade.hpp.

57{ return baseSchedule_; }
+ Here is the caller graph for this function:

◆ shift()

const std::string & shift ( ) const

Definition at line 58 of file scriptedtrade.hpp.

58{ return shift_; }
+ Here is the caller graph for this function:

◆ calendar()

const std::string & calendar ( ) const

Definition at line 59 of file scriptedtrade.hpp.

59{ return calendar_; }
+ Here is the caller graph for this function:

◆ convention()

const std::string & convention ( ) const

Definition at line 60 of file scriptedtrade.hpp.

60{ return convention_; }
+ Here is the caller graph for this function:

◆ hasData()

const bool hasData ( )

Definition at line 457 of file scriptedtrade.cpp.

457 {
458 if (type_ == Type::Array) {
459 return schedule_.hasData();
460 } else if (type_ == Type::Derived) {
461 return !baseSchedule_.empty() && !shift_.empty() && !calendar_.empty() && !convention_.empty();
462 } else if (type_ == Type::Value) {
463 return !value_.empty();
464 } else {
465 // If type_ is not defined, then the ScriptedTradeEventData object is not defined
466 return false;
467 }
468}
bool hasData() const
Check if has any dates/rules/derived schedules.
Definition: schedule.hpp:223
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ type_

Type type_
private

Definition at line 64 of file scriptedtrade.hpp.

◆ name_

std::string name_
private

Definition at line 65 of file scriptedtrade.hpp.

◆ value_

std::string value_
private

Definition at line 66 of file scriptedtrade.hpp.

◆ schedule_

ScheduleData schedule_
private

Definition at line 67 of file scriptedtrade.hpp.

◆ baseSchedule_

std::string baseSchedule_
private

Definition at line 68 of file scriptedtrade.hpp.

◆ shift_

std::string shift_
private

Definition at line 69 of file scriptedtrade.hpp.

◆ calendar_

std::string calendar_
private

Definition at line 70 of file scriptedtrade.hpp.

◆ convention_

std::string convention_
private

Definition at line 71 of file scriptedtrade.hpp.