00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _PROPHET_ACK_H_
00018 #define _PROPHET_ACK_H_
00019
00020 #include <string>
00021 #include <sys/types.h>
00022
00023 namespace prophet
00024 {
00025
00031 class Ack
00032 {
00033 public:
00037 Ack()
00038 : dest_id_(""), cts_(0), seq_(0), ets_(0) {}
00039
00043 Ack(std::string endpoint_id,
00044 u_int32_t cts = 0,
00045 u_int32_t seq = 0,
00046 u_int32_t ets = 0)
00047 : dest_id_(endpoint_id), cts_(cts),
00048 seq_(seq), ets_(ets) {}
00049
00053 Ack(const Ack& a)
00054 : dest_id_(a.dest_id_), cts_(a.cts_),
00055 seq_(a.seq_), ets_(a.ets_) {}
00056
00058 std::string dest_id() const { return dest_id_; }
00059 u_int32_t cts() const { return cts_; }
00060 u_int32_t seq() const { return seq_; }
00061 u_int32_t ets() const { return ets_; }
00063
00065 void set_dest_id ( const std::string& dest_id )
00066 {
00067 dest_id_.assign(dest_id);
00068 }
00069 void set_cts (u_int32_t cts) { cts_ = cts; }
00070 void set_seq (u_int32_t seq) { seq_ = seq; }
00071 void set_ets (u_int32_t ets) { ets_ = ets; }
00073
00077 bool operator< ( const Ack& a ) const
00078 {
00079 int comp = dest_id_.compare(a.dest_id_);
00080 if (comp == 0)
00081 {
00082 if (cts_ == a.cts_)
00083 return seq_ < a.seq_;
00084 else
00085 return (cts_ < a.cts_);
00086 }
00087 return (comp < 0);
00088 }
00089
00093 Ack& operator= ( const Ack& a )
00094 {
00095 dest_id_.assign(a.dest_id_);
00096 cts_ = a.cts_;
00097 seq_ = a.seq_;
00098 ets_ = a.ets_;
00099 return *this;
00100 }
00101
00102 protected:
00103 std::string dest_id_;
00104 u_int32_t cts_;
00105 u_int32_t seq_;
00106 u_int32_t ets_;
00107
00108 };
00109
00110 };
00111
00112 #endif // _PROPHET_ACK_H_