Skip to content
Snippets Groups Projects
AbstractFunction.h 3.8 KiB
Newer Older
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ==                                                                        ==
// ============================================================================
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.



/** \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:
    AbstractFunction(int degree = 0) : 
      degree_(degree) 
Thomas Witkowski's avatar
Thomas Witkowski committed
    {}
Thomas Witkowski's avatar
Thomas Witkowski committed
    virtual ~AbstractFunction() {}
Thomas Witkowski's avatar
Thomas Witkowski committed
    inline int getDegree() const 
    { 
      return degree_; 
Thomas Witkowski's avatar
Thomas Witkowski committed
    }
    /// Deligates the evaluation to overriden method f.
    virtual ReturnType operator()(const ArgumentType& x) const = 0;

  protected:
    int degree_;
  };

  /**
   * \ingroup Common
   *
   * \brief
   * Interface for binary functions. 
   */
  template<typename ReturnType, 
	   typename ArgumentType1, 
	   typename ArgumentType2>
  class BinaryAbstractFunction
  {
  public:
    BinaryAbstractFunction(int degree = 0) : 
      degree_(degree) 
    virtual ~BinaryAbstractFunction() {}
Thomas Witkowski's avatar
Thomas Witkowski committed
    inline int getDegree() const 
    { 
    /// Deligates the evaluation to overriden method f.
    virtual ReturnType operator()(const ArgumentType1& x,
				  const ArgumentType2& y) const = 0;

  protected:
    int degree_;
  };

  /**
   * \ingroup Common
   *
   * \brief
   * Interface for tertiary functions. 
   */
  template<typename ReturnType, 
	   typename ArgumentType1, 
	   typename ArgumentType2,
	   typename ArgumentType3>
  class TertiaryAbstractFunction
  {
  public:
    TertiaryAbstractFunction(int degree = 0) : 
      degree_(degree) 
    virtual ~TertiaryAbstractFunction() {}
Thomas Witkowski's avatar
Thomas Witkowski committed
    inline int getDegree() const 
    { 
    virtual ReturnType operator()(const ArgumentType1& x,
				  const ArgumentType2& y,
				  const ArgumentType3& z) const = 0;

  protected:
    int degree_;
  };

  /**
   * \ingroup Common
   *
   * \brief
   * Interface for quart functions. 
   */
  template<typename ReturnType, 
	   typename ArgumentType1, 
	   typename ArgumentType2, 
	   typename ArgumentType3,
	   typename ArgumentType4>
  class QuartAbstractFunction
  {
  public:
    QuartAbstractFunction(int degree = 0) : 
      degree_(degree) 
    virtual ~QuartAbstractFunction() {}
Thomas Witkowski's avatar
Thomas Witkowski committed
    inline int getDegree() const 
    { 
    virtual ReturnType operator()(const ArgumentType1& x,
				  const ArgumentType2& y,
				  const ArgumentType3& z,
				  const ArgumentType4& u) const = 0;

  protected:
    int degree_;
  };




}

#endif // AMDIS_ABSTRACTFUNCTION_H