~ubuntu-branches/ubuntu/oneiric/bombono-dvd/oneiric

« back to all changes in this revision

Viewing changes to src/mlib/any_iterator/detail/any_iterator_abstract_base.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-11-04 11:46:25 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101104114625-2tfaxma74eqggp5r
Tags: 0.8.0-0ubuntu1
* New upstream release (LP: #670193).
* Refresh 02_sparc.diff patch.
* Replace 05-boost_filesystem-link.patch with 05-fix_boost.patch, it fixes
  build failure with Boost <= 1.44.
* Bump Standards.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  (C) Copyright Thomas Becker 2005. Permission to copy, use, modify, sell and
 
2
//  distribute this software is granted provided this copyright notice appears
 
3
//  in all copies. This software is provided "as is" without express or implied
 
4
//  warranty, and with no claim as to its suitability for any purpose.
 
5
 
 
6
// Revision History
 
7
// ================
 
8
//
 
9
// 27 Dec 2006 (Thomas Becker) Created
 
10
 
 
11
#ifndef ANY_ITERATOR_ABSTRACT_BASE_01102007TMB_HPP
 
12
#define ANY_ITERATOR_ABSTRACT_BASE_01102007TMB_HPP
 
13
 
 
14
// Includes
 
15
// ========
 
16
 
 
17
#include "any_iterator_metafunctions.hpp"
 
18
 
 
19
#include <boost/iterator/iterator_categories.hpp>
 
20
#include <boost/type_traits/add_const.hpp>
 
21
#include <boost/type_traits/remove_const.hpp>
 
22
 
 
23
namespace IteratorTypeErasure
 
24
{
 
25
 
 
26
  namespace detail
 
27
  {
 
28
 
 
29
    ///////////////////////////////////////////////////////////////////////
 
30
    // 
 
31
    // The partial specializations of any_iterator_abstract_base (which is
 
32
    // the equivalent of boost::any::placeholder) mirror the hierarchy of
 
33
    // boost's iterator traversal tags.
 
34
    //
 
35
    // The first four template arguments are as in boost::iterator_facade.
 
36
    // The last template argument is the traversal tag of the most
 
37
    // derived class of the current instantiation of the hierarchy. This
 
38
    // is a slight variant of the CRTP where the derived class passes 
 
39
    // itself as a template argument to the base class(es). Here, it seemed
 
40
    // more convenient to pass up just the traversal tag of the most 
 
41
    // derived class.
 
42
    //
 
43
    template<
 
44
      class Value,
 
45
      class Traversal,
 
46
      class Reference,
 
47
      class Difference,
 
48
      class UsedAsBaseForTraversal = Traversal
 
49
    >
 
50
    class any_iterator_abstract_base;
 
51
 
 
52
    ///////////////////////////////////////////////////////////////////////
 
53
    // 
 
54
    template<
 
55
      class Value,
 
56
      class Reference,
 
57
      class Difference,
 
58
      class UsedAsBaseForTraversal
 
59
    >
 
60
    class any_iterator_abstract_base<
 
61
      Value,
 
62
      boost::incrementable_traversal_tag,
 
63
      Reference,
 
64
      Difference,
 
65
      UsedAsBaseForTraversal
 
66
    >
 
67
    {
 
68
 
 
69
    protected:
 
70
      typedef any_iterator_abstract_base<
 
71
        Value,
 
72
        UsedAsBaseForTraversal,
 
73
        Reference,
 
74
        Difference
 
75
      > most_derived_type;
 
76
 
 
77
      typedef most_derived_type clone_result_type;
 
78
 
 
79
      typedef any_iterator_abstract_base<
 
80
        typename boost::add_const<Value>::type,
 
81
        UsedAsBaseForTraversal,
 
82
        typename make_iterator_reference_const<Reference>::type,
 
83
        Difference
 
84
      > const_clone_with_const_value_type_result_type;
 
85
 
 
86
      typedef any_iterator_abstract_base<
 
87
        typename boost::remove_const<Value>::type,
 
88
        UsedAsBaseForTraversal,
 
89
        typename make_iterator_reference_const<Reference>::type,
 
90
        Difference
 
91
      > const_clone_with_non_const_value_type_result_type;
 
92
 
 
93
    public:
 
94
 
 
95
      // Plain clone function for copy construction and assignment.
 
96
      virtual clone_result_type * clone() const=0;
 
97
  
 
98
      // Clone functions for conversion to a const iterator
 
99
      virtual const_clone_with_const_value_type_result_type * make_const_clone_with_const_value_type() const=0;
 
100
      virtual const_clone_with_non_const_value_type_result_type * make_const_clone_with_non_const_value_type() const=0;
 
101
 
 
102
      // gcc 3.4.2 does not like pure virtual declaration with inline definition,
 
103
      // so I make the destructor non-pure just to spite them.
 
104
      virtual ~any_iterator_abstract_base()
 
105
      {}
 
106
 
 
107
      virtual Reference dereference() const=0;
 
108
      virtual void increment() = 0;
 
109
 
 
110
    };
 
111
 
 
112
    ///////////////////////////////////////////////////////////////////////
 
113
    // 
 
114
    template<
 
115
      class Value,
 
116
      class Reference,
 
117
      class Difference,
 
118
      class UsedAsBaseForTraversal
 
119
    >
 
120
    class any_iterator_abstract_base<
 
121
      Value,
 
122
      boost::single_pass_traversal_tag,
 
123
      Reference,
 
124
      Difference,
 
125
      UsedAsBaseForTraversal
 
126
    > : public any_iterator_abstract_base<
 
127
          Value,
 
128
          boost::incrementable_traversal_tag,
 
129
          Reference,
 
130
          Difference,
 
131
          UsedAsBaseForTraversal
 
132
        >
 
133
    {
 
134
 
 
135
    public:
 
136
 
 
137
      // gcc 3.4.2 insists on qualification of most_derived_type.
 
138
      virtual bool equal(typename any_iterator_abstract_base::most_derived_type const &) const = 0;
 
139
 
 
140
      virtual any_iterator_abstract_base<
 
141
        Value,
 
142
        boost::incrementable_traversal_tag,
 
143
        Reference,
 
144
        Difference
 
145
      >* make_incrementable_version() const=0;
 
146
    };
 
147
 
 
148
    ///////////////////////////////////////////////////////////////////////
 
149
    // 
 
150
    template<
 
151
      class Value,
 
152
      class Reference,
 
153
      class Difference,
 
154
      class UsedAsBaseForTraversal
 
155
    >
 
156
    class any_iterator_abstract_base<
 
157
      Value,
 
158
      boost::forward_traversal_tag,
 
159
      Reference,
 
160
      Difference,
 
161
      UsedAsBaseForTraversal
 
162
    > : public any_iterator_abstract_base<
 
163
          Value,
 
164
          boost::single_pass_traversal_tag,
 
165
          Reference,
 
166
          Difference,
 
167
          UsedAsBaseForTraversal
 
168
        >
 
169
    {
 
170
    public:
 
171
      virtual any_iterator_abstract_base<
 
172
        Value,
 
173
        boost::single_pass_traversal_tag,
 
174
        Reference,
 
175
        Difference
 
176
      >* make_single_pass_version() const=0;
 
177
    };
 
178
 
 
179
    ///////////////////////////////////////////////////////////////////////
 
180
    // 
 
181
    template<
 
182
      class Value,
 
183
      class Reference,
 
184
      class Difference,
 
185
      class UsedAsBaseForTraversal
 
186
    >
 
187
    class any_iterator_abstract_base<
 
188
      Value,
 
189
      boost::bidirectional_traversal_tag,
 
190
      Reference,
 
191
      Difference,
 
192
      UsedAsBaseForTraversal
 
193
    > : public any_iterator_abstract_base<
 
194
          Value,
 
195
          boost::forward_traversal_tag,
 
196
          Reference,
 
197
          Difference,
 
198
          UsedAsBaseForTraversal
 
199
        >
 
200
    {
 
201
 
 
202
    public:
 
203
      
 
204
      virtual void decrement() = 0;
 
205
 
 
206
      virtual any_iterator_abstract_base<
 
207
        Value,
 
208
        boost::forward_traversal_tag,
 
209
        Reference,
 
210
        Difference
 
211
      >* make_forward_version() const=0;
 
212
    };
 
213
 
 
214
    ///////////////////////////////////////////////////////////////////////
 
215
    // 
 
216
    template<
 
217
      class Value,
 
218
      class Reference,
 
219
      class Difference,
 
220
      class UsedAsBaseForTraversal
 
221
    >
 
222
    class any_iterator_abstract_base<
 
223
      Value,
 
224
      boost::random_access_traversal_tag,
 
225
      Reference,
 
226
      Difference,
 
227
      UsedAsBaseForTraversal
 
228
    > : public any_iterator_abstract_base<
 
229
          Value,
 
230
          boost::bidirectional_traversal_tag,
 
231
          Reference,
 
232
          Difference,
 
233
          UsedAsBaseForTraversal
 
234
        >
 
235
    {
 
236
 
 
237
    public:
 
238
 
 
239
      virtual void advance(Difference) = 0;
 
240
 
 
241
      // gcc 3.4.2 insists on qualification of most_derived_type.
 
242
      virtual Difference distance_to(typename any_iterator_abstract_base::most_derived_type const &) const= 0;
 
243
 
 
244
      virtual any_iterator_abstract_base<
 
245
        Value,
 
246
        boost::bidirectional_traversal_tag,
 
247
        Reference,
 
248
        Difference
 
249
      >* make_bidirectional_version() const=0;
 
250
    };
 
251
 
 
252
  } // end namespace detail
 
253
 
 
254
} // end namespace IteratorTypeErasure
 
255
 
 
256
#endif // ANY_ITERATOR_ABSTRACT_BASE_01102007TMB_HPP