CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
forEachLeafLogic.hpp
1/*
2 * CoDiPack, a Code Differentiation Package
3 *
4 * Copyright (C) 2015-2024 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
5 * Homepage: http://www.scicomp.uni-kl.de
6 * Contact: Prof. Nicolas R. Gauger (codi@scicomp.uni-kl.de)
7 *
8 * Lead developers: Max Sagebaum, Johannes Blühdorn (SciComp, University of Kaiserslautern-Landau)
9 *
10 * This file is part of CoDiPack (http://www.scicomp.uni-kl.de/software/codi).
11 *
12 * CoDiPack is free software: you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * CoDiPack is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty
19 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * See the GNU General Public License for more details.
22 * You should have received a copy of the GNU
23 * General Public License along with CoDiPack.
24 * If not, see <http://www.gnu.org/licenses/>.
25 *
26 * For other licensing options please contact us.
27 *
28 * Authors:
29 * - SciComp, University of Kaiserslautern-Landau:
30 * - Max Sagebaum
31 * - Johannes Blühdorn
32 * - Former members:
33 * - Tim Albring
34 */
35#pragma once
36
37#include <type_traits>
38#include <utility>
39
40#include "../../../config.h"
41#include "../../../misc/macros.hpp"
42#include "../../../traits/expressionTraits.hpp"
43#include "../traversalLogic.hpp"
44
46namespace codi {
47
59 template<typename T_Impl>
60 struct ForEachLeafLogic : public TraversalLogic<T_Impl> {
61 public:
62
64
65 /*******************************************************************************/
68
70 template<typename Node, typename... Args>
71 void handleActive(Node const& node, Args&&... args) {
72 CODI_UNUSED(node, args...);
73 }
74
76 template<typename Node, typename... Args>
77 void handleConstant(Node const& node, Args&&... args) {
78 CODI_UNUSED(node, args...);
79 }
80
82 /*******************************************************************************/
85
87 template<typename Node, typename... Args>
89 cast().handleActive(node, std::forward<Args>(args)...);
90 }
91
93 template<typename Node, typename... Args>
95 cast().handleConstant(node, std::forward<Args>(args)...);
96 }
97
99
100 private:
101
102 CODI_INLINE Impl& cast() {
103 return static_cast<Impl&>(*this);
104 }
105 };
106}
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition: config.h:457
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition: macros.hpp:94
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition: macros.hpp:111
typename std::enable_if< IsConstantExpression< Expr >::value, T >::type EnableIfConstantExpression
Enable if wrapper for IsConstantExpression.
Definition: expressionTraits.hpp:156
typename std::enable_if< IsLhsExpression< Expr >::value, T >::type EnableIfLhsExpression
Enable if wrapper for IsLhsExpression.
Definition: expressionTraits.hpp:137
CoDiPack - Code Differentiation Package.
Definition: codi.hpp:90
void CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition: macros.hpp:46
Implement logic for leaf nodes only.
Definition: forEachLeafLogic.hpp:60
void handleActive(Node const &node, Args &&... args)
Called for leaf nodes which implement LhsExpressionInterface.
Definition: forEachLeafLogic.hpp:71
void handleConstant(Node const &node, Args &&... args)
Called for leaf nodes which implement ConstantExpression.
Definition: forEachLeafLogic.hpp:77
ExpressionTraits::EnableIfConstantExpression< Node > leaf(Node const &node, Args &&... args)
Called for all leaf nodes in the expression.
Definition: forEachLeafLogic.hpp:94
T_Impl Impl
See ForEachLeafLogic.
Definition: forEachLeafLogic.hpp:63
ExpressionTraits::EnableIfLhsExpression< Node > leaf(Node const &node, Args &&... args)
Called for all leaf nodes in the expression.
Definition: forEachLeafLogic.hpp:88
Traversal of CoDiPack expressions.
Definition: traversalLogic.hpp:56
void node(Node const &node, Args &&... args)
Called for each node in the expression.
Definition: traversalLogic.hpp:86