ForwardResult.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/ForwardResult.h
10 
11 #ifndef __ForwardResult_H
12 #define __ForwardResult_H
13 
14 #include "MEAL/CalculatePolicy.h"
15 #include "MEAL/ForwardChanged.h"
16 #include <iostream>
17 
18 namespace MEAL {
19 
21 
22  template<class T>
23  class ForwardResult : public CalculatePolicy<T> {
24 
25  public:
26 
27  typedef typename T::Result Result;
28 
30  ForwardResult (T* context, T* function)
31  : CalculatePolicy<T> (context),
32  forward_changed (context)
33  {
34  evaluator = function;
35  forward_changed.manage (function);
36  }
37 
39  Result evaluate (std::vector<Result>* gradient = 0) const
40  {
42  std::cerr << class_name() + "evaluate" << std::endl;
43 
44  if (gradient)
45  gradient->resize (0);
46 
47  return evaluator->evaluate();
48  }
49 
51  std::string class_name() const
52  { return "MEAL::ForwardResult[" + this->get_context()->get_name() +
53  "->" + evaluator->get_name() + "]::"; }
54 
55  protected:
56 
59 
62 
63  };
64 
65 }
66 
67 #endif
Abstract base class of Function parameter policies.
Definition: CalculatePolicy.h:25
Result evaluate(std::vector< Result > *gradient=0) const
Calls to context->evaluate are forwarded to evaluator.
Definition: ForwardResult.h:49
ForwardResult(T *context, T *function)
Default constructor.
Definition: ForwardResult.h:40
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
static bool very_verbose
Low-level verbosity flag.
Definition: Function.h:57
std::string class_name() const
Return the name of the class for debugging.
Definition: ForwardResult.h:61
Reference::To< T, false > evaluator
The class that will do the evaluating.
Definition: ForwardResult.h:68
virtual std::string get_name() const =0
Return the name of the class.
void manage(Function *argument)
Begin to forward the changed status of argument to context.
Definition: ForwardChanged.C:18
Forwards changed signals from other classes.
Definition: ForwardChanged.h:25
ForwardChanged forward_changed
Forward the changed signals from the evaluator to the context.
Definition: ForwardResult.h:71

Generated using doxygen 1.8.17