codac 1.5.6
Loading...
Searching...
No Matches
codac2_SampledTrajEval.h
1
9
10#pragma once
11
12#include <map>
13#include "codac2_SampledTraj.h"
15
16namespace codac2
17{
18 template<typename T,typename X,bool READONLY=false>
19 class SampledTrajEval
20 {
21 public:
22
23 using OUTPUT_HULL = typename Wrapper<T>::Domain;
24
25 template<bool C=READONLY>
26 requires (C == false && std::is_same_v<X,double>)
27 // eval operation not yet supported for interval domains
28 SampledTrajEval<T,X,READONLY>& operator=(const T& x)
29 {
30 assert_release(size_of(x) == _x->size());
31 _x->set(_t, x);
32 return *this;
33 }
34
35 inline operator T() const
36 {
37 static_assert(std::is_same_v<X,double>);
38 return _const_x->eval(_t);
39 }
40
41 inline operator OUTPUT_HULL() const
42 {
43 return _const_x->eval(_t);
44 }
45
46 protected:
47
48 X _t;
49 SampledTraj<T> *_x = nullptr;
50 const SampledTraj<T> *_const_x;
51
52 friend class SampledTraj<T>;
53 };
54
55 template<typename T,typename X,bool READONLY>
56 inline std::ostream& operator<<(std::ostream& os, const SampledTrajEval<T,X,READONLY>& x)
57 {
58 if constexpr(std::is_same_v<X,double>)
59 os << (T)x << std::flush;
60 else if constexpr(std::is_same_v<X,Interval>)
61 os << (typename Wrapper<T>::Domain)x << std::flush;
62 return os;
63 }
64}
std::ostream & operator<<(std::ostream &os, const BoolInterval &x)
Streams out a BoolInterval.
Definition codac2_BoolInterval.h:45