dune-functions  2.9.0
localfunction_imp.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_FUNCTIONS_COMMON_LOCALFUNCTION_FUNCTION_IMP_HH
4 #define DUNE_FUNCTIONS_COMMON_LOCALFUNCTION_FUNCTION_IMP_HH
5 
8 
9 
10 
11 namespace Dune {
12 namespace Functions {
13 namespace Imp {
14 
15 // Interface of type erasure wrapper
16 //
17 // Notice that the basic interface of polymorphic classes (destructor, clone, ...)
18 // will be added by the type erasure foundation classes.
19 template<class Signature, class DerivativeInterface, class LocalContext>
20 class LocalFunctionWrapperInterface :
21  public DifferentiableFunctionWrapperInterface<Signature, DerivativeInterface>
22 {
23 public:
24  virtual void bind(const LocalContext&) = 0;
25 
26  virtual void unbind() = 0;
27 
28  virtual bool bound() const = 0;
29 
30  virtual const LocalContext& localContext() const = 0;
31 };
32 
33 
34 // Implementation of type erasure wrapper
35 template<class Signature, class DerivativeInterface, class LocalContext, class B>
36 class LocalFunctionWrapperImplementation :
37  public DifferentiableFunctionWrapperImplementation<Signature, DerivativeInterface, B>
38 {
39  using Base = DifferentiableFunctionWrapperImplementation<Signature, DerivativeInterface, B>;
40 public:
41  using Base::Base;
42 
43  virtual void bind(const LocalContext& context)
44  {
45  this->get().bind(context);
46  }
47 
48  virtual void unbind()
49  {
50  this->get().unbind();
51  }
52 
53  virtual bool bound() const
54  {
55  return this->get().bound();
56  }
57 
58  virtual const LocalContext& localContext() const
59  {
60  return this->get().localContext();
61  }
62 };
63 
64 }}} // namespace Dune::Functions::Imp
65 
66 
67 
68 #endif // DUNE_FUNCTIONS_COMMON_DIFFERENTIABLE_FUNCTION_IMP_HH
Definition: polynomial.hh:10