Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
envelope.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file ored/portfolio/envelope.hpp
20 \brief trade envelope data model and serialization
21 \ingroup tradedata
22*/
23
24#pragma once
25
28
29#include <boost/any.hpp>
30#include <boost/none.hpp>
31#include <ql/tuple.hpp>
32#include <boost/tuple/tuple_comparison.hpp>
33
34#include <map>
35#include <set>
36
40using std::map;
41using std::set;
42using std::string;
43
44namespace ore {
45namespace data {
46
47//! Serializable object holding generic trade data, reporting dimensions
48/*!
49 \ingroup tradedata
50*/
51class Envelope : public XMLSerializable {
52public:
53 //! Default constructor
55
56 //! Constructor with netting set id and portfolio ids, without additional fields
57 Envelope(const string& counterparty, const string& nettingSetId, const set<string>& portfolioIds = set<string>())
59 initialized_(true) {}
60
61 //! Constructor with netting set details and portfolio ids, without additional fields
63 const set<string>& portfolioIds = set<string>())
65 initialized_(true) {}
66
67 //! Constructor without netting set / portfolio ids, with additional fields
68 Envelope(const string& counterparty, const map<string, string>& additionalFields)
70 for (const auto& addField : additionalFields)
71 additionalFields_[addField.first] = addField.second;
72 }
73
74 //! Constructor with netting set, with additional fields
75 Envelope(const string& counterparty, const string& nettingSetId, const map<string, string>& additionalFields,
76 const set<string>& portfolioIds = set<string>())
78 initialized_(true) {
79 for (const auto& addField : additionalFields)
80 additionalFields_[addField.first] = addField.second;
81 }
82
83 //! Constructor with netting set details, with additional fields
85 const map<string, string>& additionalFields, const set<string>& portfolioIds = set<string>())
87 initialized_(true) {
88 for (const auto& addField : additionalFields)
89 additionalFields_[addField.first] = addField.second;
90 }
91
92 //! \name Serialisation
93 //@{
94 virtual void fromXML(XMLNode* node) override;
95 virtual XMLNode* toXML(XMLDocument& doc) const override;
96 //@}
97
98 //! \name Inspectors
99 //@{
100 const string& counterparty() const { return counterparty_; }
101 const string& nettingSetId() const { return nettingSetDetails_.nettingSetId(); }
103 const set<string>& portfolioIds() const { return portfolioIds_; }
104 const map<string, string> additionalFields() const;
105 const map<string, boost::any>& fullAdditionalFields() const { return additionalFields_; }
106 string additionalField(const std::string& name, const bool mandatory = true,
107 const std::string& defaultValue = std::string()) const;
108 boost::any additionalAnyField(const std::string& name, const bool mandatory = true,
109 const boost::any& defaultValue = boost::none) const;
110 void setAdditionalField(const std::string& key, const boost::any& value);
111 //@}
112
113 //! \name Utility
114 //@{
115 //! Check if the envelope is initialized
116 bool initialized() const { return initialized_; }
117 //! Check if the netting set details have been populated
119 //@}
120
121private:
124 set<string> portfolioIds_;
125 map<string, boost::any> additionalFields_;
126 bool initialized_ = false;
127};
128
129} // namespace data
130} // namespace ore
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
Envelope(const string &counterparty, const NettingSetDetails &nettingSetDetails, const map< string, string > &additionalFields, const set< string > &portfolioIds=set< string >())
Constructor with netting set details, with additional fields.
Definition: envelope.hpp:84
Envelope(const string &counterparty, const map< string, string > &additionalFields)
Constructor without netting set / portfolio ids, with additional fields.
Definition: envelope.hpp:68
set< string > portfolioIds_
Definition: envelope.hpp:124
const NettingSetDetails nettingSetDetails() const
Definition: envelope.hpp:102
Envelope(const string &counterparty, const NettingSetDetails &nettingSetDetails=NettingSetDetails(), const set< string > &portfolioIds=set< string >())
Constructor with netting set details and portfolio ids, without additional fields.
Definition: envelope.hpp:62
const map< string, string > additionalFields() const
Definition: envelope.cpp:110
const set< string > & portfolioIds() const
Definition: envelope.hpp:103
virtual void fromXML(XMLNode *node) override
Definition: envelope.cpp:27
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: envelope.cpp:75
Envelope()
Default constructor.
Definition: envelope.hpp:54
void setAdditionalField(const std::string &key, const boost::any &value)
Definition: envelope.cpp:133
bool hasNettingSetDetails() const
Check if the netting set details have been populated.
Definition: envelope.hpp:118
NettingSetDetails nettingSetDetails_
Definition: envelope.hpp:123
Envelope(const string &counterparty, const string &nettingSetId, const set< string > &portfolioIds=set< string >())
Constructor with netting set id and portfolio ids, without additional fields.
Definition: envelope.hpp:57
const string & nettingSetId() const
Definition: envelope.hpp:101
const map< string, boost::any > & fullAdditionalFields() const
Definition: envelope.hpp:105
boost::any additionalAnyField(const std::string &name, const bool mandatory=true, const boost::any &defaultValue=boost::none) const
Definition: envelope.cpp:126
const string & counterparty() const
Definition: envelope.hpp:100
map< string, boost::any > additionalFields_
Definition: envelope.hpp:125
Envelope(const string &counterparty, const string &nettingSetId, const map< string, string > &additionalFields, const set< string > &portfolioIds=set< string >())
Constructor with netting set, with additional fields.
Definition: envelope.hpp:75
string additionalField(const std::string &name, const bool mandatory=true, const std::string &defaultValue=std::string()) const
Definition: envelope.cpp:118
bool initialized() const
Check if the envelope is initialized.
Definition: envelope.hpp:116
Serializable object holding netting set identification data.
bool empty() const
Check if the netting set details have been populated.
const string & nettingSetId() const
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
Base class for all serializable classes.
Definition: xmlutils.hpp:101
SafeStack< ValueType > value
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
netting set details data model and serialization
string name
XML utility functions.