codac 2.0.0
Loading...
Searching...
No Matches
codac2_TDomain.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <list>
13#include <map>
14#include <memory>
15#include <vector>
16#include "codac2_TSlice.h"
17
18namespace codac2
19{
37 class TDomain : private std::list<TSlice>
38 {
39 protected:
40
48 explicit TDomain(const Interval& t0_tf);
49
61 explicit TDomain(const Interval& t0_tf, double dt, bool with_gates = true);
62
63 public:
64
65 // Keep the list iterator types and traversal API public, but not its
66 // structural modifiers. Temporal bounds must only be changed by TDomain.
67 using std::list<TSlice>::value_type;
68 using std::list<TSlice>::size_type;
69 using std::list<TSlice>::difference_type;
70 using std::list<TSlice>::reference;
71 using std::list<TSlice>::const_reference;
72 using std::list<TSlice>::iterator;
73 using std::list<TSlice>::const_iterator;
74 using std::list<TSlice>::reverse_iterator;
75 using std::list<TSlice>::const_reverse_iterator;
76 using std::list<TSlice>::begin;
77 using std::list<TSlice>::end;
78 using std::list<TSlice>::cbegin;
79 using std::list<TSlice>::cend;
80 using std::list<TSlice>::rbegin;
81 using std::list<TSlice>::rend;
82 using std::list<TSlice>::crbegin;
83 using std::list<TSlice>::crend;
84 using std::list<TSlice>::front;
85 using std::list<TSlice>::back;
86 using std::list<TSlice>::size;
87 using std::list<TSlice>::empty;
88
89 // Slices and the time index refer to the nodes of this particular list.
90 TDomain(const TDomain&) = delete;
91 TDomain& operator=(const TDomain&) = delete;
92 TDomain(TDomain&&) = delete;
93 TDomain& operator=(TDomain&&) = delete;
94
101
109 size_t nb_tslices() const;
110
116 size_t nb_tubes() const;
117
127 bool all_gates_defined() const;
128
134 std::vector<TSlice> tslices_vector() const;
135
148 std::list<TSlice>::iterator tslice(double t);
149
161 std::list<TSlice>::iterator sample(double t, bool with_gate = false);
162
173 void sample(const Interval& t0_tf, double dt, bool with_gates = false);
174
181
191 void truncate(const Interval& new_tdomain);
192
203 friend std::ostream& operator<<(std::ostream& os, const TDomain& x);
204
216 static bool are_same(const std::shared_ptr<const TDomain>& tdom1, const std::shared_ptr<const TDomain>& tdom2);
217
218 private:
219
220 // One entry per distinct lower bound, pointing to the first TSlice
221 // at that time (the gate, if present).
222 std::map<double,std::list<TSlice>::iterator> _time_index;
223
224 std::list<TSlice>::iterator insert_tslice(std::list<TSlice>::iterator pos, const TSlice& ts);
225 std::list<TSlice>::iterator erase_tslice(std::list<TSlice>::iterator it);
226
227 protected:
228
229 friend std::shared_ptr<TDomain> create_tdomain(const Interval& t0_tf);
230 friend std::shared_ptr<TDomain> create_tdomain(const Interval& t0_tf,double dt,bool with_gates);
231 };
232
242 std::shared_ptr<TDomain> create_tdomain(const Interval& t0_tf = Interval(-oo,oo));
243
255 std::shared_ptr<TDomain> create_tdomain(const Interval& t0_tf, double dt, bool with_gates = true);
256}
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:50
void truncate(const Interval &new_tdomain)
Restricts this temporal domain to a subdomain.
size_t nb_tslices() const
Returns the number of temporal elements stored in this partition.
friend std::shared_ptr< TDomain > create_tdomain(const Interval &t0_tf)
Creates a temporal domain made of a single slice.
void delete_gates()
Removes all explicit gates from this temporal domain.
static bool are_same(const std::shared_ptr< const TDomain > &tdom1, const std::shared_ptr< const TDomain > &tdom2)
Tests whether two temporal domains share the same temporal partition.
std::vector< TSlice > tslices_vector() const
Returns a copy of the temporal slices as a std::vector.
friend std::shared_ptr< TDomain > create_tdomain(const Interval &t0_tf, double dt, bool with_gates)
Creates a sampled temporal domain.
friend std::ostream & operator<<(std::ostream &os, const TDomain &x)
Stream output for a temporal domain.
Interval t0_tf() const
Returns the global temporal domain .
TDomain(const Interval &t0_tf)
Creates a temporal domain made of a single TSlice.
void sample(const Interval &t0_tf, double dt, bool with_gates=false)
Samples this temporal domain over a time interval.
size_t nb_tubes() const
Returns the number of sliced tubes attached to this temporal domain.
TDomain(const Interval &t0_tf, double dt, bool with_gates=true)
Creates a sampled temporal domain over .
bool all_gates_defined() const
Tests whether all sampling gates are explicitly represented.
std::list< TSlice >::iterator tslice(double t)
Returns the temporal slice containing .
std::list< TSlice >::iterator sample(double t, bool with_gate=false)
Samples this temporal domain at time .
Temporal slice shared by sliced tubes.
Definition codac2_TSlice.h:35
Definition codac2_OctaSym.h:21
std::shared_ptr< TDomain > create_tdomain(const Interval &t0_tf=Interval(-oo, oo))
Creates a temporal domain made of a single slice.