seqvec.h
1 /***************************************************************************
2  seqvec.h - description
3  -------------------
4  begin : Mon Aug 19 2002
5  copyright : (C) 2000-2015 by Thies H. Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef SEQVEC_H
19 #define SEQVEC_H
20 
21 #include <odinseq/seqclass.h>
22 
23 class SeqCounter; // forward declaration
24 class SeqReorderVector; // forward declaration
25 
27 
37 enum encodingScheme {linearEncoding=0, reverseEncoding, centerOutEncoding, centerInEncoding, maxDistEncoding};
38 
39 
48 enum reorderScheme {noReorder=0,rotateReorder,blockedSegmented,interleavedSegmented};
49 
50 
51 
61 enum nestingRelation {noRelation=0, reorderInner, vecInner, unrolledLoop};
62 
64 
70 class SeqVector : public ListItem<SeqVector>, public Handled<const SeqVector*>, public virtual SeqClass {
71 
72  public:
73 
77  SeqVector(const STD_string& object_label="unnamedSeqVector");
78 
85  SeqVector(const STD_string& object_label, unsigned int nindices, int slope=1, int offset=0 );
86 
90  SeqVector(const SeqVector& sv);
91 
95  virtual ~SeqVector();
96 
100  SeqVector& operator = (const SeqVector& sv);
101 
102 
107  virtual unsigned int get_vectorsize() const {return indexvec.size();}
108 
109 
115  virtual unsigned int get_numof_iterations() const;
116 
117 
122  virtual bool needs_unrolling_check() const {return false;}
123 
124 
129  virtual bool prep_iteration() const {return true;}
130 
131 
136  virtual int get_current_index() const;
137 
143  int get_acq_index() const;
144 
150  virtual bool is_qualvector() const;
151 
156  virtual bool is_acq_vector() const;
157 
161  virtual bool is_obj_vector() const {return false;}
162 
163 
170  virtual svector get_vector_commands(const STD_string& iterator) const {return svector();}
171 
172 
176  virtual STD_string get_loopcommand() const {return "";}
177 
178 
183  SeqVector& set_indexvec(const ivector& iv) {indexvec=iv; return *this;}
184 
189  ivector get_indexvec() const {return indexvec;}
190 
191 
195  SeqVector& set_reorder_scheme(reorderScheme scheme, unsigned int nsegments=1);
196 
201 
202 
206  const SeqVector& get_reorder_vector() const;
207 
208 
212  virtual nestingRelation get_nesting_relation() const;
213 
214 
220  iarray get_index_matrix() const;
221 
225  int get_current_reord_index() const;
226 
230  STD_string get_reord_iterator(const STD_string& iterator) const;
231 
232 
233  protected:
234 
238  virtual svector get_reord_vector_commands(const STD_string& iterator) const {return svector();}
239 
243  bool is_handled() const {return vechandler.get_handled();}
244 
245  private:
246  friend class SeqReorderVector;
247  friend class SeqCounter;
248  friend class SeqObjLoop;
249  friend class SeqSimultanVector;
250 
251 #ifdef SELF_FRIEND_CLASS
252 #ifndef USING_GCC
253  friend class SeqVector; // making the class itself a friend is required for MSVC6 !!
254 #endif
255 #endif
256 
260  bool loopcounter_is_active() const;
261 
265  int get_loopcounter() const;
266 
267 
268  void common_int();
269 
270 
271  virtual const SeqVector& set_vechandler(const SeqCounter *sc) const;
272 
273  ivector indexvec;
274 
275  Handler<const SeqCounter*> vechandler;
276  Handler<const SeqVector*> simhandler;
277 
278  mutable SeqReorderVector* reordvec;
279 
280  mutable nestingRelation nr_cache;
281  mutable bool nr_cache_up2date;
282 };
283 
285 
286 
287 
293 class SeqReorderVector : public SeqVector {
294 
295  public:
296  SeqReorderVector(const SeqVector* user, const SeqReorderVector* copy_templ=0);
297 
298  unsigned int get_reordered_size(unsigned int vecsize) const;
299 
300  int get_reordered_index(int counter) const {return get_reordered_index(counter,get_current_index());}
301 
302 
303  private:
304  friend class SeqVector;
305 
306  // implemented virtual functions of SeqVector
307  unsigned int get_vectorsize() const;
308  bool needs_unrolling_check() const {return reord_scheme!=noReorder;}
309  bool prep_iteration() const {return reorder_user->prep_iteration();}
310  bool is_qualvector() const {return reorder_user->is_qualvector();}
311  bool is_acq_vector() const {return reorder_user->is_acq_vector();}
312  svector get_vector_commands(const STD_string& iterator) const;
313 
314 
315  int get_reordered_index(int counter, int reord_iteration) const;
316 
317  STD_string get_reordered_iterator(const STD_string& iterator) const;
318 
319  void clear_cache() {reord_iterator_cache="";}
320 
321  reorderScheme reord_scheme;
322  unsigned int n_reord_segments;
323 
324  encodingScheme encoding_scheme;
325 
326  const SeqVector* reorder_user;
327 
328  mutable STD_string reord_iterator_cache;
329 };
330 
331 
332 #endif
virtual bool is_acq_vector() const
virtual STD_string get_loopcommand() const
Definition: seqvec.h:176
SeqVector & set_reorder_scheme(reorderScheme scheme, unsigned int nsegments=1)
virtual svector get_reord_vector_commands(const STD_string &iterator) const
Definition: seqvec.h:238
virtual bool needs_unrolling_check() const
Definition: seqvec.h:122
int get_acq_index() const
virtual ~SeqVector()
nestingRelation
Definition: seqvec.h:61
reorderScheme
Definition: seqvec.h:48
virtual bool is_qualvector() const
SeqVector & set_indexvec(const ivector &iv)
Definition: seqvec.h:183
SeqVector(const STD_string &object_label="unnamedSeqVector")
iarray get_index_matrix() const
virtual int get_current_index() const
SeqVector & operator=(const SeqVector &sv)
virtual svector get_vector_commands(const STD_string &iterator) const
Definition: seqvec.h:170
virtual bool is_obj_vector() const
Definition: seqvec.h:161
virtual unsigned int get_numof_iterations() const
virtual nestingRelation get_nesting_relation() const
virtual bool prep_iteration() const
Definition: seqvec.h:129
encodingScheme
Definition: seqvec.h:37
virtual unsigned int get_vectorsize() const
Definition: seqvec.h:107
ivector get_indexvec() const
Definition: seqvec.h:189
const SeqVector & get_reorder_vector() const
SeqVector & set_encoding_scheme(encodingScheme scheme)
STD_string get_reord_iterator(const STD_string &iterator) const
int get_current_reord_index() const
bool is_handled() const
Definition: seqvec.h:243
Sequence Loop.
Definition: seqloop.h:38