NotCached.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2005 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/MEAL/MEAL/NotCached.h
10 
11 #ifndef __NotCached_H
12 #define __NotCached_H
13 
14 #include "MEAL/CalculatePolicy.h"
15 
16 namespace MEAL
17 {
18 
20 
21  template<class T>
22  class NotCached : public CalculatePolicy<T>
23  {
24  public:
25 
26  typedef typename T::Result Result;
27 
28  NotCached (T* context) : CalculatePolicy<T> (context) { }
29 
31  Result evaluate (std::vector<Result>* grad) const try
32  {
33  if (grad)
34  grad->resize (this->get_context()->get_nparam());
35 
36  Result r;
37  this->calculate (r, grad);
38 
39  this->get_context()->set_evaluation_changed (false);
40  return r;
41  }
42  catch (Error& error)
43  {
44  throw error += class_name() + "evaluate";
45  }
46 
48  std::string class_name() const
49  { return "MEAL::NotCached[" + this->get_context()->get_name() + "]::"; }
50 
51  };
52 
53 }
54 
55 #endif
Abstract base class of Function parameter policies.
Definition: CalculatePolicy.h:25
Function * get_context() const
Return the Function for whom this policy operates.
Definition: FunctionPolicy.h:37
Namespace in which all modeling and calibration related code is declared.
Definition: ExampleComplex2.h:16
An evaluation policy that does not cache calculations.
Definition: NotCached.h:27
void set_evaluation_changed(bool _changed=true)
Set true if the Function evaluation has changed.
Definition: Function.C:129
Result evaluate(std::vector< Result > *grad) const
Implement the evaluate method of the Function.
Definition: NotCached.h:41
virtual std::string get_name() const =0
Return the name of the class.
std::string class_name() const
Return the name of the class for debugging.
Definition: NotCached.h:58

Generated using doxygen 1.8.17