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
18namespace 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 evaluator (function)
34 {
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
CalculatePolicy(T *context)
Default destructor.
Definition CalculatePolicy.h:27
Forwards changed signals from other classes.
Definition ForwardChanged.h:20
Reference::To< T, false > evaluator
The class that will do the evaluating.
Definition ForwardResult.h:58
Result evaluate(std::vector< Result > *gradient=0) const
Calls to context->evaluate are forwarded to evaluator.
Definition ForwardResult.h:39
ForwardChanged forward_changed
Forward the changed signals from the evaluator to the context.
Definition ForwardResult.h:61
std::string class_name() const
Return the name of the class for debugging.
Definition ForwardResult.h:51
ForwardResult(T *context, T *function)
Default constructor.
Definition ForwardResult.h:30
Function * get_context() const
Return the Function for whom this policy operates.
Definition FunctionPolicy.h:32
static bool very_verbose
Low-level verbosity flag.
Definition Function.h:57
virtual std::string get_name() const =0
Return the name of the class.
Namespace in which all modeling and calibration related code is declared.
Definition ExampleComplex2.h:16

Generated using doxygen 1.14.0