00001 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 00002 // vi: set et ts=4 sw=2 sts=2: 00003 #ifndef DUNE_FUNCTION_HH 00004 #define DUNE_FUNCTION_HH 00005 00006 00007 #include "typetraits.hh" 00008 00009 namespace Dune { 00010 00026 template <class Domain, class Range> 00027 class Function 00028 { 00029 typedef typename std::remove_cv<typename std::remove_reference< Domain >::type >::type RawDomainType; 00030 typedef typename std::remove_cv<typename std::remove_reference< Range >::type >::type RawRangeType; 00031 00032 public: 00033 00035 typedef RawRangeType RangeType; 00036 00038 typedef RawDomainType DomainType; 00039 00041 struct Traits 00042 { 00043 typedef RawDomainType DomainType; 00044 typedef RawRangeType RangeType; 00045 }; 00046 00053 void evaluate(const typename Traits::DomainType& x, typename Traits::RangeType& y) const; 00054 }; // end of Function class 00055 00056 00057 00065 template <class DomainType, class RangeType> 00066 class VirtualFunction : 00067 public Function<const DomainType&, RangeType&> 00068 { 00069 public: 00070 typedef typename Function<const DomainType&, RangeType&>::Traits Traits; 00071 00072 virtual ~VirtualFunction() {} 00079 virtual void evaluate(const typename Traits::DomainType& x, typename Traits::RangeType& y) const = 0; 00080 }; // end of VirtualFunction class 00081 00084 } // end namespace 00085 00086 #endif