source: trunk/test/Suite.h @ 3846

Last change on this file since 3846 was 3846, checked in by Peter, 2 months ago

avoid compiler warning about ignoring return value from chdir

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 21.8 KB
Line 
1#ifndef _theplu_yat_test_suite_
2#define _theplu_yat_test_suite_
3
4// $Id: Suite.h 3846 2019-09-13 12:11:23Z peter $
5
6/*
7  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2009, 2010, 2011, 2013, 2014, 2015, 2016, 2018 Peter Johansson
9
10  This file is part of the yat library, http://dev.thep.lu.se/yat
11
12  The yat library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 3 of the
15  License, or (at your option) any later version.
16
17  The yat library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21
22  You should have received a copy of the GNU General Public License
23  along with yat. If not, see <http://www.gnu.org/licenses/>.
24*/
25
26// ensure that config.h always is included first
27#ifndef YAT_VERSION
28#error header 'config.h' not included
29#endif
30
31#include <yat/utility/config_public.h>
32
33#define YAT_TEST_PROLOGUE "\n=== " << __func__ << " ===\n"
34
35// used to tell automake that test should be skipped
36#define EXIT_SKIP 77
37#define EXIT_HARD_FAILURE 99
38
39// SKIP_BAM_TEST is defined if we should skip bam tests
40#if !defined (YAT_HAVE_LIBBAM) || !defined (HAVE_SAMTOOLS_EXECUTABLE)
41#define SKIP_BAM_TEST
42#endif
43
44#include <yat/utility/VectorMutable.h>
45#include <yat/utility/WeightedIteratorArchetype.h>
46#include <yat/classifier/Target.h>
47
48#include <boost/concept_archetype.hpp>
49#include <boost/concept_check.hpp>
50#include <boost/iterator/iterator_categories.hpp>
51#include <boost/iterator/iterator_concepts.hpp>
52
53#include <iosfwd>
54#include <sstream>
55#include <vector>
56
57namespace theplu {
58namespace yat {
59namespace test {
60
61  /**
62     \internal utility class for tests
63   */
64  class Suite
65  {
66  public:
67    Suite(int argc, char* argv[], bool require_bam=false);
68
69    /**
70     */
71    ~Suite(void);
72
73    /**
74       set ok to 'b && ok'
75
76       \return b
77    */
78    bool add(bool b);
79
80    /**
81       \return In verbose mode std::cerr, else a ofstream to "/dev/null".
82    */
83    std::ostream& err(void) const;
84
85    /**
86       \return true if \f$ |a-b| <= N * \epsilon * min(|a|,|b|) \f$
87       where \f$ \epsilon \f$ is std::numeric_limits<double>().epsilon()
88    */
89    bool equal(double a, double b, unsigned long int N=1);
90
91    /**
92       \return true if |\a a - \a b| <= \a margin
93    */
94    bool equal_fix(double a, double b, double margin=0);
95
96    /**
97       \return true if \f$ |a-b| <= N * sqrt(\epsilon) * min(|a|,|b|) \f$
98       where \f$ \epsilon \f$ is std::numeric_limits<double>().epsilon()
99    */
100    bool equal_sqrt(double a, double b, unsigned long int N=1);
101
102    template<class MATRIX1, class MATRIX2>
103    bool equal_matrix(const MATRIX1& a, const MATRIX2& b,unsigned long int N=1);
104
105    /**
106       apply equal on ranges [first1, last1) and [first2, ...)
107    */
108    template<typename Iterator1, typename Iterator2>
109    bool equal_range(Iterator1 first1, Iterator1 last1, Iterator2 first2,
110                     unsigned int N=1);
111
112    /**
113       apply equal_fix on ranges [first1, last1) and [first2, ...)
114    */
115    template<typename Iterator1, typename Iterator2>
116    bool equal_range_fix(Iterator1 first1, Iterator1 last1, Iterator2 first2,
117                         double margin);
118
119    /**
120      \return true if test is ok
121    */
122    bool ok(void) const;
123
124    /**
125       \return In verbose mode std::cout, else a ofstream to "/dev/null".
126    */
127    std::ostream& out(void) const;
128
129    /**
130       In verbose mode a final message is sent to std::cout.
131
132       If ok() is true: "Test is ok." otherwise
133       "Test failed."
134
135       \return 0 if ok.
136     */
137    int return_value(void) const;
138
139    template<typename TrivialIterator>
140    void test_trivial_iterator(const TrivialIterator&);
141
142    template<typename InputIterator>
143    void test_input_iterator(InputIterator&);
144
145    template<typename OutputIterator>
146    void test_output_iterator(OutputIterator&);
147
148    template<typename ForwardIterator>
149    void test_forward_iterator(ForwardIterator);
150
151    template<typename BidirectionalIterator>
152    void test_bidirectional_iterator(BidirectionalIterator);
153
154    template<typename RandomAccessIterator>
155    void test_random_access_iterator(RandomAccessIterator);
156
157    template<typename Container2D>
158    void test_concept_container2d(const Container2D&);
159
160    template<typename MutableContainer2D>
161    void test_concept_mutable_container2d(MutableContainer2D&);
162
163    /**
164       Function writes to a stream using operator<<, creates a new
165       object using stream constructor, and the new object is written
166       to another stream, and function check if the two outputs are
167       equal.
168    */
169    template<class T>
170    bool test_stream(const T&) const;
171
172    /**
173       This function is similar to add(bool) and could be used to
174       detect/count known issues. When the issue is fixed, one can
175       replace the call to xadd(bool) with a call to add(bool).
176
177       If \a b is false a counter is incremented, which is used to in
178       return_value() to generate some printout on how many known
179       issues were detected.
180
181       If \a b is true, ok_ is set to false, becasue the known issue
182       is no longer an issue and one should replace the call with a
183       call to add(bool).
184     */
185    bool xadd(bool b);
186
187  private:
188    unsigned int known_issues_;
189    bool ok_;
190  };
191
192  /**
193     \return absolute path to test src dir
194  */
195  std::string abs_srcdir(void);
196
197  /**
198     \return absolute path to file
199     \param local_path path relative to srcdir
200   */
201  std::string filename(const std::string& local_path);
202
203  /*
204    class to test (at compile time) that a function (or class) works
205    with a Container2D. Do not run any test using this class because
206    the class is not really functional at run time.
207
208    \see boost/concept_archetype.hpp
209   */
210  template<typename T>
211  class container2d_archetype
212  {
213  public:
214    typedef T value_type;
215    typedef const T& const_reference;
216    typedef const T* const_iterator;
217    typedef const_iterator const_column_iterator;
218    typedef const_iterator const_row_iterator;
219    const_iterator begin(void) const { return &element_; }
220    const_column_iterator begin_column(size_t) const { return &element_; }
221    const_iterator begin_row(size_t) const { return &element_; }
222    const_iterator end(void) const { return NULL; }
223    const_column_iterator end_column(size_t) const { return NULL; }
224    const_iterator end_row(size_t) const { return NULL; }
225    size_t columns(void) const { return 0; }
226    size_t rows(void) const { return 0; }
227    const_reference operator()(size_t row, size_t column) const
228    { return element_; }
229
230  protected:
231    T element_;
232  };
233
234  /*
235    class to test (at compile time) that a function (or class) works
236    with a MutableContainer2D. Do not run any test using this class because
237    the class is not really functional at run time.
238
239    \see boost/concept_archetype.hpp
240   */
241  template<typename T>
242  class mutable_container2d_archetype : public container2d_archetype<T>
243  {
244  public:
245    typedef T& reference;
246    typedef T* iterator;
247    typedef iterator column_iterator;
248    typedef iterator row_iterator;
249    iterator begin(void) { return &this->element_; }
250    column_iterator begin_column(size_t) { return &this->element_; }
251    iterator begin_row(size_t) { return &this->element_; }
252    iterator end(void) { return NULL; }
253    column_iterator end_column(size_t) { return NULL; }
254    iterator end_row(size_t) { return NULL; }
255    reference operator()(size_t row, size_t column)
256    { return this->element_; }
257  };
258
259  /*
260    class to test (at compile time) that a function (or class) works
261    with a Distance. Do not run any test using this class because
262    the class is not really functional at run time.
263
264    \see boost/concept_archetype.hpp
265   */
266  class distance_archetype
267  {
268  public:
269    /// class must be constructible somehow, but we don't wanna assume
270    /// void constructor or any other common constructor so we use the
271    /// signature to allow construction without assuming too much.
272    distance_archetype(const boost::detail::dummy_constructor&) {};
273    distance_archetype(const distance_archetype&) {};
274    template<typename T1, typename T2>
275    double operator()(T1 first1, T1 last1, T2 first2) const { return 0.0; }
276  private:
277    distance_archetype(void);
278    distance_archetype& operator=(const distance_archetype&);
279  };
280
281  /*
282    class to test (at compile time) that a function (or class) works
283    with a NeighborWeighting. Do not run any test using this class because
284    the class is not really functional at run time.
285
286    \see boost/concept_archetype.hpp
287   */
288  class neighbor_weighting_archetype
289  {
290  public:
291    neighbor_weighting_archetype(void) {}
292    void operator()(const utility::VectorBase& distance,
293                    const std::vector<size_t>& k_sorted,
294                    const classifier::Target& target,
295                    utility::VectorMutable& prediction) const {}
296    neighbor_weighting_archetype& operator=(const neighbor_weighting_archetype&)
297    { return *this; }
298  private:
299    neighbor_weighting_archetype(const neighbor_weighting_archetype&) {};
300  };
301
302
303  // compilation tests on iterators
304
305  template<typename Iterator>
306  void test_readable_iterator(Iterator iterator)
307  {
308    BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIterator<Iterator>));
309  }
310
311
312  template<typename Iterator>
313  void test_writable_iterator(Iterator iterator)
314  {
315    BOOST_CONCEPT_ASSERT((boost_concepts::WritableIterator<Iterator>));
316  }
317
318
319  template<typename Iterator>
320  void test_swappable_iterator(Iterator iterator)
321  {
322    BOOST_CONCEPT_ASSERT((boost_concepts::SwappableIterator<Iterator>));
323  }
324
325  template<typename Iterator>
326  void test_lvalue_iterator(Iterator iterator)
327  {
328    BOOST_CONCEPT_ASSERT((boost_concepts::LvalueIterator<Iterator>));
329  }
330
331  template<typename Iterator>
332  void test_incrementable_iterator(Iterator iterator)
333  {
334    BOOST_CONCEPT_ASSERT((boost_concepts::IncrementableIterator<Iterator>));
335  }
336
337  template<typename Iterator>
338  void test_single_pass_iterator(Iterator iterator)
339  {
340    BOOST_CONCEPT_ASSERT((boost_concepts::SinglePassIterator<Iterator>));
341  }
342
343
344  template<typename Iterator>
345  void test_forward_traversal_iterator(Iterator iterator)
346  {
347    BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversal<Iterator>));
348  }
349
350
351  template<typename Iterator>
352  void test_bidirectional_traversal_iterator(Iterator iterator)
353  {
354    BOOST_CONCEPT_ASSERT((boost_concepts::BidirectionalTraversal<Iterator>));
355  }
356
357
358  template<typename Iterator>
359  void test_random_access_traversal_iterator(Iterator iterator)
360  {
361    BOOST_CONCEPT_ASSERT((boost_concepts::RandomAccessTraversal<Iterator>));
362  }
363
364
365  // This function pulls out the iterator_category and checks that the
366  // iterator has implemented what is promised in the category.
367  //
368  // Likewise it pulls out the boost::iterator_traversal type and
369  // checks that the traversal is implemented as promised.
370  //
371  // Iterator is a model of input iterator (output iterator makes no
372  // sense as a const iterator)
373  template<typename Iterator>
374  void test_const_iterator(Iterator iterator);
375
376
377  // Similar to test_const_iterator but function also works for
378  // output_iterator and it tests that the iterator is mutable.
379  template<typename Iterator>
380  void test_mutable_iterator(Iterator iterator);
381
382  // functions used by test_const_iterator and test_mutable_iterator
383  namespace detail {
384
385    template<typename Iterator>
386    void test_iterator_traversal(Iterator iterator,
387                                 boost::incrementable_traversal_tag tag)
388    {
389      test_incrementable_iterator(iterator);
390    }
391
392
393    template<typename Iterator>
394    void test_iterator_traversal(Iterator iterator,
395                                 boost::single_pass_traversal_tag tag)
396    {
397      test_single_pass_iterator(iterator);
398    }
399
400
401    template<typename Iterator>
402    void test_iterator_traversal(Iterator iterator,
403                                 boost::forward_traversal_tag tag)
404    {
405      test_forward_traversal_iterator(iterator);
406    }
407
408
409    template<typename Iterator>
410    void test_iterator_traversal(Iterator iterator,
411                                 boost::bidirectional_traversal_tag tag)
412    {
413      test_bidirectional_traversal_iterator(iterator);
414    }
415
416
417    template<typename Iterator>
418    void test_iterator_traversal(Iterator iterator,
419                                 boost::random_access_traversal_tag tag)
420    {
421      test_random_access_traversal_iterator(iterator);
422    }
423
424
425    template<typename Iterator>
426    void test_iterator(Iterator iterator, std::forward_iterator_tag tag)
427    {
428      test_lvalue_iterator(iterator);
429      test_iterator(iterator);
430    }
431
432
433    template<typename Iterator>
434    void test_iterator(Iterator iterator, std::bidirectional_iterator_tag tag)
435    {
436      test_lvalue_iterator(iterator);
437      test_iterator(iterator);
438    }
439
440
441    template<typename Iterator>
442    void test_iterator(Iterator iterator, std::random_access_iterator_tag tag)
443    {
444      test_lvalue_iterator(iterator);
445      test_iterator(iterator);
446    }
447
448
449    // testing forward iterator (or bidirectional or random access)
450    template<typename Iterator>
451    void test_iterator(Iterator iterator)
452    {
453      typename boost::iterator_category<Iterator>::type tag;
454      test_iterator(iterator, tag);
455      typename boost::iterator_traversal<Iterator>::type trav_tag;
456      test_iterator_traversal(iterator, trav_tag);
457    }
458
459
460    template<typename Iterator>
461    void test_mutable_iterator(Iterator iterator, std::output_iterator_tag tag)
462    {
463      test_incrementable_iterator(iterator);
464    }
465
466
467    template<typename Iterator>
468    void test_mutable_iterator(Iterator iterator, std::input_iterator_tag tag)
469    {
470      test_single_pass_iterator(iterator);
471    }
472
473
474    template<typename Iterator>
475    void test_mutable_iterator(Iterator iterator, std::forward_iterator_tag tag)
476    {
477      test_lvalue_iterator(iterator);
478      test_iterator(iterator);
479    }
480
481
482    template<typename Iterator>
483    void test_const_iterator(Iterator iterator, std::input_iterator_tag tag)
484    {
485      test_single_pass_iterator(iterator);
486      test_readable_iterator(iterator);
487    }
488
489
490    template<typename Iterator>
491    void test_const_iterator(Iterator iterator, std::forward_iterator_tag tag)
492    {
493      test_lvalue_iterator(iterator);
494      test_iterator(iterator);
495    }
496
497
498  } // end of namespace detail
499
500
501  // template implementations
502
503  template<class MATRIX1, class MATRIX2>
504  bool Suite::equal_matrix(const MATRIX1& a, const MATRIX2& b,
505                           unsigned long int N)
506  {
507    if (a.rows() != b.rows() || a.columns() != b.columns()) {
508      err() << "incorrect dimensions: "
509            << a.rows() << " x " << a.columns() << " : "
510            << b.rows() << " x " << b.columns() << "\n";
511      return false;
512    }
513    for (size_t i=0; i<a.rows(); ++i)
514      for (size_t j=0; j<a.columns(); ++j)
515        if (!equal(a(i,j), b(i,j), N)) {
516          err() << "  Matrix comparison: row: " << i << " column: " << j
517                << "\n";
518          return false;
519        }
520    return true;
521  }
522
523
524  template<typename Iterator1, typename Iterator2>
525  bool Suite::equal_range(Iterator1 first1, Iterator1 last1, Iterator2 first2,
526                          unsigned int N)
527  {
528    while (first1!=last1){
529      if (!this->equal(*first1, *first2, N) )  {
530        return false;
531      }
532      ++first1;
533      ++first2;
534    }
535    return true;
536  }
537
538
539  template<typename Iterator1, typename Iterator2>
540  bool Suite::equal_range_fix(Iterator1 first1, Iterator1 last1, 
541                              Iterator2 first2, double margin)
542  {
543    while (first1!=last1){
544      if (!this->equal_fix(*first1, *first2, margin) )   {
545        return false;
546      }
547      ++first1;
548      ++first2;
549    }
550    return true;
551  }
552
553
554  // return true if we can write to a write-protected file
555  bool run_as_root(void);
556
557  // function that can be used to avoid warning: '-Wunused-but-set-variable'
558  template<typename T>
559  void avoid_compiler_warning(T) {}
560
561  template<class T>
562  bool Suite::test_stream(const T& t) const
563  {
564    this->err() << "Checking that output stream is valid as an input stream\n";
565    std::stringstream ss;
566    this->err() << "writing to output\n";
567    ss << t;
568    this->err() << "creating a new object from output\n";
569    T t2(ss);
570    std::stringstream ss2;
571    this->err() << "writing to output\n";
572    ss2 << t2;
573    bool ok = ss2.str()==ss.str();
574    if (!ok) {
575      this->err() << "ERROR: first object gave following output:\n"
576                  << ss.str() << "\n"
577                  << "ERROR: and second object gave following output:\n"
578                  << ss2.str() << "\n";
579    }
580    return ok;
581  }
582
583  template<typename TrivialIterator>
584  void Suite::test_trivial_iterator(const TrivialIterator& iter)
585  {
586    err() << "  testing Trivial features" << std::endl;
587    typename std::iterator_traits<TrivialIterator>::value_type tmp = *iter;
588    add(tmp==*iter);
589    TrivialIterator default_constructed;
590    avoid_compiler_warning(default_constructed);
591  }
592
593  template<typename InputIterator>
594  void Suite::test_input_iterator(InputIterator& iter)
595  {
596    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator>));
597    test_trivial_iterator(iter);
598    err() << "  testing Input features" << std::endl;
599    // just to check compilation
600    if (false) {
601      ++iter;
602      iter++;
603    }
604  }
605
606  template<typename OutputIterator>
607  void Suite::test_output_iterator(OutputIterator& iter)
608  {
609    err() << "  testing Output features" << std::endl;
610    // OutputIterator should be default constructible and assignable
611    OutputIterator oi;
612    oi = iter;
613    ++oi;
614  }
615
616  template<typename ForwardIterator>
617  void Suite::test_forward_iterator(ForwardIterator iter)
618  {
619    BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>));
620    test_output_iterator(iter);
621    test_input_iterator(iter);
622    err() << "  testing Forward features" << std::endl;
623
624    typename std::iterator_traits<ForwardIterator>::value_type tmp = *iter;
625    // testing multiple traversing is possible and does not change the data
626    ForwardIterator iter1 = iter;
627    ++iter1;
628    add(iter!=iter1);
629    ForwardIterator iter2 = iter;
630    ++iter2;
631    add(tmp==*iter);
632  }
633
634  template<typename BidirectionalIterator>
635  void Suite::test_bidirectional_iterator(BidirectionalIterator iter)
636  {
637    BOOST_CONCEPT_ASSERT((boost::BidirectionalIterator<BidirectionalIterator>));
638    test_forward_iterator(iter);
639    bool ok_cached = ok();
640    err() << "  testing Bidirectional features" << std::endl;
641    const BidirectionalIterator i = iter;
642    BidirectionalIterator tmp = iter++;
643    if (!add(tmp==i)) {
644      err() << "iter++ does not return iter\n";
645    }
646    if (!add(++tmp==iter)) {
647      err() << "++iter failed\n";
648    }
649    if (!add(--tmp==i)) {
650      err() << "--iter failed\n";
651    }
652    tmp = iter--;
653    if (!add(--tmp==iter))
654      err() << "iter-- failed" << std::endl;
655    if (ok_cached && !ok())
656      err() << "failed" << std::endl;
657  }
658
659  template<typename RandomAccessIterator>
660  void Suite::test_random_access_iterator(RandomAccessIterator iter)
661  {
662    BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<RandomAccessIterator>));
663    test_bidirectional_iterator(iter);
664    err() << "  testing RandomAccess features" << std::endl;
665    bool ok_cached = ok();
666    RandomAccessIterator iter2 = iter;
667    iter2 += 1;
668    iter2 -= 1;
669    RandomAccessIterator& iter3 = (iter2 += 1);
670    RandomAccessIterator& iter4 = (iter3 -= 1);
671    if (!add(iter2 == iter4))
672      err() << "operator-(int) failed" << std::endl;
673    add(++iter2 == iter3);
674
675    RandomAccessIterator iter5 = iter + 0;
676    RandomAccessIterator iter6 = 0 + iter;
677    add(iter6 == iter5);
678
679    RandomAccessIterator iter7 = iter - 0;
680    add(iter7 == iter);
681    add(iter7 - iter == 0);
682    add(! (iter7<iter));
683
684    typename RandomAccessIterator::value_type tmp = iter[0];
685    typename RandomAccessIterator::value_type tmp2 = *iter;
686    tmp = tmp; // avoid compiler warning
687    if (!add(tmp == tmp2))
688      err() << "operator[] failed" << std::endl;
689    if (!add(iter[0] == *iter))
690      err() << "operator[] failed" << std::endl;
691    if (ok_cached && !ok())
692      err() << "failed" << std::endl;
693  }
694
695  template<typename Container2D>
696  void Suite::test_concept_container2d(const Container2D& c)
697  {
698    typedef typename Container2D::value_type value_type;
699    typedef typename Container2D::const_reference const_reference;
700    typedef typename Container2D::const_iterator const_iterator;
701    typedef typename Container2D::const_column_iterator const_column_iterator;
702    typedef typename Container2D::const_row_iterator const_row_iterator;
703    const_iterator ci = c.begin();
704    const_column_iterator cci = c.begin_column(0);
705    const_row_iterator cri = c.begin_row(0);
706    ci = c.end();
707    cci = c.end_column(0);
708    cri = c.end_row(0);
709    size_t cols = c.columns();
710    size_t rows = c.rows();
711    // just to avoid compiler warning
712    avoid_compiler_warning(cols);
713    avoid_compiler_warning(rows);
714    const_reference x = c(0,0);
715    value_type y;
716    y = x;
717    avoid_compiler_warning(y);
718  }
719
720  template<typename MutableContainer2D>
721  void Suite::test_concept_mutable_container2d(MutableContainer2D& mc)
722  {
723    test_concept_container2d(mc);
724    typedef typename MutableContainer2D::reference reference;
725    typedef typename MutableContainer2D::iterator iterator;
726    typedef typename MutableContainer2D::column_iterator column_iterator;
727    typedef typename MutableContainer2D::row_iterator row_iterator;
728    iterator i = mc.begin();
729    column_iterator ci = mc.begin_column(0);
730    row_iterator ri = mc.begin_row(0);
731    *i = *ci;
732    *ci = *i;
733    *ri = *i;
734    i = mc.end();
735    ci = mc.end_column(0);
736    ri = mc.end_row(0);
737    reference x = mc(0,0);
738    x = *mc.begin();
739  }
740
741
742  template<typename Iterator>
743  void test_const_iterator(Iterator iterator)
744  {
745    typename boost::iterator_category<Iterator>::type tag;
746    detail::test_const_iterator(iterator, tag);
747  }
748
749
750  template<typename Iterator>
751  void test_mutable_iterator(Iterator iterator)
752  {
753    typename boost::iterator_category<Iterator>::type tag;
754    detail::test_mutable_iterator(iterator, tag);
755    test_writable_iterator(iterator);
756  }
757
758
759  // For convenience to create data iterator. This class typedefs four
760  // classes that can be conveniently constructed in tests
761  // (const/mutable and weighted/unweighted. Traversal
762  // is expected to be one of:
763  //// boost::incrementable_traversal_tag (problematic with unweighted)
764  // boost::single_pass_traversal_tag (problematic with unweighted)
765  // boost::forward_traversal_tag
766  // boost::bidirectional_traversal_tag
767  // boost::random_access_traversal_tag
768  template<typename Traversal>
769  struct DataIterator
770  {
771    typedef boost::iterator_archetype<
772      double,
773      boost::iterator_archetypes::readable_iterator_t,
774      Traversal
775      > unweighted_const_iterator;
776
777    typedef boost::iterator_archetype<
778      double,
779      boost::iterator_archetypes::readable_writable_iterator_t,
780      Traversal
781      > unweighted_iterator;
782
783
784    typedef utility::WeightedIteratorArchetype<
785      boost::iterator_archetypes::readable_iterator_t, Traversal
786      >
787    weighted_const_iterator;
788
789    typedef utility::WeightedIteratorArchetype<
790      boost::iterator_archetypes::readable_writable_iterator_t,
791      Traversal
792      >
793    weighted_iterator;
794  };
795}}}
796
797#endif
Note: See TracBrowser for help on using the repository browser.