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
19namespace MEAL {
20
22
24
25 template<typename T>
26 std::string axis_value_to_string(const T& axis_value) { return tostring(axis_value); }
27
28 template<class Type>
29 class Axis : public Argument {
30
31 public:
32
34
36 class Value : public Argument::Value {
37
38 public:
39
40 friend class Axis;
41
43 Value (const Type& _value) { value = _value; }
44
46 void set_value (const Type& _value) { value = _value; }
47
49 Type get_value () const { return value; }
50
52 operator Type () const { return value; }
53
54 // ///////////////////////////////////////////////////////////////////
55 //
56 // Argument::Value implementation
57 //
58 // ///////////////////////////////////////////////////////////////////
59
61 void apply () const override
62 {
63 axis->set_value (value);
64 }
65
67 std::string get_string () const override
68 {
70 }
71
72 protected:
73
75 Value (const Type& _value, Axis* _axis) { value = _value; axis = _axis; }
76
78 Type value;
79
82
83 };
84
86 Value* new_Value (const Type& value) { return new Value(value, this); }
87
89 Value get_Value (const Type& value) { return Value(value, this); }
90
92 void set_value (const Type& value)
93 { signal.send (value); current_value = value; }
94
96 Type get_value () const { return current_value; }
97
99 Callback<Type> signal;
100
101 protected:
102
103 Type current_value;
104
105 };
106
107}
108
109#endif
110
void send(const Type &data)
The value of an argument.
Definition Argument.h:36
A value of the independent variable represented by Axis.
Definition Axis.h:36
Type value
The value of this instance.
Definition Axis.h:78
std::string get_string() const override
Return a string representation of the value, if posssible.
Definition Axis.h:67
void apply() const override
Apply the value.
Definition Axis.h:61
Reference::To< Axis > axis
The Axis on which this value applies.
Definition Axis.h:81
Value(const Type &_value)
Construct with value.
Definition Axis.h:43
void set_value(const Type &_value)
Set the value of this instance.
Definition Axis.h:46
Value(const Type &_value, Axis *_axis)
Construct with value and Axis.
Definition Axis.h:75
Type get_value() const
Get the value of this instance.
Definition Axis.h:49
Represents a value with no free parameters.
Definition Value.h:21
Namespace in which all modeling and calibration related code is declared.
Definition ExampleComplex2.h:16
std::string axis_value_to_string(const T &axis_value)
An argument of a specified type.
Definition Axis.h:26

Generated using doxygen 1.14.0