datatypes_AMOS.hh

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 #ifndef __datatypes_AMOS_HH
00015 #define __datatypes_AMOS_HH 1
00016 
00017 #include "Message_AMOS.hh"
00018 #include <vector>
00019 #include <string>
00020 
00021 
00022 
00023 
00024 
00025 //-- Miscellaneous types and definitions
00026 namespace AMOS {
00027 
00028 //================================================ Distribution_t ==============
00036 //==============================================================================
00037 struct Distribution_t : public IMessagable_t
00038 {
00039 
00040   Pos_t mean;           
00041   SD_t sd;              
00042 
00043 
00044   static const NCode_t NCODE;
00046 
00047 
00048   //--------------------------------------------------- Distribution_t ---------
00053   Distribution_t ( )
00054   {
00055     clear( );
00056   }
00057 
00058 
00059   //--------------------------------------------------- ~Distribution_t --------
00062   ~Distribution_t ( )
00063   {
00064 
00065   }
00066 
00067 
00068   //--------------------------------------------------- clear ------------------
00071   void clear ( )
00072   {
00073     mean = 0; sd = 0;
00074   }
00075 
00076 
00077   //--------------------------------------------------- getNCode ---------------
00078   virtual NCode_t getNCode ( ) const
00079   {
00080     return Distribution_t::NCODE;
00081   }
00082 
00083 
00084   //--------------------------------------------------- readMessage ------------
00085   virtual void readMessage (const Message_t & msg);
00086 
00087 
00088   //--------------------------------------------------- readRecord -------------
00091   void readRecord (std::istream & in);
00092 
00093 
00094   //--------------------------------------------------- writeMessage -----------
00095   virtual void writeMessage (Message_t & msg) const;
00096 
00097 
00098   //--------------------------------------------------- writeRecord ------------
00101   void writeRecord (std::ostream & out) const;
00102 
00103 };
00104 
00105 
00106 
00107 
00108 //================================================ Range_t =====================
00119 //==============================================================================
00120 struct Range_t
00121 {
00122 
00123   Pos_t begin;              
00124   Pos_t end;                
00125 
00126 
00127   //--------------------------------------------------- Range_t ----------------
00132   Range_t ( )
00133   {
00134     clear( );
00135   }
00136 
00137 
00138   //--------------------------------------------------- Range_t ----------------
00143   Range_t (const Range_t & source)
00144   {
00145     *this = source;
00146   }
00147 
00148 
00149   //--------------------------------------------------- Range_t ----------------
00157   Range_t (Pos_t b, Pos_t e)
00158   {
00159     begin = b;
00160     end = e;
00161   }
00162 
00163 
00164   //--------------------------------------------------- ~Range_t ---------------
00167   ~Range_t ( )
00168   {
00169 
00170   }
00171 
00172 
00173   //--------------------------------------------------- clear ------------------
00176   void clear ( )
00177   {
00178     begin = end = 0;
00179   }
00180 
00181 
00182   //--------------------------------------------------- getBegin ---------------
00185   Pos_t getBegin ( ) const
00186   {
00187     return begin;
00188   }
00189 
00190 
00191   //--------------------------------------------------- getLo ------------------
00194   Pos_t getLo ( ) const
00195   {
00196     return (begin < end ? begin : end);
00197   }
00198 
00199 
00200   //--------------------------------------------------- getHi ------------------
00203   Pos_t getHi ( ) const
00204   {
00205     return (begin > end ? begin : end);
00206   }
00207 
00208 
00209   //--------------------------------------------------- getEnd -----------------
00212   Pos_t getEnd ( ) const
00213   {
00214     return end;
00215   }
00216 
00217 
00218   //--------------------------------------------------- getLength --------------
00223   Size_t getLength ( ) const
00224   {
00225     return labs (end - begin);
00226   }
00227 
00228 
00229   //--------------------------------------------------- isReverse --------------
00234   bool isReverse ( ) const
00235   {
00236     return begin > end;
00237   }
00238 
00239 
00240   //--------------------------------------------------- setBegin ---------------
00243   void setBegin (Pos_t b)
00244   {
00245     begin = b;
00246   }
00247 
00248 
00249   //--------------------------------------------------- setEnd -----------------
00252   void setEnd (Pos_t e)
00253   {
00254     end = e;
00255   }
00256 
00257 
00258   //--------------------------------------------------- setRange ---------------
00261   void setRange (Pos_t b, Pos_t e)
00262   {
00263     begin = b;
00264     end = e;
00265   }
00266 
00267 
00268   //--------------------------------------------------- swap -------------------
00271   void swap ( )
00272   {
00273    Pos_t save = begin;
00274    begin = end;
00275    end = save;
00276   }
00277 
00278 };
00279 
00280 
00281 
00282 
00283 //================================================ Tile_t ======================
00300 //==============================================================================
00301 struct Tile_t : public IMessagable_t
00302 {
00303   ID_t source;                
00304   std::vector<Pos_t> gaps;    
00305   Pos_t offset;               
00306   Range_t range;              
00307 
00308 
00309   static const NCode_t NCODE;
00311 
00312 
00313   //--------------------------------------------------- Tile_t -----------------
00318   Tile_t ( )
00319   {
00320     source = NULL_ID;
00321     offset = 0;
00322   }
00323 
00324 
00325   //--------------------------------------------------- ~Tile_t ----------------
00328   ~Tile_t ( )
00329   {
00330 
00331   }
00332 
00333 
00334   //--------------------------------------------------- clear ------------------
00337   void clear ( );
00338 
00339 
00340   //--------------------------------------------------- getGappedLength --------
00347   Size_t getGappedLength ( ) const
00348   {
00349     return (range . getLength( ) + gaps . size( ));
00350   }
00351 
00352 
00353   //--------------------------------------------------- getNCode ---------------
00354   virtual NCode_t getNCode ( ) const
00355   {
00356     return Tile_t::NCODE;
00357   }
00358 
00359 
00360   //--------------------------------------------------- getRightOffset --------
00367 
00368   Pos_t getRightOffset() const
00369   {
00370     return offset + range.getLength() + gaps.size() - 1;
00371   }
00372 
00373 
00374   //--------------------------------------------------- readMessage ------------
00375   virtual void readMessage (const Message_t & msg);
00376 
00377 
00378   //--------------------------------------------------- readRecord -------------
00381   void readRecord (std::istream & in);
00382 
00383 
00384   //--------------------------------------------------- writeMessage -----------
00385   virtual void writeMessage (Message_t & msg) const;
00386 
00387 
00388   //--------------------------------------------------- writeRecord ------------
00391   void writeRecord (std::ostream & out) const;
00392 
00393 };
00394 
00395 
00396 //================================================ Helper Functions ============
00397 //----------------------------------------------------- operator& --------------
00406 Range_t operator& (Range_t a, Range_t b);
00407 
00408 
00409 //----------------------------------------------------- operator| --------------
00418 Range_t operator| (Range_t a, Range_t b);
00419 
00420 
00421 //----------------------------------------------------- operator== -------------
00430 bool operator== (const Range_t & a, const Range_t & b);
00431 bool operator!= (const Range_t & a, const Range_t & b);
00432 
00433 
00434 //----------------------------------------------------- operator== -------------
00443 bool operator== (const Distribution_t & a, const Distribution_t & b);
00444 bool operator!= (const Distribution_t & a, const Distribution_t & b);
00445 
00446 
00447 //----------------------------------------------------- operator== -------------
00456 bool operator== (const Tile_t & a, const Tile_t & b);
00457 bool operator!= (const Tile_t & a, const Tile_t & b);
00458 
00459 
00460 //----------------------------------------------------- WrapStirng -------------
00463 void WrapString (std::ostream & out, const std::string & s, int per);
00464 
00465 
00466 //--TEMPORARY
00467 typedef Range_t Ordered_Range_t;
00468 
00469 } // namespace AMOS
00470 
00471 #endif // #ifndef __datatypes_AMOS_HH

Generated on Mon Feb 22 17:36:27 2010 for libAMOS by  doxygen 1.4.7