00001 /*****************************************************************************/ 00002 /* */ 00003 /* XrdMonDecOnePacket.hh */ 00004 /* */ 00005 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */ 00006 /* All Rights Reserved */ 00007 /* Produced by Jacek Becla for Stanford University under contract */ 00008 /* DE-AC02-76SF00515 with the Department of Energy */ 00009 /*****************************************************************************/ 00010 00011 // $Id: XrdMonDecOnePacket.hh 22437 2008-03-04 14:35:16Z rdm $ 00012 00013 #ifndef XRDMONDECONEPACKET_HH 00014 #define XRDMONDECONEPACKET_HH 00015 00016 #include "XrdMon/XrdMonCommon.hh" 00017 00018 #include <fstream> 00019 #include <sys/time.h> 00020 using std::fstream; 00021 using std::ostream; 00022 00023 class XrdMonDecOnePacket { 00024 public: 00025 XrdMonDecOnePacket() {} 00026 XrdMonDecOnePacket(bool); // LOST 00027 XrdMonDecOnePacket(int errType, kXR_int64 pos); 00028 int init(const char* buf, int bytesLeft, kXR_int64 fPos); 00029 00030 static dictid_t minDictId() { return _minDictId; } 00031 static dictid_t maxDictId() { return _maxDictId; } 00032 static void resetNextNr() { _nextNr = 0; } 00033 00034 long myNr() const { return _myNr; } 00035 kXR_int64 fPos() const { return _fPos; } 00036 kXR_int16 seq() const { return _seq; } 00037 dictid_t dictId() const { return _dictId; } 00038 packetlen_t len() const { return _len; } 00039 kXR_int32 stod() const { return _stod; } 00040 00041 bool isLost() const { return _seq == LOST; } 00042 00043 void setOOOStatus() { _seq = OOO; } 00044 00045 00046 enum { REGULAR = 257, // not lost, not out of order 00047 LOST = -1, // lost packet 00048 OOO = -2, // out of order 00049 INVALID = -3 // just ignore this slot 00050 }; 00051 00052 private: 00053 static long _nextNr; 00054 static dictid_t _minDictId; 00055 static dictid_t _maxDictId; 00056 00057 long _myNr; // id to identify this packet 00058 00059 kXR_int64 _fPos; // offset of this packet in the file 00060 kXR_int16 _seq; // seqNo, or info: lost/outoforder/emptyslot 00061 dictid_t _dictId; // dict id, or -1 00062 packetlen_t _len; // packet size 00063 kXR_int32 _stod; // when xrd server was started 00064 00065 friend ostream& operator<<(ostream& o, const XrdMonDecOnePacket& p); 00066 }; 00067 00068 #endif /* XRDMONDECONEPACKET_HH */