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

#include <orea/simm/simmcalibration.hpp>

+ Inheritance diagram for SimmCalibrationData:
+ Collaboration diagram for SimmCalibrationData:

Public Member Functions

 SimmCalibrationData ()
 
- 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)
 
std::string toXMLString () const
 

Serialisation

std::map< std::string, QuantLib::ext::shared_ptr< SimmCalibration > > data_
 
ore::data::XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
void fromXML (ore::data::XMLNode *node) override
 
void add (const QuantLib::ext::shared_ptr< SimmCalibration > &)
 
bool hasId (const std::string &id) const
 
const QuantLib::ext::shared_ptr< SimmCalibration > & getById (const std::string &id) const
 
const QuantLib::ext::shared_ptr< SimmCalibrationgetBySimmVersion (const std::string &id) const
 

Detailed Description

Definition at line 297 of file simmcalibration.hpp.

Constructor & Destructor Documentation

◆ SimmCalibrationData()

Definition at line 300 of file simmcalibration.hpp.

300{}

Member Function Documentation

◆ toXML()

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

Implements XMLSerializable.

Definition at line 596 of file simmcalibration.cpp.

596 {
597 XMLNode* node = doc.allocNode("SIMMCalibrationData");
598 for (const auto& [simmCalibrationId, simmCalibration] : data_) {
599 XMLUtils::appendNode(node, simmCalibration->toXML(doc));
600 }
601 return node;
602}
std::map< std::string, QuantLib::ext::shared_ptr< SimmCalibration > > data_
XMLNode * allocNode(const string &nodeName)
static void appendNode(XMLNode *parent, XMLNode *child)
+ Here is the call graph for this function:

◆ fromXML()

void fromXML ( ore::data::XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 604 of file simmcalibration.cpp.

604 {
605 XMLUtils::checkNode(node, "SIMMCalibrationData");
606 vector<XMLNode*> simmCalibrationNodes = XMLUtils::getChildrenNodes(node, "SIMMCalibration");
607 for (XMLNode* scNode : simmCalibrationNodes) {
608 try {
609 add(QuantLib::ext::make_shared<SimmCalibration>(scNode));
610 } catch (const std::exception& ex) {
611 ore::data::StructuredConfigurationErrorMessage("SIMM calibration data", "",
612 "SIMM calibration node failed to parse", ex.what())
613 .log();
614 }
615 }
616}
void add(const QuantLib::ext::shared_ptr< SimmCalibration > &)
static void checkNode(XMLNode *n, const string &expectedName)
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
+ Here is the call graph for this function:

◆ add()

void add ( const QuantLib::ext::shared_ptr< SimmCalibration > &  simmCalibration)

Definition at line 618 of file simmcalibration.cpp.

618 {
619
620 const string configurationType = "SIMM calibration data";
621 const string exceptionType = "Adding SIMM calibration";
622
623 // Check for SIMM calibration ID duplicates
624 if (data_.find(simmCalibration->id()) != data_.end()) {
626 configurationType, simmCalibration->id(), exceptionType,
627 "Cannot add SIMM calibration data since data with the same ID already exists.")
628 .log();
629 return;
630 }
631
632 // Check for SIMM version name clashes
633 const auto& incVersionNames = simmCalibration->versionNames();
634 for (const auto& [id, sc] : data_) {
635 for (const string& incName : incVersionNames) {
636 for (const string& currName : sc->versionNames()) {
637 if (incName == currName) {
638 const string msg = "SIMM calibration has duplicate version name '" + incName +
639 "' (added under calibration id='" + id +
640 "'). SIMM calibration will not be added.";
641 ore::data::StructuredConfigurationWarningMessage(configurationType, simmCalibration->id(),
642 exceptionType, msg)
643 .log();
644 return;
645 }
646 }
647 }
648 }
649
650 data_[simmCalibration->id()] = simmCalibration;
651}
+ Here is the call graph for this function:

◆ hasId()

bool hasId ( const std::string &  id) const

Definition at line 309 of file simmcalibration.hpp.

309{ return data_.find(id) != data_.end(); }

◆ getById()

const QuantLib::ext::shared_ptr< SimmCalibration > & getById ( const std::string &  id) const

Definition at line 653 of file simmcalibration.cpp.

653 {
654 if (!hasId(id))
655 QL_FAIL("Could not find SIMM calibration with ID '" << id << "'");
656
657 return data_.at(id);
658}
bool hasId(const std::string &id) const

◆ getBySimmVersion()

const QuantLib::ext::shared_ptr< SimmCalibration > getBySimmVersion ( const std::string &  id) const

Definition at line 660 of file simmcalibration.cpp.

660 {
661 for (const auto& kv : data_) {
662 const auto& simmCalibrationData = kv.second;
663 for (const string& scVersion : simmCalibrationData->versionNames()) {
664 if (scVersion == version) {
665 return simmCalibrationData;
666 }
667 }
668 }
669
670 return nullptr;
671}
+ Here is the call graph for this function:

Member Data Documentation

◆ data_

std::map<std::string, QuantLib::ext::shared_ptr<SimmCalibration> > data_
private

Definition at line 314 of file simmcalibration.hpp.