IBR-DTNSuite  0.12
RetransmissionExtension.h
Go to the documentation of this file.
1 /*
2  * RetransmissionExtension.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef RETRANSMISSIONEXTENSION_H_
23 #define RETRANSMISSIONEXTENSION_H_
24 
26 #include "core/EventReceiver.h"
27 #include <ibrdtn/data/BundleID.h>
28 #include <ibrdtn/data/EID.h>
29 #include <ibrcommon/thread/Mutex.h>
30 #include <queue>
31 #include <set>
32 
33 namespace dtn
34 {
35  namespace routing
36  {
38  {
39  public:
41  virtual ~RetransmissionExtension();
42 
46  virtual void eventTransferCompleted(const dtn::data::EID &peer, const dtn::data::MetaBundle &meta) throw ();
47 
48  void raiseEvent(const dtn::core::Event *evt) throw ();
49  void componentUp() throw ();
50  void componentDown() throw ();
51 
52  private:
53  class RetransmissionData : public dtn::data::BundleID
54  {
55  public:
56  RetransmissionData(const dtn::data::BundleID &id, const dtn::data::EID &destination, const dtn::data::Size retry = 2);
57  virtual ~RetransmissionData();
58 
59 
60  const dtn::data::EID destination;
61 
62  const dtn::data::Timestamp& getTimestamp() const;
63  dtn::data::Size getCount() const;
64 
65  RetransmissionData& operator++();
66  RetransmissionData& operator++(int);
67 
68  bool operator!=(const RetransmissionData &obj);
69  bool operator==(const RetransmissionData &obj);
70 
71  private:
72  dtn::data::Timestamp _timestamp;
73  dtn::data::Size _count;
74  const dtn::data::Size retry;
75  };
76 
77  ibrcommon::Mutex _mutex;
78  std::queue<RetransmissionData> _queue;
79  std::set<RetransmissionData> _set;
80  };
81  }
82 }
83 
84 #endif /* RETRANSMISSIONEXTENSION_H_ */