IBR-DTNSuite  0.8
ibrdtn/ibrdtn/data/BundleList.h
Go to the documentation of this file.
00001 /*
00002  * BundleList.h
00003  *
00004  *  Created on: 19.02.2010
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef BUNDLELIST_H_
00009 #define BUNDLELIST_H_
00010 
00011 #include <ibrdtn/data/MetaBundle.h>
00012 #include <set>
00013 
00014 namespace dtn
00015 {
00016         namespace data
00017         {
00018                 class BundleList : public std::set<dtn::data::MetaBundle>
00019                 {
00020                 public:
00021                         BundleList();
00022                         virtual ~BundleList();
00023 
00024                         virtual void add(const dtn::data::MetaBundle &bundle);
00025                         virtual void remove(const dtn::data::MetaBundle &bundle);
00026                         virtual void clear();
00027                         virtual bool contains(const dtn::data::BundleID &bundle) const;
00028 
00029                         void expire(const size_t timestamp);
00030 
00031                         bool operator==(const size_t version) const;
00032                         size_t getVersion() const;
00033 
00034                 protected:
00035                         class ExpiringBundle
00036                         {
00037                         public:
00038                                 ExpiringBundle(const MetaBundle &b);
00039                                 virtual ~ExpiringBundle();
00040 
00041                                 bool operator!=(const ExpiringBundle& other) const;
00042                                 bool operator==(const ExpiringBundle& other) const;
00043                                 bool operator<(const ExpiringBundle& other) const;
00044                                 bool operator>(const ExpiringBundle& other) const;
00045 
00046                                 const MetaBundle bundle;
00047                                 const size_t expiretime;
00048                         };
00049 
00050                         virtual void eventBundleExpired(const ExpiringBundle&) {};
00051                         virtual void eventCommitExpired() {};
00052 
00053                         std::set<ExpiringBundle> _bundles;
00054 
00055                 private:
00056                         // the version value gets incremented on every change
00057                         size_t _version;
00058                 };
00059 
00060         }
00061 }
00062 
00063 #endif /* BUNDLELIST_H_ */