codac 1.5.6
Loading...
Searching...
No Matches
codac2_TubeEvaluation.h
Go to the documentation of this file.
1
12#ifndef __CODAC2_TUBEEVALUATION_H__
13#define __CODAC2_TUBEEVALUATION_H__
14
15template<class T>
16class TubeEvaluation
17{
18 public:
19
20 TubeEvaluation& operator=(const T& x)
21 {
22 // Sampling the tube only if affectation is performed
23 // (i.e. this is not done in the constructor)
24 std::list<TSlice>::iterator it_lb = _tube->tdomain()->sample(_t.lb(), _t.is_degenerated());
25 std::list<TSlice>::iterator it_ub;
26
27 if(!_t.is_degenerated())
28 {
29 it_ub = _tube->tdomain()->sample(_t.ub(), false);
30 it_ub--; // pointing to the tslice [..,_t.ub()]
31
32 if(it_lb->t0_tf().ub() == _t.lb())
33 it_lb++;
34 }
35
36 else
37 it_ub = it_lb;
38
39 do
40 {
41 _tube->operator()(it_lb).set(x);
42 } while(it_lb != it_ub && (++it_lb) != _tube->tdomain()->tslices().end());
43
44 return *this;
45 }
46
47 explicit operator T() const
48 {
49 return _tube->eval(_t);
50 }
51
52 friend std::ostream& operator<<(std::ostream& os, const TubeEvaluation<T>& x)
53 {
54 os << x._tube->eval(x._t) << std::flush;
55 return os;
56 }
57
58
59 protected:
60
61 explicit TubeEvaluation(Tube<T> *tubevector, double t) :
62 _t(Interval(t)), _tube(tubevector)
63 {
64
65 }
66
67 explicit TubeEvaluation(Tube<T> *tubevector, const Interval& t) :
68 _t(t), _tube(tubevector)
69 {
70
71 }
72
73 const Interval _t;
74 Tube<T>* _tube;
75 template<typename U>
76 friend class Tube;
77};
78
79template<class T>
80class ConstTubeEvaluation
81{
82 public:
83
84 explicit operator T() const
85 {
86 return _tube->eval(_t);
87 }
88
89 friend std::ostream& operator<<(std::ostream& os, const ConstTubeEvaluation<T>& x)
90 {
91 os << x._tube->eval(x._t) << std::flush;
92 return os;
93 }
94
95
96 protected:
97
98 explicit ConstTubeEvaluation(const Tube<T> *tubevector, double t) :
99 _t(Interval(t)), _tube(tubevector)
100 {
101
102 }
103
104 explicit ConstTubeEvaluation(const Tube<T> *tubevector, const Interval& t) :
105 _t(t), _tube(tubevector)
106 {
107
108 }
109
110 const Interval _t;
111 const Tube<T>* _tube;
112 template<typename U>
113 friend class Tube;
114};
115
116#endif