1 //=========================================================================== 2 // $Name: arts++-1-1-a13 $ 3 // $Id: ArtsRttTimeSeriesTableData.hh,v 1.2 2004/04/21 23:51:29 kkeys Exp $ 4 //=========================================================================== 5 // Copyright Notice 6 // 7 // By accessing this software, arts++, you are duly informed 8 // of and agree to be bound by the conditions described below in this 9 // notice: 10 // 11 // This software product, arts++, is developed by Daniel W. McRobb, and 12 // copyrighted(C) 1998 by the University of California, San Diego 13 // (UCSD), with all rights reserved. UCSD administers the CAIDA grant, 14 // NCR-9711092, under which part of this code was developed. 15 // 16 // There is no charge for arts++ software. You can redistribute it 17 // and/or modify it under the terms of the GNU Lesser General Public 18 // License, Version 2.1, February 1999, which is incorporated by 19 // reference herein. 20 // 21 // arts++ is distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF 22 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE or that the use 23 // of it will not infringe on any third party's intellectual 24 // property rights. 25 // 26 // You should have received a copy of the GNU Lesser General Public 27 // License along with arts++. Copies can also be obtained from: 28 // 29 // http://www.gnu.org/copyleft/lesser.html 30 // 31 // or by writing to: 32 // 33 // Free Software Foundation, Inc. 34 // 59 Temple Place, Suite 330 35 // Boston, MA 02111-1307 36 // USA 37 // 38 // Or contact: 39 // 40 // info@caida.org 41 //=========================================================================== 42 43 #ifndef _ARTSRTTTIMESERIESTABLEDATA_HH_ 44 #define _ARTSRTTTIMESERIESTABLEDATA_HH_ 45 46 extern "C" { 47 #include <sys/time.h> 48 49 #include "caida_t.h" 50 } 51 52 #include <vector> 53 54 //---------------------------------------------------------------------------- 55 // class ArtsRttTimeSeriesTableEntry 56 //---------------------------------------------------------------------------- 57 //! This class encapsulates a single RTT time series measurement (a 58 //! sample). Note we ony store time information here. This class is 59 //! not intended to be used directly for I/O, but instead as a component 60 //! of the ArtsRttTimeSeriesTableData class. 61 //! 62 //! Note we use some simple techniques to reduce disk space requirements 63 //! when storing this data. We use length,value encoding for several 64 //! fields, allowing us to store 32-bit values with only the number of 65 //! bytes required for the particular value (and 2 bits to indicate the 66 //! length). Some of the fields are permitted to have 0 length values; 67 //! this means the field is either not applicable (for example, RTT for 68 //! a measurement packet that was dropped) or the field's value is 69 //! implicit (from data elsewhere, hence the higher number of arguments 70 //! to the write() and read() members than those members in other Arts 71 //! classes... reminder, this class is not intended to be used directly 72 //! for disk I/O, and in fact the read() and write() members are not 73 //! visible except from the friend ArtsRttTimeSeriesTableData class). 74 //! 75 /*! When we write an ArtsRttTimeSeriesTableEntry to disk, we store the 76 following: 77 \verbatim 78 1 byte flags bitfield 79 0-4 byte RTT value (microseconds) 80 1-4 byte timestamp seconds offset 81 1-3 byte microseconds timestamp 82 83 The flags bitfield breaks down as follows: 84 85 +--+ 86 dropped packet flag (1 bit) | | msb (most signficant bit) 87 +--+ 88 seconds offset flag (1 bit) | | 89 +--+ 90 RTT size (2 bits) | | 91 + + 92 | | 93 +--+ 94 timestamp secs offset size (2 bits) | | 95 + + 96 | | 97 +--+ 98 timestamp usecs size (2 bits) | | 99 + + 100 | | lsb (least significant bit) 101 +--+ 102 \endverbatim 103 104 The meaning of the flag fields: 105 \verbatim 106 dropped packet flag (1 bit) 107 If set, the ArtsRttTimeSeriesTableEntry is for a dropped packet. 108 This implies that the RTT will not be stored on disk since it's 109 not applicable. Hence the RTT size flags should be 0. In terms 110 of applications using the API, they can set the rtt (via 111 Rtt(uint32_t rtt)) to k_droppedPacketRtt to indicate a dropped 112 packet, and Rtt() will return k_droppedPacketRtt for one of 113 these types of entries. 114 115 seconds offset flag (1 bit) 116 This flag indicates whether or not a seconds offset flag is stored. 117 The idea here is that when storing multiple adjacent RTT 118 measurements at greater than 1 per second, we often don't need 119 to store a seconds value and can instead make it implicit if it's 120 the same as the previous entry's seconds offset value. If this 121 flag is set, there is a seconds offset value. If it is not set, 122 there is no seconds offset value stored on disk (and the timestamp 123 secs offset size bits should be 0) and the value is assumed to be 124 that of the previous entry's seconds offset value. 125 126 RTT size (2 bits) 127 If there's an RTT value stored (dropped packet flag is 0), these 128 bits indicate the length of the stored RTT (which is in microseconds). 129 00 means it's a one-byte value, 01 means it's a 2-byte value, 10 130 means it's a 3-byte value and 11 means it's a 4-byte value. 131 132 timestamp secs offset size (2 bits) 133 If there's a timestamp seconds offset value for this entry (i.e. 134 the seconds offset flag is set), these bits indicate the length 135 of the stored timestamp seconds offset value. 00 means it's a 136 one-byte value, 01 means it's a 2-byte value, 10 means it's a 137 3-byte value and 11 means it's a 4-byte value. 138 139 timestamp usecs size (2 bits) 140 These bits indicate the length of the stored timestamp 141 microseconds value. 00 means it's a one-byte value, 01 means 142 it's a 2-byte value, 10 means it's a 3-byte value. Note we 143 should never need 4 bytes here, since microseconds roll over 144 at 20 bits (and hence only require 3 bytes of storage, max) 145 and our microseconds value is a remainder from the seconds value. 146 \endverbatim 147 None of this trickery needs to be understood by an application 148 programmer. From within an application, you just call Timestamp() 149 and Rtt() functions from the ArtsRttTimeSeriesTableEntry class, 150 and when doing disk I/O you use the higher-level 151 ArtsRttTimeSeriesTableData class members (which take care of the 152 I/O trickery under the hood). 153 */ 154 //--------------------------------------------------------------------------- 155 class ArtsRttTimeSeriesTableEntry 156 { 157 public: 158 static const uint32_t k_droppedPacketRtt = 0xffffffff; 159 160 //-------------------------------------------------------------------------- 161 // ArtsRttTimeSeriesTableEntry() 162 //.......................................................................... 163 //! constructor 164 //-------------------------------------------------------------------------- 165 ArtsRttTimeSeriesTableEntry(); 166 167 //-------------------------------------------------------------------------- 168 // ArtsRttTimeSeriesTableEntry(const ArtsRttTimeSeriesTableEntry & rttEntry) 169 //.......................................................................... 170 //! copy constructor 171 //-------------------------------------------------------------------------- 172 ArtsRttTimeSeriesTableEntry(const ArtsRttTimeSeriesTableEntry & rttEntry); 173 174 //-------------------------------------------------------------------------- 175 // ~ArtsRttTimeSeriesTableEntry() 176 //.......................................................................... 177 //! destructor 178 //-------------------------------------------------------------------------- 179 ~ArtsRttTimeSeriesTableEntry(); 180 181 //-------------------------------------------------------------------------- 182 // uint32_t Rtt() const 183 //.......................................................................... 184 //! Returns the RTT value (microseconds). 185 //-------------------------------------------------------------------------- 186 uint32_t Rtt() const; 187 188 //-------------------------------------------------------------------------- 189 // uint32_t Rtt(uint32_t rtt) 190 //.......................................................................... 191 //! Sets and returns the RTT value (microseconds). 192 //-------------------------------------------------------------------------- 193 uint32_t Rtt(uint32_t rtt); 194 195 //-------------------------------------------------------------------------- 196 // const struct timeval & Timestamp() const 197 //.......................................................................... 198 //! Returns a reference to the timestamp. 199 //-------------------------------------------------------------------------- 200 const struct timeval & Timestamp() const; 201 202 //-------------------------------------------------------------------------- 203 // const struct timeval & Timestamp(const struct timeval & timestamp) 204 //.......................................................................... 205 //! Sets the timestamp and returns a reference to the timestamp. 206 //-------------------------------------------------------------------------- 207 const struct timeval & Timestamp(const struct timeval & timestamp); 208 209 //-------------------------------------------------------------------------- 210 // ArtsRttTimeSeriesTableEntry & 211 // operator = (const ArtsRttTimeSeriesTableEntry & rttEntry) 212 //.......................................................................... 213 //! overloaded '=' operator for copying an ArtsRttTimeSeriesTableEntry. 214 //-------------------------------------------------------------------------- 215 ArtsRttTimeSeriesTableEntry & 216 operator = (const ArtsRttTimeSeriesTableEntry & rttEntry); 217 218 uint32_t Length(uint32_t timeBase, 219 uint32_t prevSecsOffset, 220 uint8_t version = 0) const; 221 222 friend class ArtsRttTimeSeriesTableData; 223 224 #ifndef NDEBUG 225 //------------------------------------------------------------------------ 226 // static uint32_t NumObjects() 227 //........................................................................ 228 // 229 //------------------------------------------------------------------------ NumObjects()230 static uint32_t NumObjects() 231 { 232 return(_numObjects); 233 } 234 #endif // NDEBUG 235 236 private: 237 uint32_t _rtt; 238 struct timeval _timestamp; 239 240 //-------------------------------------------------------------------------- 241 // std::ostream & write(std::ostream & os, uint32_t timeBase, 242 // uint32_t prevSecsOffset, uint8_t version = 0) const 243 //.......................................................................... 244 //! Writes an ArtsRttTimeSeriesTableEntry to an ostream. Returns the 245 //! ostream. Note this is a private member, but visible from the 246 //! ArtsRttTimeSeriesTableData class (a friend). 247 //-------------------------------------------------------------------------- 248 std::ostream & write(std::ostream & os, uint32_t timeBase, 249 uint32_t prevSecsOffset, uint8_t version = 0) const; 250 251 //-------------------------------------------------------------------------- 252 // int write(int fd, uint32_t timeBase, uint32_t prevSecsOffset, 253 // uint8_t version = 0) const 254 //.......................................................................... 255 //! Writes an ArtsRttTimeSeriesTableEntry to a file descriptor. Returns 256 //! the number of bytes written on success, -1 on failure. 257 //-------------------------------------------------------------------------- 258 int write(int fd, uint32_t timeBase, uint32_t prevSecsOffset, 259 uint8_t version = 0) const; 260 261 //-------------------------------------------------------------------------- 262 // std::istream & read(std::istream & is, uint32_t timeBase, 263 // uint32_t prevSecsOffset, uint8_t version = 0) 264 //.......................................................................... 265 //! Reads an ArtsRttTimeSeriesTableEntry from an istream. Returns the 266 //! istream. Note this is a private member, but visible from the 267 //! ArtsRttTimeSeriesTableData class (a friend). 268 //-------------------------------------------------------------------------- 269 std::istream & read(std::istream & is, uint32_t timeBase, 270 uint32_t prevSecsOffset, uint8_t version = 0); 271 272 //-------------------------------------------------------------------------- 273 // int read(int fd, uint32_t timeBase, 274 // uint32_t prevSecsOffset, uint8_t version = 0) 275 //.......................................................................... 276 //! Reads an ArtsRttTimeSeriesTableEntry from a file descriptor. Returns 277 //! the number of bytes read on success, -1 on failure. 278 //-------------------------------------------------------------------------- 279 int read(int fd, uint32_t timeBase, 280 uint32_t prevSecsOffset, uint8_t version = 0); 281 282 static uint32_t _numObjects; 283 }; 284 285 //---------------------------------------------------------------------------- 286 // class ArtsRttTimeSeriesTableEntryGreaterRtt 287 //---------------------------------------------------------------------------- 288 //! This class is used to compare ArtsRttTimeSeriesTableEntry objects 289 //! by their Rtt(). It can be used to sort ArtsRttTimeSeriesTableEntry 290 //! objects in descending order by Rtt(). 291 //---------------------------------------------------------------------------- 292 class ArtsRttTimeSeriesTableEntryGreaterRtt 293 { 294 public: 295 //-------------------------------------------------------------------------- 296 // bool operator()(const ArtsRttTimeSeriesTableEntry & rttEntry1, 297 // const ArtsRttTimeSeriesTableEntry & rttEntry2) 298 //.......................................................................... 299 // 300 //-------------------------------------------------------------------------- 301 bool operator()(const ArtsRttTimeSeriesTableEntry & rttEntry1, 302 const ArtsRttTimeSeriesTableEntry & rttEntry2); 303 }; 304 305 //---------------------------------------------------------------------------- 306 // class ArtsRttTimeSeriesTableEntryLessRtt 307 //---------------------------------------------------------------------------- 308 //! This class is used to compare ArtsRttTimeSeriesTableEntry objects 309 //! by their Rtt(). It can be used to sort ArtsRttTimeSeriesTableEntry 310 //! objects in ascending order by Rtt(). 311 //---------------------------------------------------------------------------- 312 class ArtsRttTimeSeriesTableEntryLessRtt 313 { 314 public: 315 //-------------------------------------------------------------------------- 316 // bool operator()(const ArtsRttTimeSeriesTableEntry & rttEntry1, 317 // const ArtsRttTimeSeriesTableEntry & rttEntry2) 318 //.......................................................................... 319 // 320 //-------------------------------------------------------------------------- 321 bool operator()(const ArtsRttTimeSeriesTableEntry & rttEntry1, 322 const ArtsRttTimeSeriesTableEntry & rttEntry2); 323 }; 324 325 326 //---------------------------------------------------------------------------- 327 // class ArtsRttTimeSeriesTableData 328 //---------------------------------------------------------------------------- 329 //! This class encapsulates RTT (round-trip time) time-series data. It 330 //! holds a number of ArtsRttTimeSeriesTableEntry objects and provides 331 //! for I/O functionality (reading and writing RTT time series data). 332 //! Each entry contains a timestamp (struct timeval) and an RTT (in 333 //! microseconds). You can indicate a dropped RTT measurement packet by 334 //! setting an ArtsRttTimeSeriesTableEntry's RTT to 335 //! ArtsRttTimeSeriesTableEntry::k_droppedPacketRtt. 336 //! 337 //! We use some simple techniques to save some space on disk when storing 338 //! this data: see the comments in the ArtsRttTimeSeriesTableEntry class. 339 //! 340 //! This class also holds the destination IP address of the measurement. 341 //! The source IP address is assumed to be a host attribute in the 342 //! higher-level Arts class' attribute vector. 343 //---------------------------------------------------------------------------- 344 class ArtsRttTimeSeriesTableData 345 { 346 public: 347 //-------------------------------------------------------------------------- 348 // ArtsRttTimeSeriesTableData() 349 //.......................................................................... 350 //! constructor 351 //-------------------------------------------------------------------------- 352 ArtsRttTimeSeriesTableData(); 353 354 //-------------------------------------------------------------------------- 355 // ArtsRttTimeSeriesTableData(const ArtsRttTimeSeriesTableData & rttTable) 356 //.......................................................................... 357 //! copy constructor 358 //-------------------------------------------------------------------------- 359 ArtsRttTimeSeriesTableData(const ArtsRttTimeSeriesTableData & rttTable); 360 361 //-------------------------------------------------------------------------- 362 // ~ArtsRttTimeSeriesTableData() 363 //.......................................................................... 364 //! destructor 365 //-------------------------------------------------------------------------- 366 ~ArtsRttTimeSeriesTableData(); 367 368 //-------------------------------------------------------------------------- 369 // ArtsRttTimeSeriesTableData & 370 // operator = (const ArtsRttTimeSeriesTableData & rttTable) 371 //.......................................................................... 372 //! Overloaded '=' operator for copying an ArtsRttTimeSeriesTableData 373 //! to another. 374 //-------------------------------------------------------------------------- 375 ArtsRttTimeSeriesTableData & 376 operator = (const ArtsRttTimeSeriesTableData & rttTable); 377 378 //-------------------------------------------------------------------------- 379 // std::vector<ArtsRttTimeSeriesTableEntry> & RttEntries() const 380 //.......................................................................... 381 //! Returns a reference to the vector of RTT entries. 382 //-------------------------------------------------------------------------- 383 std::vector<ArtsRttTimeSeriesTableEntry> & RttEntries() const; 384 385 //-------------------------------------------------------------------------- 386 // void AddRttEntry(const ArtsRttTimeSeriesTableEntry & rttEntry) 387 //.......................................................................... 388 //! Adds an RTT entry to the vector of RTT entries. 389 //-------------------------------------------------------------------------- 390 void AddRttEntry(const ArtsRttTimeSeriesTableEntry & rttEntry); 391 392 //-------------------------------------------------------------------------- 393 // uint32_t Length(uint8_t version = 0) const 394 //.......................................................................... 395 //! Returns the number of bytes required to store the 396 //! ArtsRttTimeSeriesTableData on disk. 397 //-------------------------------------------------------------------------- 398 uint32_t Length(uint8_t version = 0) const; 399 400 //-------------------------------------------------------------------------- 401 // std::istream & read(std::istream& is, uint8_t version = 0) 402 //.......................................................................... 403 //! Reads an ArtsRttTimeSeriesTableData object from an istream. 404 //! Returns the istream. 405 //-------------------------------------------------------------------------- 406 std::istream & read(std::istream& is, uint8_t version = 0); 407 408 //-------------------------------------------------------------------------- 409 // int read(int fd, uint8_t version = 0) 410 //.......................................................................... 411 //! Reads an ArtsRttTimeSeriesTableData object from a file descriptor. 412 //! Returns the number of bytes read on success, -1 on failure. 413 //-------------------------------------------------------------------------- 414 int read(int fd, uint8_t version = 0); 415 416 //-------------------------------------------------------------------------- 417 // std::ostream & write(std::ostream & os, uint8_t version = 0) const 418 //.......................................................................... 419 //! Writes an ArtsRttTimeSeriesTableData object to an ostream. 420 //! Returns the ostream. 421 //-------------------------------------------------------------------------- 422 std::ostream & write(std::ostream & os, uint8_t version = 0) const; 423 424 //-------------------------------------------------------------------------- 425 // int write(int fd, uint8_t version = 0) const 426 //.......................................................................... 427 //! Writes an ArtsRttTimeSeriesTableData object to a file descriptor. 428 //! Returns the number of bytes written on success, -1 on failure. 429 //-------------------------------------------------------------------------- 430 int write(int fd, uint8_t version = 0) const; 431 432 //-------------------------------------------------------------------------- 433 // void SortEntriesByTimestamp() 434 //.......................................................................... 435 //! Sorts the contained ArtsRttTimeSeriesTableEntry objects by their 436 //! timestamp. This is useful when you're doing something like using 437 //! the receive timestamp for measurement packets that are returned but 438 //! using the transmit timestamp for dropped measurement packets, or 439 //! are receiving out-of-order packets and using the receive timestamp. 440 //! 441 //! This function is always called by write(), since we want to be sure to 442 //! store RTT measurements in chronological order on disk. 443 //-------------------------------------------------------------------------- 444 void SortEntriesByTimestamp(); 445 446 //-------------------------------------------------------------------------- 447 // const ArtsRttTimeSeriesTableEntry & RttMax() const 448 //.......................................................................... 449 //! Returns the maximum RTT entry (by RTT value). If the table has 450 //! no RTT entries, returns an ArtsRttTimeSeriesTableEntry with a 451 //! timestamp and RTT value of 0. 452 //-------------------------------------------------------------------------- 453 const ArtsRttTimeSeriesTableEntry & RttMax() const; 454 455 //-------------------------------------------------------------------------- 456 // const ArtsRttTimeSeriesTableEntry & RttMin() const 457 //.......................................................................... 458 //! Returns the minimum RTT entry (by RTT value). If the table has 459 //! no RTT entries, returns an ArtsRttTimeSeriesTableEntry with a 460 //! timestamp and RTT value of 0. 461 //-------------------------------------------------------------------------- 462 const ArtsRttTimeSeriesTableEntry & RttMin() const; 463 464 //-------------------------------------------------------------------------- 465 // const ArtsRttTimeSeriesTableEntry & RttPercentile(int percentile) const 466 //.......................................................................... 467 //! Returns the RTT entry whose RTT value is the percentile (0 to 100) 468 //! value of all table entries. If the table has no RTT entries, 469 //! returns an ArtsRttTimeSeriesTableEntry with a timestamp and RTT 470 //! value of 0. 471 //-------------------------------------------------------------------------- 472 const ArtsRttTimeSeriesTableEntry & RttPercentile(int percentile) const; 473 474 //-------------------------------------------------------------------------- 475 // size_t RttPercentiles(const std::vector<int> & percentiles, 476 // std::vector<uint32_t> & results) const 477 //.......................................................................... 478 // 479 //-------------------------------------------------------------------------- 480 size_t RttPercentiles(const std::vector<int> & percentiles, 481 std::vector<uint32_t> & results) const; 482 483 //-------------------------------------------------------------------------- 484 // const ArtsRttTimeSeriesTableEntry & RttMedian() const 485 //.......................................................................... 486 //! Returns the RTT entry whose RTT value is the median (50th percentile) 487 //! value of all table entries. If the table has no RTT entries, 488 //! returns an ArtsRttTimeSeriesTableEntry with a timestamp and RTT 489 //! value of 0. 490 //-------------------------------------------------------------------------- 491 const ArtsRttTimeSeriesTableEntry & RttMedian() const; 492 493 //-------------------------------------------------------------------------- 494 // const ArtsRttTimeSeriesTableEntry & RttLowerQuartile() const 495 //.......................................................................... 496 //! Returns the RTT entry whose RTT value is the lower quartile (25th 497 //! percentile) value of all table entries. If the table has no RTT 498 //! entries, returns an ArtsRttTimeSeriesTableEntry with a timestamp 499 //! and RTT value of 0. 500 //-------------------------------------------------------------------------- 501 const ArtsRttTimeSeriesTableEntry & RttLowerQuartile() const; 502 503 //-------------------------------------------------------------------------- 504 // const ArtsRttTimeSeriesTableEntry & RttUpperQuartile() const 505 //.......................................................................... 506 //! Returns the RTT entry whose RTT value is the upper quartile (75th 507 //! percentile) value of all table entries. If the table has no RTT 508 //! entries, returns an ArtsRttTimeSeriesTableEntry with a timestamp 509 //! and RTT value of 0. 510 //-------------------------------------------------------------------------- 511 const ArtsRttTimeSeriesTableEntry & RttUpperQuartile() const; 512 513 //-------------------------------------------------------------------------- 514 // double AveragePacketLoss() const 515 //.......................................................................... 516 //! Returns the average percentage of packet loss (0.0 - 100.0) in the 517 //! RTT table. 518 //-------------------------------------------------------------------------- 519 double AveragePacketLoss() const; 520 521 //-------------------------------------------------------------------------- 522 // void ClearRttData() 523 //.......................................................................... 524 //! Clears the RTT data (erases all RTT entries and clears the time 525 //! base). This would typically be used in an application that wants 526 //! to reuse an ArtsRttTimeSeriesTableData object (perhaps to avoid 527 //! the overhead of construction/destruction). This function does *not* 528 //! touch the destination IP address field. 529 //-------------------------------------------------------------------------- 530 void ClearRttData(); 531 532 //-------------------------------------------------------------------------- 533 // friend std::ostream & 534 // operator << (std::ostream & os, 535 // const ArtsRttTimeSeriesTableData & rttTimeSeriesTable) 536 //.......................................................................... 537 //! Overloaded ostream << operator to dump the contents of an 538 //! ArtsRttTimeSeriesTableData object ot an ostream in a human-readable 539 //! form. 540 //-------------------------------------------------------------------------- 541 friend std::ostream & 542 operator << (std::ostream & os, 543 const ArtsRttTimeSeriesTableData & rttTimeSeriesTable); 544 545 #ifndef NDEBUG 546 //------------------------------------------------------------------------ 547 // static uint32_t NumObjects() 548 //........................................................................ 549 // 550 //------------------------------------------------------------------------ NumObjects()551 static uint32_t NumObjects() 552 { 553 return(_numObjects); 554 } 555 #endif // NDEBUG 556 557 protected: 558 //-------------------------------------------------------------------------- 559 // uint32_t TimeBase() const 560 //.......................................................................... 561 //! Returns the timebase of the object. This can't be called directly 562 //! by applications; it would be private but we want it for operator = 563 //! and the copy constructor. 564 //-------------------------------------------------------------------------- 565 uint32_t TimeBase() const; 566 567 //-------------------------------------------------------------------------- 568 // uint32_t TimeBase(uint32_t timeBase) 569 //.......................................................................... 570 //! Sets and returns the timebase of the object. This can't be called 571 //! directly by applications; it would be private but we want it for 572 //! operator = and the copy constructor. 573 //-------------------------------------------------------------------------- 574 uint32_t TimeBase(uint32_t timeBase); 575 576 private: 577 mutable uint32_t _timeBase; 578 mutable std::vector<ArtsRttTimeSeriesTableEntry> _rttEntries; 579 580 static uint32_t _numObjects; 581 }; 582 583 //---------------------------------------------------------------------------- 584 // class ArtsRttTimeSeriesTableEntryTimestampsLess 585 //---------------------------------------------------------------------------- 586 //! This class is used to compare ArtsRttTimeSeriesTableEntry objects 587 //! by their timestamps. It is used to sort ArtsRttTimeSeriesTableEntry 588 //! objects by timestamp in an ArtsRttTimeSeriesTableData object. 589 //---------------------------------------------------------------------------- 590 class ArtsRttTimeSeriesTableEntryTimestampsLess 591 { 592 public: 593 //-------------------------------------------------------------------------- 594 // bool operator () (const ArtsRttTimeSeriesTableEntry & rtt1, 595 // const ArtsRttTimeSeriesTableEntry & rtt2) 596 //.......................................................................... 597 // 598 //-------------------------------------------------------------------------- operator ()(const ArtsRttTimeSeriesTableEntry & rtt1,const ArtsRttTimeSeriesTableEntry & rtt2)599 bool operator () (const ArtsRttTimeSeriesTableEntry & rtt1, 600 const ArtsRttTimeSeriesTableEntry & rtt2) 601 { 602 if (rtt1.Timestamp().tv_sec < rtt2.Timestamp().tv_sec) 603 return(true); 604 if ((rtt1.Timestamp().tv_sec == rtt2.Timestamp().tv_sec) && 605 (rtt1.Timestamp().tv_usec < rtt2.Timestamp().tv_usec)) 606 return(true); 607 return(false); 608 } 609 }; 610 611 612 #endif // _ARTSRTTTIMESERIESTABLEDATA_HH_ 613