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
21#include <ql/event.hpp>
22#include <ql/patterns/visitor.hpp>
23#include <ql/optional.hpp>
24#include <ql/settings.hpp>
25
26namespace QuantLib {
27
28 bool Event::hasOccurred(const Date& d, // refDate
29 ext::optional<bool> includeRefDate) const {
30 Date refDate =
31 d != Date() ? d : Settings::instance().evaluationDate();
32 bool includeRefDateEvent = includeRefDate ? // NOLINT(readability-implicit-bool-conversion)
33 *includeRefDate :
34 Settings::instance().includeReferenceDateEvents();
35 if (includeRefDateEvent)
36 return date() < refDate;
37 else
38 return date() <= refDate;
39 }
40
41 void Event::accept(AcyclicVisitor& v) {
42 auto* v1 = dynamic_cast<Visitor<Event>*>(&v);
43 if (v1 != nullptr)
44 v1->visit(*this);
45 else
46 QL_FAIL("not an event visitor");
47 }
48
49}
50

source code of quantlib/ql/event.cpp

Morty Proxy This is a proxified and sanitized view of the page, visit original site.