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
00026 namespace AMOS {
00027
00028
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
00053 Distribution_t ( )
00054 {
00055 clear( );
00056 }
00057
00058
00059
00062 ~Distribution_t ( )
00063 {
00064
00065 }
00066
00067
00068
00071 void clear ( )
00072 {
00073 mean = 0; sd = 0;
00074 }
00075
00076
00077
00078 virtual NCode_t getNCode ( ) const
00079 {
00080 return Distribution_t::NCODE;
00081 }
00082
00083
00084
00085 virtual void readMessage (const Message_t & msg);
00086
00087
00088
00091 void readRecord (std::istream & in);
00092
00093
00094
00095 virtual void writeMessage (Message_t & msg) const;
00096
00097
00098
00101 void writeRecord (std::ostream & out) const;
00102
00103 };
00104
00105
00106
00107
00108
00119
00120 struct Range_t
00121 {
00122
00123 Pos_t begin;
00124 Pos_t end;
00125
00126
00127
00132 Range_t ( )
00133 {
00134 clear( );
00135 }
00136
00137
00138
00143 Range_t (const Range_t & source)
00144 {
00145 *this = source;
00146 }
00147
00148
00149
00157 Range_t (Pos_t b, Pos_t e)
00158 {
00159 begin = b;
00160 end = e;
00161 }
00162
00163
00164
00167 ~Range_t ( )
00168 {
00169
00170 }
00171
00172
00173
00176 void clear ( )
00177 {
00178 begin = end = 0;
00179 }
00180
00181
00182
00185 Pos_t getBegin ( ) const
00186 {
00187 return begin;
00188 }
00189
00190
00191
00194 Pos_t getLo ( ) const
00195 {
00196 return (begin < end ? begin : end);
00197 }
00198
00199
00200
00203 Pos_t getHi ( ) const
00204 {
00205 return (begin > end ? begin : end);
00206 }
00207
00208
00209
00212 Pos_t getEnd ( ) const
00213 {
00214 return end;
00215 }
00216
00217
00218
00223 Size_t getLength ( ) const
00224 {
00225 return labs (end - begin);
00226 }
00227
00228
00229
00234 bool isReverse ( ) const
00235 {
00236 return begin > end;
00237 }
00238
00239
00240
00243 void setBegin (Pos_t b)
00244 {
00245 begin = b;
00246 }
00247
00248
00249
00252 void setEnd (Pos_t e)
00253 {
00254 end = e;
00255 }
00256
00257
00258
00261 void setRange (Pos_t b, Pos_t e)
00262 {
00263 begin = b;
00264 end = e;
00265 }
00266
00267
00268
00271 void swap ( )
00272 {
00273 Pos_t save = begin;
00274 begin = end;
00275 end = save;
00276 }
00277
00278 };
00279
00280
00281
00282
00283
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
00318 Tile_t ( )
00319 {
00320 source = NULL_ID;
00321 offset = 0;
00322 }
00323
00324
00325
00328 ~Tile_t ( )
00329 {
00330
00331 }
00332
00333
00334
00337 void clear ( );
00338
00339
00340
00347 Size_t getGappedLength ( ) const
00348 {
00349 return (range . getLength( ) + gaps . size( ));
00350 }
00351
00352
00353
00354 virtual NCode_t getNCode ( ) const
00355 {
00356 return Tile_t::NCODE;
00357 }
00358
00359
00360
00367
00368 Pos_t getRightOffset() const
00369 {
00370 return offset + range.getLength() + gaps.size() - 1;
00371 }
00372
00373
00374
00375 virtual void readMessage (const Message_t & msg);
00376
00377
00378
00381 void readRecord (std::istream & in);
00382
00383
00384
00385 virtual void writeMessage (Message_t & msg) const;
00386
00387
00388
00391 void writeRecord (std::ostream & out) const;
00392
00393 };
00394
00395
00396
00397
00406 Range_t operator& (Range_t a, Range_t b);
00407
00408
00409
00418 Range_t operator| (Range_t a, Range_t b);
00419
00420
00421
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
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
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
00463 void WrapString (std::ostream & out, const std::string & s, int per);
00464
00465
00466
00467 typedef Range_t Ordered_Range_t;
00468
00469 }
00470
00471 #endif // #ifndef __datatypes_AMOS_HH