Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
astresetter.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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
20
21namespace ore {
22namespace data {
23
24namespace {
25class ASTResetter : public AcyclicVisitor, public Visitor<ASTNode>, public Visitor<VariableNode> {
26public:
27 ASTResetter() {}
28
29 void visit(ASTNode& n) override {
30 for (auto const& c : n.args)
31 if (c != nullptr)
32 c->accept(*this);
33 }
34
35 void visit(VariableNode& n) override {
36 n.isCached = n.isScalar = false;
37 n.cachedScalar = nullptr;
38 n.cachedVector = nullptr;
39 visit(static_cast<ASTNode&>(n));
40 }
41};
42} // namespace
43
44void reset(const ASTNodePtr root) {
45 ASTResetter r;
46 root->accept(r);
47}
48
49} // namespace data
50} // namespace ore
resets cached values in ast
@ data
Definition: log.hpp:77
void reset(const ASTNodePtr root)
Definition: astresetter.cpp:44
QuantLib::ext::shared_ptr< ASTNode > ASTNodePtr
Definition: ast.hpp:46
Serializable Credit Default Swap.
Definition: namespaces.docs:23