DUNE PDELab (git)

localfunction_imp.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUNCTIONS_COMMON_LOCALFUNCTION_FUNCTION_IMP_HH
8#define DUNE_FUNCTIONS_COMMON_LOCALFUNCTION_FUNCTION_IMP_HH
9
10#include <dune/functions/common/type_traits.hh>
11#include <dune/functions/common/differentiablefunction_imp.hh>
12
13
14
15namespace Dune {
16namespace Functions {
17namespace Imp {
18
19// Interface of type erasure wrapper
20//
21// Notice that the basic interface of polymorphic classes (destructor, clone, ...)
22// will be added by the type erasure foundation classes.
23template<class Signature, class DerivativeInterface, class LocalContext>
24class LocalFunctionWrapperInterface :
25 public DifferentiableFunctionWrapperInterface<Signature, DerivativeInterface>
26{
27public:
28 virtual void bind(const LocalContext&) = 0;
29
30 virtual void unbind() = 0;
31
32 virtual bool bound() const = 0;
33
34 virtual const LocalContext& localContext() const = 0;
35};
36
37
38// Implementation of type erasure wrapper
39template<class Signature, class DerivativeInterface, class LocalContext, class B>
40class LocalFunctionWrapperImplementation :
41 public DifferentiableFunctionWrapperImplementation<Signature, DerivativeInterface, B>
42{
43 using Base = DifferentiableFunctionWrapperImplementation<Signature, DerivativeInterface, B>;
44public:
45 using Base::Base;
46
47 virtual void bind(const LocalContext& context)
48 {
49 this->get().bind(context);
50 }
51
52 virtual void unbind()
53 {
54 this->get().unbind();
55 }
56
57 virtual bool bound() const
58 {
59 return this->get().bound();
60 }
61
62 virtual const LocalContext& localContext() const
63 {
64 return this->get().localContext();
65 }
66};
67
68}}} // namespace Dune::Functions::Imp
69
70
71
72#endif // DUNE_FUNCTIONS_COMMON_DIFFERENTIABLE_FUNCTION_IMP_HH
Dune namespace.
Definition: alignedallocator.hh:13
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
Return the entry at position pos of the given sequence.
Definition: integersequence.hh:22
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)