QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
callabilityschedule.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2005 Joseph Wang
5 Copyright (C) 2005, 2006 Theo Boafo
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
25#ifndef quantlib_callability_schedule_hpp
26#define quantlib_callability_schedule_hpp
27
28#include <ql/event.hpp>
29#include <ql/instruments/bond.hpp>
30#include <ql/patterns/visitor.hpp>
31#include <ql/utilities/null.hpp>
32#include <ql/shared_ptr.hpp>
33#include <ql/optional.hpp>
34#include <vector>
35
36namespace QuantLib {
37
39 class Callability : public Event {
40 public:
42 enum Type { Call, Put };
43
46 const Bond::Price& price() const {
47 QL_REQUIRE(price_, "no price given");
48 return *price_;
49 }
50 Type type() const { return type_; }
52
53 Date date() const override { return date_; }
55
57 void accept(AcyclicVisitor&) override;
59 private:
60 ext::optional<Bond::Price> price_;
63 };
64
66 auto* v1 = dynamic_cast<Visitor<Callability>*>(&v);
67 if (v1 != nullptr)
68 v1->visit(*this);
69 else
71 }
72
73 typedef std::vector<ext::shared_ptr<Callability> > CallabilitySchedule;
74
75}
76
77#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Bond price information.
Definition: bond.hpp:62
instrument callability
Type
type of the callability
void accept(AcyclicVisitor &) override
Callability(const Bond::Price &price, Type type, const Date &date)
Date date() const override
returns the date at which the event occurs
const Bond::Price & price() const
ext::optional< Bond::Price > price_
Concrete date class.
Definition: date.hpp:125
Base class for event.
Definition: event.hpp:40
virtual void accept(AcyclicVisitor &)
Definition: event.cpp:41
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
Definition: any.hpp:35
std::vector< ext::shared_ptr< Callability > > CallabilitySchedule