ImmediateTreeDataKernels.h
Go to the documentation of this file.
1 #ifndef GfxTL__IMMEDIATETREEDATAKERNELS_HEADER__
2 #define GfxTL__IMMEDIATETREEDATAKERNELS_HEADER__
3 #include <GfxTL/Swap.h>
4 #include <iterator>
5 
6 namespace GfxTL
7 {
8  // ImmediateTreeDataKernels let the tree operate directly on the data,
9  // i.e. the data can be reordered to accomodate the tree cell structure.
10  // Therefore a const DataT cannot be accepted.
11  // There are two possibilities how the kernels maintain the data. The
12  // first option makes the data a member of the strategy itself.
13  // The second option operates on a range of random access iterators.
14  // The two options are implemented as two different Kernels
15  // ImmediateMemberTreeDataKernel is a realization of the first possibility
16  // ImmediateIteratorTreeDataKernel implements the second one
17 
18  template< class DataT >
20  {
21  public:
22  typedef typename DataT::value_type value_type;
23  typedef typename DataT::size_type HandleType;
25  typedef typename DataT::iterator iterator;
26  typedef typename DataT::const_iterator const_iterator;
27 
28  DataT& ContainedData()
29  {
30  return m_data;
31  }
32 
33  const DataT& ContainedData() const
34  {
35  return m_data;
36  }
37 
39  {
40  return h;
41  }
42 
44  {
45  return m_data.at(s);
46  }
47 
49  {
50  return m_data.at(s);
51  }
52 
54  {
55  return m_data.back();
56  }
57 
58  const value_type& back() const
59  {
60  return m_data.back();
61  }
62 
64  {
65  return m_data.begin();
66  }
67 
69  {
70  return m_data.end();
71  }
72 
74  {
75  return m_data.begin();
76  }
77 
79  {
80  return m_data.end();
81  }
82 
83  size_t size() const
84  {
85  return m_data.size();
86  }
87 
89  {
90  return 0;
91  }
93  {
94  return size();
95  }
96 
97  protected:
99  {
100  Swap(a, b, &m_data);
101  }
102 
104  {
105  /*
106  value_type v = back();
107  std::copy_backward(begin() + range.second - 1, end() - 1, end());
108  at(range.second - 1) = v;
109  */
110  }
111 
113  {
114  m_data.erase(m_data.begin() + s);
115  }
116 
117  private:
118  DataT m_data;
119  };
120 
121  template< class DataT >
123  {
124  public:
125  typedef typename DataT::value_type value_type;
126  typedef typename DataT::size_type HandleType;
128  typedef typename DataT::iterator iterator;
129  typedef typename DataT::const_iterator const_iterator;
130 
131  void ContainedData(DataT* data)
132  {
133  m_data = data;
134  }
135 
136  DataT& ContainedData()
137  {
138  return *m_data;
139  }
140 
141  const DataT& ContainedData() const
142  {
143  return *m_data;
144  }
145 
147  {
148  return h;
149  }
150 
152  {
153  return m_data->at(s);
154  }
155 
157  {
158  return m_data->at(s);
159  }
160 
162  {
163  return m_data->back();
164  }
165 
166  const value_type& back() const
167  {
168  return m_data->back();
169  }
170 
172  {
173  return m_data->begin();
174  }
175 
177  {
178  return m_data->end();
179  }
180 
182  {
183  return m_data->begin();
184  }
185 
187  {
188  return m_data->end();
189  }
190 
191  size_t size() const
192  {
193  return m_data->size();
194  }
195 
197  {
198  return 0;
199  }
201  {
202  return size();
203  }
204 
205  protected:
207  {
208  Swap(a, b, m_data);
209  }
210 
212  {
213  /*value_type v = back();
214  std::copy_backward(begin() + range.second - 1, end() - 1, end());
215  at(range.second - 1) = v;*/
216  }
217 
219  {
220  m_data->erase(m_data->begin() + s);
221  }
222 
223  private:
224  DataT* m_data;
225  };
226 
227  template< class DataT >
229  {
230  public:
231  typedef typename DataT::value_type value_type;
232  typedef typename DataT::size_type HandleType;
234  typedef typename DataT::iterator iterator;
235  typedef typename DataT::const_iterator const_iterator;
236 
237  void ContainedData(DataT* data)
238  {
239  m_data = data;
240  }
241 
243  {
244  m_beginRange = begin;
245  m_endRange = end;
246  }
247 
248  DataT& ContainedData()
249  {
250  return *m_data;
251  }
252 
253  const DataT& ContainedData() const
254  {
255  return *m_data;
256  }
257 
259  {
260  return h;
261  }
262 
264  {
265  return m_data->at(s);
266  }
267 
269  {
270  return m_data->at(s);
271  }
272 
274  {
275  return m_data->begin() + m_endRange - 1;
276  }
277 
278  const value_type& back() const
279  {
280  return m_data->begin() + m_endRange - 1;
281  }
282 
284  {
285  return m_data->begin() + m_beginRange;
286  }
287 
289  {
290  return m_data->begin() + m_endRange;
291  }
292 
294  {
295  return m_data->begin() + m_beginRange;
296  }
297 
299  {
300  return m_data->begin() + m_endRange;
301  }
302 
303  HandleType size() const
304  {
305  return m_endRange - m_beginRange;
306  }
307 
309  {
310  return m_beginRange;
311  }
313  {
314  return m_endRange;
315  }
316 
317  protected:
319  {
320  Swap(a, b, m_data);
321  }
322 
324  {
325  /*value_type v = back();
326  std::copy_backward(begin() + range.second - 1, end() - 1, end());
327  at(range.second - 1) = v;*/
328  }
329 
331  {
332  m_data->erase(m_data->begin() + s);
333  }
334 
335  private:
336  DataT* m_data;
337  HandleType m_beginRange;
338  HandleType m_endRange;
339  };
340 
341  // this kernel does not support insertion or removal
342  template< class IteratorT >
344  {
345  public:
346  typedef typename std::iterator_traits< IteratorT >::value_type value_type;
347  typedef typename std::iterator_traits< IteratorT >::reference reference;
348  typedef size_t HandleType;
350  typedef IteratorT iterator;
351  typedef IteratorT const_iterator;
352 
353  void Begin(IteratorT begin)
354  {
355  m_begin = begin;
356  }
357 
358  void End(IteratorT end)
359  {
360  m_end = end;
361  }
362 
364  {
365  return h;
366  }
367 
369  {
370  return m_begin[s];
371  }
372 
374  {
375  return m_begin[s];
376  }
377 
379  {
380  return *(m_end - 1);
381  }
382 
383  reference back() const
384  {
385  return *(m_end - 1);
386  }
387 
389  {
390  return m_begin;
391  }
392 
394  {
395  return m_end;
396  }
397 
399  {
400  return m_begin;
401  }
402 
404  {
405  return m_end;
406  }
407 
408  size_t size() const
409  {
410  return m_end - m_begin;
411  }
412 
414  {
415  return 0;
416  }
418  {
419  return size();
420  }
421 
422  protected:
424  {
425  using namespace std;
426  swap(at(a), at(b));
427  }
428 
429  private:
430  IteratorT m_begin;
431  IteratorT m_end;
432  };
433 };
434 
435 #endif
GfxTL::ImmediateRangeTreeDataKernel::ContainedData
const DataT & ContainedData() const
Definition: ImmediateTreeDataKernels.h:253
GfxTL::ImmediateIteratorTreeDataKernel::End
void End(IteratorT end)
Definition: ImmediateTreeDataKernels.h:358
GfxTL::ImmediateMemberTreeDataKernel::begin
const_iterator begin() const
Definition: ImmediateTreeDataKernels.h:73
GfxTL::ImmediateMemberTreeDataKernel::ContainedData
const DataT & ContainedData() const
Definition: ImmediateTreeDataKernels.h:33
GfxTL::ImmediateIteratorTreeDataKernel::back
reference back()
Definition: ImmediateTreeDataKernels.h:378
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::at
const value_type & at(DereferencedType s) const
Definition: ImmediateTreeDataKernels.h:156
GfxTL::ImmediateRangeTreeDataKernel::end
const_iterator end() const
Definition: ImmediateTreeDataKernels.h:298
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::begin
const_iterator begin() const
Definition: ImmediateTreeDataKernels.h:181
GfxTL::ImmediateMemberTreeDataKernel::value_type
DataT::value_type value_type
Definition: ImmediateTreeDataKernels.h:22
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::Remove
void Remove(DereferencedType s)
Definition: ImmediateTreeDataKernels.h:218
GfxTL::ImmediateRangeTreeDataKernel::size
HandleType size() const
Definition: ImmediateTreeDataKernels.h:303
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::begin
iterator begin()
Definition: ImmediateTreeDataKernels.h:171
GfxTL::ImmediateMemberTreeDataKernel::at
const value_type & at(DereferencedType s) const
Definition: ImmediateTreeDataKernels.h:48
GfxTL::ImmediateIteratorTreeDataKernel
Definition: ImmediateTreeDataKernels.h:343
GfxTL::ImmediateRangeTreeDataKernel::back
const value_type & back() const
Definition: ImmediateTreeDataKernels.h:278
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::EndHandle
HandleType EndHandle() const
Definition: ImmediateTreeDataKernels.h:200
GfxTL::ImmediateMemberTreeDataKernel::Remove
void Remove(DereferencedType s)
Definition: ImmediateTreeDataKernels.h:112
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::iterator
DataT::iterator iterator
Definition: ImmediateTreeDataKernels.h:128
GfxTL::ImmediateMemberTreeDataKernel::begin
iterator begin()
Definition: ImmediateTreeDataKernels.h:63
GfxTL::ImmediateRangeTreeDataKernel::begin
iterator begin()
Definition: ImmediateTreeDataKernels.h:283
GfxTL::ImmediateIteratorTreeDataKernel::BeginHandle
HandleType BeginHandle() const
Definition: ImmediateTreeDataKernels.h:413
GfxTL::ImmediateIteratorTreeDataKernel::DereferencedType
HandleType DereferencedType
Definition: ImmediateTreeDataKernels.h:349
GfxTL::ImmediateMemberTreeDataKernel::DereferencedType
HandleType DereferencedType
Definition: ImmediateTreeDataKernels.h:24
Swap.h
GfxTL::ImmediateIteratorTreeDataKernel::begin
iterator begin()
Definition: ImmediateTreeDataKernels.h:388
GfxTL::ImmediateMemberTreeDataKernel::back
value_type & back()
Definition: ImmediateTreeDataKernels.h:53
GfxTL::ImmediateIteratorTreeDataKernel::Begin
void Begin(IteratorT begin)
Definition: ImmediateTreeDataKernels.h:353
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::back
const value_type & back() const
Definition: ImmediateTreeDataKernels.h:166
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::SwapHandles
void SwapHandles(HandleType a, HandleType b)
Definition: ImmediateTreeDataKernels.h:206
GfxTL::ImmediateIteratorTreeDataKernel::end
const_iterator end() const
Definition: ImmediateTreeDataKernels.h:403
GfxTL::ImmediateRangeTreeDataKernel::BeginHandle
HandleType BeginHandle() const
Definition: ImmediateTreeDataKernels.h:308
GfxTL::ImmediateRangeTreeDataKernel::SwapHandles
void SwapHandles(HandleType a, HandleType b)
Definition: ImmediateTreeDataKernels.h:318
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::BeginHandle
HandleType BeginHandle() const
Definition: ImmediateTreeDataKernels.h:196
GfxTL::ImmediateIteratorTreeDataKernel::value_type
std::iterator_traits< IteratorT >::value_type value_type
Definition: ImmediateTreeDataKernels.h:346
GfxTL::ImmediateMemberTreeDataKernel::SwapHandles
void SwapHandles(HandleType a, HandleType b)
Definition: ImmediateTreeDataKernels.h:98
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::end
iterator end()
Definition: ImmediateTreeDataKernels.h:176
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::DereferencedType
HandleType DereferencedType
Definition: ImmediateTreeDataKernels.h:127
GfxTL::ImmediateIteratorTreeDataKernel::EndHandle
HandleType EndHandle() const
Definition: ImmediateTreeDataKernels.h:417
GfxTL::ImmediateMemberTreeDataKernel::const_iterator
DataT::const_iterator const_iterator
Definition: ImmediateTreeDataKernels.h:26
armarx::armem::client::util::swap
void swap(SubscriptionHandle &first, SubscriptionHandle &second)
Definition: SubscriptionHandle.cpp:66
GfxTL::ImmediateRangeTreeDataKernel::DereferencedType
HandleType DereferencedType
Definition: ImmediateTreeDataKernels.h:233
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::Dereference
DereferencedType Dereference(HandleType h) const
Definition: ImmediateTreeDataKernels.h:146
GfxTL::ImmediateMemberTreeDataKernel::size
size_t size() const
Definition: ImmediateTreeDataKernels.h:83
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::ContainedData
void ContainedData(DataT *data)
Definition: ImmediateTreeDataKernels.h:131
GfxTL::ImmediateRangeTreeDataKernel::EndHandle
HandleType EndHandle() const
Definition: ImmediateTreeDataKernels.h:312
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::const_iterator
DataT::const_iterator const_iterator
Definition: ImmediateTreeDataKernels.h:129
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
GfxTL::ImmediateRangeTreeDataKernel::Dereference
DereferencedType Dereference(HandleType h) const
Definition: ImmediateTreeDataKernels.h:258
GfxTL::ImmediateMemberTreeDataKernel::back
const value_type & back() const
Definition: ImmediateTreeDataKernels.h:58
GfxTL::ImmediateIteratorTreeDataKernel::reference
std::iterator_traits< IteratorT >::reference reference
Definition: ImmediateTreeDataKernels.h:347
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::end
const_iterator end() const
Definition: ImmediateTreeDataKernels.h:186
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
GfxTL::ImmediateMemberTreeDataKernel::HandleType
DataT::size_type HandleType
Definition: ImmediateTreeDataKernels.h:23
GfxTL::ImmediateMemberTreeDataKernel::BeginHandle
HandleType BeginHandle() const
Definition: ImmediateTreeDataKernels.h:88
GfxTL::ImmediateMemberTreeDataKernel::Dereference
DereferencedType Dereference(HandleType h) const
Definition: ImmediateTreeDataKernels.h:38
GfxTL::ImmediateIteratorTreeDataKernel::SwapHandles
void SwapHandles(HandleType a, HandleType b)
Definition: ImmediateTreeDataKernels.h:423
GfxTL::ImmediateMemberTreeDataKernel::iterator
DataT::iterator iterator
Definition: ImmediateTreeDataKernels.h:25
GfxTL::ImmediateMemberTreeDataKernel::end
iterator end()
Definition: ImmediateTreeDataKernels.h:68
GfxTL::ImmediateIteratorTreeDataKernel::const_iterator
IteratorT const_iterator
Definition: ImmediateTreeDataKernels.h:351
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::size
size_t size() const
Definition: ImmediateTreeDataKernels.h:191
GfxTL::ImmediateRangeTreeDataKernel::ContainedData
DataT & ContainedData()
Definition: ImmediateTreeDataKernels.h:248
GfxTL::ImmediateRangeTreeDataKernel::const_iterator
DataT::const_iterator const_iterator
Definition: ImmediateTreeDataKernels.h:235
GfxTL::ImmediateIteratorTreeDataKernel::size
size_t size() const
Definition: ImmediateTreeDataKernels.h:408
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::value_type
DataT::value_type value_type
Definition: ImmediateTreeDataKernels.h:125
GfxTL::ImmediateRangeTreeDataKernel::HandleType
DataT::size_type HandleType
Definition: ImmediateTreeDataKernels.h:232
GfxTL
Definition: AABox.h:8
GfxTL::ImmediateIteratorTreeDataKernel::Dereference
DereferencedType Dereference(HandleType h) const
Definition: ImmediateTreeDataKernels.h:363
GfxTL::ImmediateRangeTreeDataKernel::end
iterator end()
Definition: ImmediateTreeDataKernels.h:288
GfxTL::ImmediateMemberTreeDataKernel::InsertBack
void InsertBack(HandleType h)
Definition: ImmediateTreeDataKernels.h:103
GfxTL::ImmediateMemberTreeDataKernel::EndHandle
HandleType EndHandle() const
Definition: ImmediateTreeDataKernels.h:92
GfxTL::ImmediateIteratorTreeDataKernel::back
reference back() const
Definition: ImmediateTreeDataKernels.h:383
GfxTL::ImmediateRangeTreeDataKernel::Remove
void Remove(DereferencedType s)
Definition: ImmediateTreeDataKernels.h:330
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::ContainedData
DataT & ContainedData()
Definition: ImmediateTreeDataKernels.h:136
GfxTL::ImmediateRangeTreeDataKernel::ContainedData
void ContainedData(DataT *data)
Definition: ImmediateTreeDataKernels.h:237
GfxTL::ImmediateIteratorTreeDataKernel::end
iterator end()
Definition: ImmediateTreeDataKernels.h:393
GfxTL::ImmediateRangeTreeDataKernel
Definition: ImmediateTreeDataKernels.h:228
std
Definition: Application.h:66
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::InsertBack
void InsertBack(HandleType h)
Definition: ImmediateTreeDataKernels.h:211
GfxTL::ImmediateIteratorTreeDataKernel::at
reference at(DereferencedType s) const
Definition: ImmediateTreeDataKernels.h:373
GfxTL::ImmediateRangeTreeDataKernel::iterator
DataT::iterator iterator
Definition: ImmediateTreeDataKernels.h:234
GfxTL::ImmediateRangeTreeDataKernel::value_type
DataT::value_type value_type
Definition: ImmediateTreeDataKernels.h:231
GfxTL::ImmediateIteratorTreeDataKernel::iterator
IteratorT iterator
Definition: ImmediateTreeDataKernels.h:350
GfxTL::ImmediateIteratorTreeDataKernel::at
reference at(DereferencedType s)
Definition: ImmediateTreeDataKernels.h:368
GfxTL::ImmediateRangeTreeDataKernel::at
const value_type & at(DereferencedType s) const
Definition: ImmediateTreeDataKernels.h:268
GfxTL::ImmediateIteratorTreeDataKernel::HandleType
size_t HandleType
Definition: ImmediateTreeDataKernels.h:348
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::back
value_type & back()
Definition: ImmediateTreeDataKernels.h:161
GfxTL::ImmediateMemberTreeDataKernel::ContainedData
DataT & ContainedData()
Definition: ImmediateTreeDataKernels.h:28
GfxTL::ImmediateRangeTreeDataKernel::InsertBack
void InsertBack(HandleType h)
Definition: ImmediateTreeDataKernels.h:323
GfxTL::ImmediateMemberTreeDataKernel::at
value_type & at(DereferencedType s)
Definition: ImmediateTreeDataKernels.h:43
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::at
value_type & at(DereferencedType s)
Definition: ImmediateTreeDataKernels.h:151
GfxTL::ImmediateIteratorTreeDataKernel::begin
const_iterator begin() const
Definition: ImmediateTreeDataKernels.h:398
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
GfxTL::Swap
void Swap(HandleT a, HandleT b, ContainerT *container)
Definition: Swap.h:9
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::HandleType
DataT::size_type HandleType
Definition: ImmediateTreeDataKernels.h:126
GfxTL::ImmediateMemberTreeDataKernel
Definition: ImmediateTreeDataKernels.h:19
GfxTL::ImmediateMemberTreeDataKernel::end
const_iterator end() const
Definition: ImmediateTreeDataKernels.h:78
GfxTL::ImmediateRangeTreeDataKernel::begin
const_iterator begin() const
Definition: ImmediateTreeDataKernels.h:293
GfxTL::ImmediateMemberTreeDataKernel< DataT * >::ContainedData
const DataT & ContainedData() const
Definition: ImmediateTreeDataKernels.h:141
GfxTL::ImmediateRangeTreeDataKernel::DataRange
void DataRange(HandleType begin, HandleType end)
Definition: ImmediateTreeDataKernels.h:242
GfxTL::ImmediateRangeTreeDataKernel::back
value_type & back()
Definition: ImmediateTreeDataKernels.h:273
GfxTL::ImmediateRangeTreeDataKernel::at
value_type & at(DereferencedType s)
Definition: ImmediateTreeDataKernels.h:263