bpp-seq  2.2.0
SequencePositionIterators.h
Go to the documentation of this file.
1 //
2 // File: SequencePositionIterators.h
3 // Author: Sylvain Gaillard
4 // Created: 23/06/2009 10:35:28
5 //
6 
7 /*
8 Copyright or © or Copr. Bio++ Development Team, (June 23, 2009)
9 
10 This software is a computer program whose purpose is to provide classes
11 for sequences analysis.
12 
13 This software is governed by the CeCILL license under French law and
14 abiding by the rules of distribution of free software. You can use,
15 modify and/ or redistribute the software under the terms of the CeCILL
16 license as circulated by CEA, CNRS and INRIA at the following URL
17 "http://www.cecill.info".
18 
19 As a counterpart to the access to the source code and rights to copy,
20 modify and redistribute granted by the license, users are provided only
21 with a limited warranty and the software's author, the holder of the
22 economic rights, and the successive licensors have only limited
23 liability.
24 
25 In this respect, the user's attention is drawn to the risks associated
26 with loading, using, modifying and/or developing or reproducing the
27 software by the user in light of its specific status of free software,
28 that may mean that it is complicated to manipulate, and that also
29 therefore means that it is reserved for developers and experienced
30 professionals having in-depth computer knowledge. Users are therefore
31 encouraged to load and test the software's suitability as regards their
32 requirements in conditions enabling the security of their systems and/or
33 data to be ensured and, more generally, to use and operate it in the
34 same conditions as regards security.
35 
36 The fact that you are presently reading this means that you have had
37 knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _SEQUENCEPOSITIONITERATORS_H_
41 #define _SEQUENCEPOSITIONITERATORS_H_
42 
43 // from STL
44 #include <string>
45 
46 #include "Sequence.h"
47 
48 namespace bpp
49 {
50 
59  {
60  public:
63 
64  public:
68  virtual unsigned int getPosition() const = 0;
73  virtual void setPosition(unsigned int pos) = 0;
77  virtual int getValue() const = 0;
81  virtual std::string getChar() const = 0;
82 
83  virtual bool operator==(const SequencePositionIterator & it) const = 0;
84  virtual bool operator!=(const SequencePositionIterator & it) const = 0;
85  virtual SequencePositionIterator & operator+=(int i) = 0;
86  virtual SequencePositionIterator & operator-=(int i) = 0;
87  virtual SequencePositionIterator& operator++() = 0;
88 
93  virtual bool hasMorePositions() const = 0;
98  virtual const Sequence & getSequence() const = 0;
99  };
100 
107  public virtual SequencePositionIterator
108  {
109  private:
111  unsigned int currentPosition_;
112 
113 
114  public:
115  AbstractSequencePositionIterator(const Sequence& seq, unsigned int pos = 0) :
116  sequence_(&seq), currentPosition_(pos) {}
117 
120 
122  {
123  sequence_ = aspi.sequence_;
125  return *this;
126  }
127 
129 
130  public:
131 
137  bool operator==(const SequencePositionIterator& it) const;
138  bool operator!=(const SequencePositionIterator& it) const;
141  unsigned int getPosition() const;
142  void setPosition(unsigned int pos);
143  int getValue() const;
144  std::string getChar() const;
145  const Sequence& getSequence() const;
146  };
147 
165  {
166  public:
180  SimpleSequencePositionIterator(const Sequence& seq, unsigned int pos = 0):
191  public:
201  virtual SimpleSequencePositionIterator operator+(int i) const;
202  virtual SimpleSequencePositionIterator operator-(int i) const;
205  bool hasMorePositions() const;
206  };
207 
208 }
209 
210 #endif //_SEQUENCEPOSITIONITERATORS_H_
virtual int getValue() const =0
Get the numerical value of the Sequence at current position.
virtual bool hasMorePositions() const =0
Tells if there is more positions in the Sequence.
AbstractSequencePositionIterator & operator=(const AbstractSequencePositionIterator &aspi)
virtual SequencePositionIterator & operator++()=0
unsigned int getPosition() const
Get the actual position of the iterator in the Sequence.
bool operator==(const SequencePositionIterator &it) const
virtual SequencePositionIterator & operator+=(int i)=0
int getValue() const
Get the numerical value of the Sequence at current position.
SimpleSequencePositionIterator(const Sequence &seq, unsigned int pos=0)
General constructor.
This alphabet is used to deal NumericAlphabet.
virtual std::string getChar() const =0
Get the textual value of the Sequence at current position.
virtual const Sequence & getSequence() const =0
Get the Sequence on which the iterator loops.
virtual SimpleSequencePositionIterator operator-(int i) const
SimpleSequencePositionIterator & operator+=(int i)
std::string getChar() const
Get the textual value of the Sequence at current position.
void setPosition(unsigned int pos)
Set the position of the iterator.
bool hasMorePositions() const
Tells if there is more positions in the Sequence.
SimpleSequencePositionIterator & operator++()
AbstractSequencePositionIterator(const Sequence &seq, unsigned int pos=0)
SimpleSequencePositionIterator & operator-=(int i)
const Sequence & getSequence() const
Get the Sequence on which the iterator loops.
The sequence interface.
Definition: Sequence.h:74
virtual SequencePositionIterator & operator-=(int i)=0
virtual SimpleSequencePositionIterator operator+(int i) const
bool operator!=(const SequencePositionIterator &it) const
virtual void setPosition(unsigned int pos)=0
Set the position of the iterator.
virtual bool operator!=(const SequencePositionIterator &it) const =0
AbstractSequencePositionIterator(const AbstractSequencePositionIterator &aspi)
Loop over all positions in a Sequence.
Partial implementation of the SequencePositionIterator interface.
virtual unsigned int getPosition() const =0
Get the actual position of the iterator in the Sequence.
virtual bool operator==(const SequencePositionIterator &it) const =0