Update mussa to build on ubuntu 10.04 with qt 4.6.2 +boost 1.40.0.1
[mussa.git] / alg / sequence_location.cpp
index bb17e34fd5a334f96e5d71833d4dd7e79a975560..4b3ddc8b5a1b282400670a69e462df62d9e2c12b 100644 (file)
@@ -1,21 +1,23 @@
 #include "alg/sequence_location.hpp"
+
+#include <cstdlib>
     
 SequenceLocation::SequenceLocation(
     const boost::shared_ptr<Sequence> s, 
     int l, 
-    int c
+    int r
 ) : sequence(s), 
     left(l), 
-    count(c)
+    right(r)
 {
 }
 
 SequenceLocation::SequenceLocation(
     const Sequence& s, 
     int l, 
-    int c
+    int r
 ) : left(l), 
-    count(c)
+    right(r)
 {
   boost::shared_ptr<Sequence> copy(new Sequence(s));
   sequence = copy;
@@ -25,7 +27,7 @@ SequenceLocation::SequenceLocation(
 SequenceLocation::SequenceLocation(const SequenceLocation& o) 
   : sequence(o.sequence),
     left(o.left),
-    count(o.count)
+    right(o.right)
 {
 }
 
@@ -33,8 +35,8 @@ SequenceLocation& SequenceLocation::operator=(const SequenceLocation& o)
 {
   if (this != &o) {
     sequence = o.sequence;
-    left = o.left;
-    count = o.count;
+    left = o.getLeft();
+    right = o.getRight();
   }
   return *this;
 }
@@ -47,7 +49,7 @@ const Sequence& SequenceLocation::getSequence() const
 
 Sequence SequenceLocation::getSelectedSequence() const
 {
-  return sequence->subseq(left, count);
+  return sequence->subseq(getLeft(), getCount());
 }
 
 void SequenceLocation::setLeft(int l)
@@ -60,22 +62,27 @@ int SequenceLocation::getLeft() const
   return left;
 }
 
-void SequenceLocation::setCount(int c)
+void SequenceLocation::setCount(SequenceLocation::size_type c)
 {
-  count = c;
+  right = left + c;
 }
 
-int SequenceLocation::getCount() const
+SequenceLocation::size_type SequenceLocation::getCount() const
 {
-  return count;
+  return std::max(right - left, 0);
 }
 
 void SequenceLocation::setRight(int r)
 {
-  count = r-left;
+  right = r;
 }
 
 int SequenceLocation::getRight() const
 {
-  return left+count;
+  return right;
+}
+
+SequenceLocation::size_type SequenceLocation::size() const
+{
+  return getCount();
 }