Main Page | Class Hierarchy | Class List | File List | Class Members

AnnotationScore.h

00001 
00002 // Copyright (c) 2003, The Institute for Genomic Research (TIGR), Rockville,
00003 // Maryland, U.S.A.  All rights reserved.
00005 #ifndef ANNOTATIONSCORE_H
00006 #define ANNOTATIONSCORE_H
00007 
00008 #include <iostream>
00009 
00010 //class ostream;
00011 //class istream;
00012 
00018 class AnnotationScore {
00019  public:
00023   AnnotationScore() : _val(AnnotationScore::badVal().getVal()) { }
00024   AnnotationScore(double val) : _val(val) {}
00025   AnnotationScore(int val) : _val(static_cast<double>(val)) {}
00026   AnnotationScore(const AnnotationScore& as) : _val(as._val) { }
00027  ~AnnotationScore() { }
00028 
00032  bool isValid() const { return badVal()._val != _val; }
00033 
00037  inline static AnnotationScore defaultScore() {
00038   return AnnotationScore(1.0);
00039  }
00040 
00044 inline static AnnotationScore minVal() {
00045   return AnnotationScore(-1.0);
00046 }
00047 
00051 inline static AnnotationScore badVal() {
00052   return AnnotationScore(-1.0);
00053 }
00054     
00055 inline friend AnnotationScore operator*(const AnnotationScore&,double);
00056 inline bool operator>(const AnnotationScore&) const;
00057 inline bool operator<=(const AnnotationScore&) const;
00058 inline bool operator>=(const AnnotationScore&) const;
00059 inline bool operator==(const AnnotationScore&) const;
00060 bool operator!=(const AnnotationScore& as) const {
00061   return (_val != as._val);
00062 }
00063 inline AnnotationScore& operator=(const AnnotationScore& in) {
00064   _val = in._val;
00065   return *this;
00066 }
00067 inline AnnotationScore& operator/=(const AnnotationScore& in) {
00068   _val /= in._val;
00069   return *this;
00070 }
00071 inline AnnotationScore& operator-=(const AnnotationScore& in) {
00072     _val -= in._val;
00073     return *this;
00074 }
00075 inline AnnotationScore& operator+=(const AnnotationScore& in) {
00076     _val += in._val;
00077     return *this;
00078 }
00079 inline AnnotationScore& operator*=(const AnnotationScore& in) {
00080     _val *= in._val;
00081     return *this;
00082 }
00083 
00084  friend inline AnnotationScore operator*(const AnnotationScore& a, const AnnotationScore& b) {
00085    return a._val*b._val;
00086  } 
00087 friend bool operator<(const AnnotationScore& ain, const AnnotationScore& bin) {
00088   const double aVal = ain.getVal();
00089   const double bVal = bin.getVal();
00090   const bool result = (aVal < bVal);
00091   return result;
00092 }
00093 inline friend AnnotationScore operator-(const AnnotationScore& as1, const AnnotationScore& as2) {
00094     const AnnotationScore rVal = AnnotationScore(as1._val-as2._val);
00095     return rVal;
00096   }
00097 
00098 inline friend AnnotationScore operator+(const AnnotationScore& as1, const AnnotationScore& as2) 
00099     { return AnnotationScore( as1._val+as2._val ); }
00100 
00101 inline friend AnnotationScore operator/(const AnnotationScore& as1, const AnnotationScore& as2) {
00102    return AnnotationScore(as1._val/as2._val); 
00103 }
00104 
00105  inline friend AnnotationScore combineScore(const AnnotationScore& as1, const AnnotationScore& as2) {
00106     return (as1 + as2); 
00107 } 
00108 
00109 
00110  friend std::istream& operator>>(std::istream&,AnnotationScore&);
00111  friend std::ostream& operator<<(std::ostream&,const AnnotationScore&);
00112  inline double getVal() const { return _val; }
00113 
00114 private:
00115  double _val;
00116 
00117 };
00118 
00119 #include "inline/AnnotationScore.hpp"
00120 
00121 #endif //ANNOTATIONSCORE_H