QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
event.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2009 Ferdinando Ametrano
5 Copyright (C) 2005 Joseph Wang
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_event_hpp
26#define quantlib_event_hpp
27
28#include <ql/time/date.hpp>
29#include <ql/patterns/observable.hpp>
30#include <ql/optional.hpp>
31
32namespace QuantLib {
33
34 class AcyclicVisitor;
35
37
40 class Event : public virtual Observable {
41 public:
42 ~Event() override = default;
44
45
46 virtual Date date() const = 0;
47
49
53 virtual bool hasOccurred(
54 const Date& refDate = Date(),
55 ext::optional<bool> includeRefDate = ext::nullopt) const;
57
59
60 virtual void accept(AcyclicVisitor&);
62 };
63
64
65 namespace detail {
66
67 // used to create an Event instance.
68 // to be replaced with specific events as soon as we find out which.
69 class simple_event : public Event {
70 public:
71 explicit simple_event(const Date& date) : date_(date) {}
72 Date date() const override { return date_; }
73
74 private:
76 };
77
78 }
79
80}
81
82
83#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Concrete date class.
Definition: date.hpp:125
Base class for event.
Definition: event.hpp:40
virtual void accept(AcyclicVisitor &)
Definition: event.cpp:41
~Event() override=default
virtual Date date() const =0
returns the date at which the event occurs
virtual bool hasOccurred(const Date &refDate=Date(), ext::optional< bool > includeRefDate=ext::nullopt) const
returns true if an event has already occurred before a date
Definition: event.cpp:28
Object that notifies its changes to a set of observers.
Definition: observable.hpp:62
simple_event(const Date &date)
Definition: event.hpp:71
Date date() const override
returns the date at which the event occurs
Definition: event.hpp:72
const boost::none_t & nullopt
Definition: optional.cpp:27
Definition: any.hpp:35