AbstractFunction.h 4.39 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file AbstractFunction.h */

#ifndef AMDIS_ABSTRACTFUNCTION_H
#define AMDIS_ABSTRACTFUNCTION_H

#include "Global.h"

namespace AMDiS {

  /** 
   * \ingroup Common
   * 
   * \brief
   * An AbstractFunction object represents a function 
   * f : ArgumentType -> ReturnType. 
   *
   * AbstractFunction is a pure virtual class interface class.
   * To create your own function you have to derive AbstractFunction and
   * overload operator(). 
   */
  template<typename ReturnType, typename ArgumentType>
  class AbstractFunction
  {
  public:
44
    /// Constructor.
45
46
    AbstractFunction(int degree = 0) : 
      degree_(degree) 
Thomas Witkowski's avatar
Thomas Witkowski committed
47
    {}
48

Thomas Witkowski's avatar
Thomas Witkowski committed
49
    virtual ~AbstractFunction() {}
50

51
    /// Returns \ref degree_.
52
53
    inline int getDegree() const { 
      return degree_; 
Thomas Witkowski's avatar
Thomas Witkowski committed
54
    }
55

56
    /// Deligates the evaluation to overriden method f.
57
    virtual ReturnType operator()(const ArgumentType& x) const = 0;
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

  protected:
    int degree_;
  };

  /**
   * \ingroup Common
   *
   * \brief
   * Interface for binary functions. 
   */
  template<typename ReturnType, 
	   typename ArgumentType1, 
	   typename ArgumentType2>
  class BinaryAbstractFunction
  {
  public:
75
    /// Constructor.
76
77
    BinaryAbstractFunction(int degree = 0) : 
      degree_(degree) 
78
    {}
79

80
    virtual ~BinaryAbstractFunction() {}
81

82
    /// Returns \ref degree_.
83
84
    inline int getDegree() const { 
      return degree_; 
85
    }
86

87
    /// Deligates the evaluation to overriden method f.
88
89
    virtual ReturnType operator()(const ArgumentType1& x,
				  const ArgumentType2& y) const = 0;
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

  protected:
    int degree_;
  };

  /**
   * \ingroup Common
   *
   * \brief
   * Interface for tertiary functions. 
   */
  template<typename ReturnType, 
	   typename ArgumentType1, 
	   typename ArgumentType2,
	   typename ArgumentType3>
  class TertiaryAbstractFunction
  {
  public:
108
    /// Constructor.
109
110
    TertiaryAbstractFunction(int degree = 0) : 
      degree_(degree) 
111
    {}
112

113
    virtual ~TertiaryAbstractFunction() {}
114

115
    /// Returns \ref degree_.
116
117
    inline int getDegree() const { 
      return degree_; 
118
    }
119

120
    /// function evaluation.
121
122
123
    virtual ReturnType operator()(const ArgumentType1& x,
				  const ArgumentType2& y,
				  const ArgumentType3& z) const = 0;
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

  protected:
    int degree_;
  };

  /**
   * \ingroup Common
   *
   * \brief
   * Interface for quart functions. 
   */
  template<typename ReturnType, 
	   typename ArgumentType1, 
	   typename ArgumentType2, 
	   typename ArgumentType3,
	   typename ArgumentType4>
  class QuartAbstractFunction
  {
  public:
143
    /// Constructor.
144
145
    QuartAbstractFunction(int degree = 0) : 
      degree_(degree) 
146
    {}
147

148
    virtual ~QuartAbstractFunction() {}
149

150
    /// Returns \ref degree_.
151
152
    inline int getDegree() const { 
      return degree_; 
153
    }
154

155
    /// function evaluation.
156
157
158
159
    virtual ReturnType operator()(const ArgumentType1& x,
				  const ArgumentType2& y,
				  const ArgumentType3& z,
				  const ArgumentType4& u) const = 0;
160
161
162
163
164
165
166
167
168
169
170

  protected:
    int degree_;
  };




}

#endif // AMDIS_ABSTRACTFUNCTION_H