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