constFormula.hh

Go to the documentation of this file.
1 
6 #ifndef constformula_hh
7 #define constformula_hh
8 
9 #include "basics/debug.hh"
10 #include "formula.hh"
11 
12 #define ConstFormConstr_D 0
13 #define ConstFormDestr_D 0
14 
15 
16 namespace concepts {
17 
18 
19  // ********************************************************* ConstFormula **
20 
25  template<typename F = Real>
26  class ConstFormula : public Formula<F> {
27  public:
28  ConstFormula(const F a = F(1.0)) : a_(a) {
29  DEBUGL(ConstFormConstr_D, "a = " << a);
30  }
31  virtual F operator() (const Real p, const Real t = 0.0) const {
32  return a_;
33  }
34  virtual F operator() (const Real2d& p, const Real t = 0.0) const {
35  return a_;
36  }
37  virtual F operator() (const Real3d& p, const Real t = 0.0) const {
38  return a_;
39  }
40  virtual ~ConstFormula() {
41  DEBUGL(ConstFormDestr_D, "Delete " << *this);
42  }
43  virtual ConstFormula<F>* clone() const {
44  return new ConstFormula<F>(a_);
45  }
46  ConstFormula<F>& operator=(const F a) {
47  a_ = a;
48  return *this;
49  }
50  protected:
51  virtual std::ostream& info(std::ostream& os) const {
52  return os << concepts::typeOf(*this)<< "(" << a_ << ")";
53  }
54  private:
55  F a_;
56  };
57 
58 
59 
60 } // namespace concepts
61 
62 
63 #endif // constformula_hh
virtual std::ostream & info(std::ostream &os) const
Definition: constFormula.hh:51
virtual F operator()(const Real p, const Real t=0.0) const
Application operator.
Definition: constFormula.hh:31
Class for a constant formula.
Definition: constFormula.hh:26
Interface for a formula.
Definition: lform.hh:18
#define ConstFormConstr_D
Definition: constFormula.hh:12
#define DEBUGL(doit, msg)
ConstFormula(const F a=F(1.0))
Definition: constFormula.hh:28
#define ConstFormDestr_D
Definition: constFormula.hh:13
virtual ConstFormula< F > * clone() const
Definition: constFormula.hh:43
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
ConstFormula< F > & operator=(const F a)
Definition: constFormula.hh:46
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich