26#include <ql/shared_ptr.hpp>
27#include <ql/errors.hpp>
28#include <ql/time/date.hpp>
29#include <ql/types.hpp>
75 const std::set<std::string>
ids()
const {
76 std::set<std::string> result;
84 virtual const std::vector<QuantLib::Date>&
dates()
const = 0;
87 virtual QuantLib::Date
asof()
const = 0;
93 virtual void setT0(Real value, Size
id, Size
depth = 0) = 0;
98 virtual Real
get(Size
id, Size date, Size sample, Size
depth = 0)
const = 0;
100 virtual void set(Real value, Size
id, Size date, Size sample, Size
depth = 0) = 0;
103 virtual Real
get(
const std::string&
id,
const QuantLib::Date& date, Size sample, Size
depth = 0)
const {
107 virtual void set(Real value,
const std::string&
id,
const QuantLib::Date& date, Size sample, Size
depth = 0) {
113 virtual void remove(Size
id);
116 virtual void remove(Size
id, Size sample);
121 virtual Size
index(
const std::string&
id)
const {
123 QL_REQUIRE(it !=
idsAndIndexes().end(),
"NPVCube can't find an index for id " <<
id);
127 virtual Size
index(
const QuantLib::Date& date)
const {
128 auto it = std::find(
dates().begin(),
dates().end(), date);
129 QL_REQUIRE(it !=
dates().end(),
"NPVCube can't find an index for date " << date);
130 return std::distance(
dates().begin(), it);
138 for (Size date = 0; date < this->
numDates(); ++date) {
140 setT0(0.0,
id, depth);
141 for (Size sample = 0; sample < this->
samples(); ++sample) {
149 for (Size date = 0; date < this->
numDates(); ++date) {
NPV Cube class stores both future and current NPV values.
virtual void remove(Size id)
virtual Real getT0(Size id, Size depth=0) const =0
Get a T0 value from the cube using index.
NPVCube(NPVCube &)=delete
Do not allow cube copying.
virtual Size numDates() const =0
virtual Size samples() const =0
virtual Real get(Size id, Size date, Size sample, Size depth=0) const =0
Get a value from the cube using index.
virtual QuantLib::Date asof() const =0
Return the asof date (T0 date)
Size getTradeIndex(const std::string &id) const
virtual Real getT0(const std::string &id, Size depth=0) const
Get a T0 value from the cube using trade id.
virtual void set(Real value, Size id, Size date, Size sample, Size depth=0)=0
Set a value in the cube using index.
virtual Size numIds() const =0
Return the length of each dimension.
virtual Size depth() const =0
virtual Size index(const std::string &id) const
virtual Real get(const std::string &id, const QuantLib::Date &date, Size sample, Size depth=0) const
Get a value from the cube using trade id and date.
virtual const std::vector< QuantLib::Date > & dates() const =0
Get the vector of dates for this cube.
const std::set< std::string > ids() const
Get a set of all ids in the cube.
virtual void setT0(Real value, const std::string &id, Size depth=0)
Set a value in the cube using trade id.
virtual const std::map< std::string, Size > & idsAndIndexes() const =0
Get a map of id and their index position in this cube.
virtual void setT0(Real value, Size id, Size depth=0)=0
Set a value in the cube using index.
virtual Size index(const QuantLib::Date &date) const
virtual void set(Real value, const std::string &id, const QuantLib::Date &date, Size sample, Size depth=0)
Set a value in the cube using trade id and date.
NPVCube & operator=(NPVCube const &)=delete
SafeStack< ValueType > value