Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
report.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/report/report.hpp
20 \brief Report interface class
21 \ingroup report
22*/
23
24#pragma once
25
26#include <boost/variant.hpp>
27#include <ql/time/date.hpp>
28#include <ql/time/period.hpp>
29#include <ql/types.hpp>
30#include <string>
31
32namespace ore {
33namespace data {
34using QuantLib::Date;
35using QuantLib::Period;
36using QuantLib::Real;
37using QuantLib::Size;
38using std::string;
39
40/*! Abstract Report interface class
41 *
42 * A Report can be thought of as a CSV file or SQL table, it has columns (each with a name and type) which
43 * are set before we add any data, then each row of data is added with calls to add().
44 *
45 * ReportType is a boost::variant which covers all the allowable types for a report.
46 *
47 * Usage of the report API is as follows
48 * <pre>
49 * Report npv_report = makeReport();
50 *
51 * // create headers
52 * npv_report.addColumn("Id", string())
53 * .addColumn("NPV", double(), 2)
54 * .addColumn("CP", string());
55 *
56 * // add rows
57 * npv_report.next().add("t1").add(123.45).add("cp");
58 * npv_report.next().add("t2").add(3.14).add("cp");
59 * npv_report.next().add("t3").add(100.0).add("cp2");
60 * npv_report.end();
61 * </pre>
62 \ingroup report
63 */
64class Report {
65public:
66 typedef boost::variant<Size, Real, string, Date, Period> ReportType;
67
68 virtual ~Report() {}
69 virtual Report& addColumn(const string& name, const ReportType&, Size precision = 0) = 0;
70 virtual Report& next() = 0;
71 virtual Report& add(const ReportType& rt) = 0;
72 virtual void end() = 0;
73 // make sure that (possibly) buffered output data is written to the result object (e.g. a file)
74 virtual void flush() {}
75};
76} // namespace data
77} // namespace ore
virtual Report & add(const ReportType &rt)=0
virtual Report & next()=0
virtual void end()=0
virtual void flush()
Definition: report.hpp:74
virtual Report & addColumn(const string &name, const ReportType &, Size precision=0)=0
boost::variant< Size, Real, string, Date, Period > ReportType
Definition: report.hpp:66
virtual ~Report()
Definition: report.hpp:68
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
string name