IBR-DTNSuite  0.10
BundleSet.h
Go to the documentation of this file.
1 /*
2  * BundleSet.h
3  *
4  * Created on: 18.12.2012
5  * Author: morgenro
6  */
7 
8 #ifndef BUNDLESET_H_
9 #define BUNDLESET_H_
10 
11 #include "ibrdtn/data/Number.h"
12 #include "ibrdtn/data/MetaBundle.h"
14 #include <set>
15 
16 namespace dtn
17 {
18  namespace data
19  {
20  class BundleSet
21  {
22  public:
23  class Listener {
24  public:
25  virtual ~Listener() = 0;
26  virtual void eventBundleExpired(const dtn::data::MetaBundle&) throw () = 0;
27  };
28 
32  BundleSet(Listener *listener = NULL, Length bf_size = 1024);
33  virtual ~BundleSet();
34 
35  virtual void add(const dtn::data::MetaBundle &bundle) throw ();
36  virtual void clear() throw ();
37  virtual bool has(const dtn::data::BundleID &bundle) const throw ();
38 
39  virtual void expire(const Timestamp timestamp) throw ();
40 
44  virtual Size size() const throw ();
45 
49  Length getLength() const throw ();
50 
51  const ibrcommon::BloomFilter& getBloomFilter() const throw ();
52 
53  std::set<dtn::data::MetaBundle> getNotIn(ibrcommon::BloomFilter &filter) const throw ();
54 
55  friend std::ostream &operator<<(std::ostream &stream, const BundleSet &obj);
56  friend std::istream &operator>>(std::istream &stream, BundleSet &obj);
57 
58  private:
59  class ExpiringBundle
60  {
61  public:
62  ExpiringBundle(const MetaBundle &b);
63  virtual ~ExpiringBundle();
64 
65  bool operator!=(const ExpiringBundle& other) const;
66  bool operator==(const ExpiringBundle& other) const;
67  bool operator<(const ExpiringBundle& other) const;
68  bool operator>(const ExpiringBundle& other) const;
69 
70  const dtn::data::MetaBundle &bundle;
71  };
72 
73  std::set<dtn::data::MetaBundle> _bundles;
74  std::set<ExpiringBundle> _expire;
75 
77 
78  Listener *_listener;
79 
80  bool _consistent;
81  };
82  } /* namespace data */
83 } /* namespace dtn */
84 #endif /* BUNDLESET_H_ */