Axis.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2004 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/MEAL/MEAL/Axis.h
10 
11 #ifndef __MEAL_Axis_Header
12 #define __MEAL_Axis_Header
13 
14 #include "MEAL/Argument.h"
15 #include "Callback.h"
16 
17 #include <iostream>
18 
19 namespace MEAL {
20 
22 
25  template<class Type>
26  class Axis : public Argument {
27 
28  public:
29 
31 
33  class Value : public Argument::Value {
34 
35  public:
36 
37  friend class Axis;
38 
40  Value (const Type& _value) { value = _value; }
41 
43  void set_value (const Type& _value) { value = _value; }
44 
46  Type get_value () const { return value; }
47 
49  operator Type () const { return value; }
50 
51  // ///////////////////////////////////////////////////////////////////
52  //
53  // Argument::Value implementation
54  //
55  // ///////////////////////////////////////////////////////////////////
56 
58  void apply () const
59  {
60  if (verbose) std::cerr << "MEAL::Axis<Type>::Value::apply value="
61  << value << std::endl;
62  axis->set_value (value);
63  }
64 
65  protected:
66 
68  Value (const Type& _value, Axis* _axis) { value = _value; axis = _axis; }
69 
71  Type value;
72 
75 
76  };
77 
79  Value* new_Value (const Type& value) { return new Value(value, this); }
80 
82  Value get_Value (const Type& value) { return Value(value, this); }
83 
85  void set_value (const Type& value)
86  { signal.send (value); current_value = value; }
87 
89  Type get_value () const { return current_value; }
90 
93 
94  protected:
95 
96  Type current_value;
97 
98  };
99 
100 }
101 
102 #endif
103 
Type value
The value of this instance.
Definition: Axis.h:86
An argument of a specified type.
Definition: Axis.h:31
void set_value(const Type &_value)
Set the value of this instance.
Definition: Axis.h:58
Represents a value with no free parameters.
Definition: Value.h:26
Value get_Value(const Type &value)
Return an instance of the Value of this argument.
Definition: Axis.h:92
void set_value(const Type &value)
Set the value of the argument represented by this axis.
Definition: Axis.h:95
Type get_value() const
Get the value of this instance.
Definition: Axis.h:61
Value * new_Value(const Type &value)
Return a new instance of the Value of this argument.
Definition: Axis.h:89
A value of the independent variable represented by Axis.
Definition: Axis.h:43
Namespace in which all modeling and calibration related code is declared.
Definition: ExampleComplex2.h:16
Callback< Type > signal
The mechanism by which methods are connected.
Definition: Axis.h:102
The value of an argument.
Definition: Argument.h:46
Reference::To< Axis > axis
The Axis on which this value applies.
Definition: Axis.h:89
Type get_value() const
Get the value of the argument represented by this axis.
Definition: Axis.h:99
void send(const Type &data)
Value(const Type &_value)
Construct with value.
Definition: Axis.h:55
void apply() const
Apply the value.
Definition: Axis.h:73
static bool verbose
Verbosity flag.
Definition: Argument.h:40

Generated using doxygen 1.8.17