IBR-DTNSuite  0.8
daemon/src/routing/RetransmissionExtension.h
Go to the documentation of this file.
00001 /*
00002  * RetransmissionExtension.h
00003  *
00004  *  Created on: 09.03.2010
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef RETRANSMISSIONEXTENSION_H_
00009 #define RETRANSMISSIONEXTENSION_H_
00010 
00011 #include "routing/BaseRouter.h"
00012 #include <ibrdtn/data/BundleID.h>
00013 #include <ibrdtn/data/EID.h>
00014 #include <ibrcommon/thread/Mutex.h>
00015 #include <queue>
00016 #include <set>
00017 
00018 namespace dtn
00019 {
00020         namespace routing
00021         {
00022                 class RetransmissionExtension : public BaseRouter::Extension
00023                 {
00024                 public:
00025                         RetransmissionExtension();
00026                         virtual ~RetransmissionExtension();
00027 
00028                         void notify(const dtn::core::Event *evt);
00029 
00030                 private:
00031                         class RetransmissionData : public dtn::data::BundleID
00032                         {
00033                         public:
00034                                 RetransmissionData(const dtn::data::BundleID &id, dtn::data::EID destination, size_t retry = 2);
00035                                 virtual ~RetransmissionData();
00036 
00037 
00038                                 const dtn::data::EID destination;
00039 
00040                                 size_t getTimestamp() const;
00041                                 size_t getCount() const;
00042 
00043                                 RetransmissionData& operator++();
00044                                 RetransmissionData& operator++(int);
00045 
00046                                 bool operator!=(const RetransmissionData &obj);
00047                                 bool operator==(const RetransmissionData &obj);
00048 
00049                         private:
00050                                 size_t _timestamp;
00051                                 size_t _count;
00052                                 const size_t retry;
00053                         };
00054 
00055                         ibrcommon::Mutex _mutex;
00056                         std::queue<RetransmissionData> _queue;
00057                         std::set<RetransmissionData> _set;
00058                 };
00059         }
00060 }
00061 
00062 #endif /* RETRANSMISSIONEXTENSION_H_ */