1 // ==========================================================================
2 //                 SeqAn - The Library for Sequence Analysis
3 // ==========================================================================
4 // Copyright (c) 2006-2010, Knut Reinert, FU Berlin
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 //
10 //     * Redistributions of source code must retain the above copyright
11 //       notice, this list of conditions and the following disclaimer.
12 //     * Redistributions in binary form must reproduce the above copyright
13 //       notice, this list of conditions and the following disclaimer in the
14 //       documentation and/or other materials provided with the distribution.
15 //     * Neither the name of Knut Reinert or the FU Berlin nor the names of
16 //       its contributors may be used to endorse or promote products derived
17 //       from this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
23 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
29 // DAMAGE.
30 //
31 // ==========================================================================
32 
33 #ifndef SEQAN_HEADER_BASIC_ITERATOR_SIMPLE_H
34 #define SEQAN_HEADER_BASIC_ITERATOR_SIMPLE_H
35 
36 namespace SEQAN_NAMESPACE_MAIN
37 {
38 //////////////////////////////////////////////////////////////////////////////
39 // Iter
40 //////////////////////////////////////////////////////////////////////////////
41 
42 struct SimpleIterator;
43 
44 /**
45 .Spec.SimpleIterator:
46 ..cat:Iterators
47 ..summary:A simple iterator.
48 ..signature:Iter<TContainer, SimpleIterator>
49 ..param.TContainer:Type of the container that can be iterated.
50 ...metafunction:Metafunction.Container
51 ..general:Class.Iter
52 ..include:seqan/basic.h
53 */
54 template <typename TContainer>
55 class Iter<TContainer, SimpleIterator>
56 {
57 public:
58 	typedef typename Value<TContainer>::Type TValue;
59 	TValue * data_ptr;
60 
Iter()61 	Iter()
62 	{
63 	}
Iter(Iter const & other_)64 	Iter(Iter const & other_):
65 		data_ptr(other_.data_ptr)
66 	{
67 	}
Iter(TValue * other_data_ptr)68 	Iter(TValue * other_data_ptr):
69 		data_ptr(other_data_ptr)
70 	{
71 	}
72 	template <typename TContainer2>
Iter(Iter<TContainer2,SimpleIterator> const & other_)73 	Iter(Iter<TContainer2, SimpleIterator> const & other_):
74 		data_ptr(other_.data_ptr)
75 	{
76 	}
~Iter()77 	~Iter()
78 	{
79 	}
80 	Iter const &
81 	operator = (Iter const & other_)
82 	{
83 		this->data_ptr = other_.data_ptr;
84 		return *this;
85 	}
86 	Iter const &
87 	operator = (TValue * other_data_ptr)
88 	{
89 		data_ptr = other_data_ptr;
90 		return *this;
91 	}
92 	template <typename TContainer2>
93 	Iter const &
94 	operator = (Iter<TContainer2, SimpleIterator> const & other_)
95 	{
96 		this->data_ptr = other_.data_ptr;
97 		return *this;
98 	}
99 
100 	operator TValue * ()
101 	{
102 		return data_ptr;
103 	}
104 };
105 
106 //////////////////////////////////////////////////////////////////////////////
107 
108 template <typename T>
109 struct Iterator_Default_Imp<T, Standard>
110 {
111 	typedef typename Value<T>::Type * Type;
112 //	typedef Iter<T, SimpleIterator> Type;
113 };
114 
115 //////////////////////////////////////////////////////////////////////////////
116 
117 template <typename TContainer, typename TContainer2>
118 inline typename Position<Iter<TContainer, SimpleIterator> const>::Type
119 position(Iter<TContainer, SimpleIterator> const & me,
120 		 TContainer2 const & cont)
121 {
122 SEQAN_CHECKPOINT
123 	return me.data_ptr - begin(cont);
124 }
125 
126 //////////////////////////////////////////////////////////////////////////////
127 
128 } //namespace SEQAN_NAMESPACE_MAIN
129 
130 #endif //#ifndef SEQAN_HEADER_...
131