00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _PROPHET_ACK_LIST_H_
00018 #define _PROPHET_ACK_LIST_H_
00019
00020 #include <set>
00021 #include "Ack.h"
00022 #include "Bundle.h"
00023 #include "PointerList.h"
00024
00025 namespace prophet
00026 {
00027
00028 struct AckComp : public std::less<Ack*>
00029 {
00030 bool operator() (const Ack* a, const Ack* b) const
00031 {
00032 return *a < *b;
00033 }
00034 };
00035
00036
00037 class BundleCore;
00038
00045 class AckList
00046 {
00047 public:
00051 AckList() {}
00052
00056 AckList(const AckList& list)
00057 : acks_(list.acks_) {}
00058
00062 ~AckList();
00063
00071 bool insert(const std::string& dest_id, u_int32_t cts,
00072 u_int32_t seq = 0, u_int32_t ets = 0);
00073
00078 bool insert(const Bundle* b, const BundleCore* core);
00079
00083 bool insert(const Ack* ack);
00084
00089 size_t clone(PointerList<Ack>& list) const;
00090
00096 size_t fetch(const std::string& dest_id, PointerList<Ack>* list) const;
00097
00102 size_t expire();
00103
00107 size_t size() const { return acks_.size(); }
00108
00113 bool is_ackd(const std::string& dest_id,
00114 u_int32_t cts, u_int32_t seq) const;
00115
00119 bool empty() const { return acks_.empty(); }
00120
00121 protected:
00122 typedef std::set<Ack*,AckComp> palist;
00123 palist acks_;
00124
00125 };
00126
00127 };
00128
00129 #endif // _PROPHET_ACK_LIST_H_