DUNE PDELab (2.7)

callable.hh
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_CALLABLE_HH
4#define DUNE_FUNCTIONS_COMMON_CALLABLE_HH
5
6#include <memory>
7#include <functional>
8
11
12
13namespace Dune {
14namespace Functions {
15
16
17
18
36template<class F>
38{
39 using Range = typename F::RangeType;
40 using Domain = typename F::DomainType;
41
42 public:
43
51 {
53 }
54
61 CallableFunctionWrapper(const std::shared_ptr<const F>& f) :
62 f_(f)
63 {}
64
70 Range operator()(const Domain& x) const
71 {
72 Range y;
73 f_->evaluate(x, y);
74 return y;
75 }
76
77 private:
78 std::shared_ptr<const F> f_;
79};
80
81
82
104template<class F>
106{
108}
109
110
136template<class F>
137CallableFunctionWrapper<F> callable(const std::shared_ptr<F>& fp)
138{
140}
141
142
143
144} // namespace Functions
145} // namespace Dune
146
147#endif //DUNE_FUNCTIONS_COMMON_CALLABLE_HH
Wrap a Dune::VirtualFunction into a callable object.
Definition: callable.hh:38
Range operator()(const Domain &x) const
Forward operator() to F::evaluate()
Definition: callable.hh:70
CallableFunctionWrapper(const F &f)
Instanciate from reference to f.
Definition: callable.hh:50
CallableFunctionWrapper(const std::shared_ptr< const F > &f)
Instanciate from shared_ptr to f.
Definition: callable.hh:61
Simple base class templates for functions.
CallableFunctionWrapper< F > callable(const std::shared_ptr< F > &fp)
Create a callable object from shared_ptr<F>
Definition: callable.hh:137
Dune namespace.
Definition: alignedallocator.hh:14
shared_ptr< T > stackobject_to_shared_ptr(T &t)
Create a shared_ptr for a stack-allocated object.
Definition: shared_ptr.hh:75
This file implements the class shared_ptr (a reference counting pointer), for those systems that don'...
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)