IBR-DTNSuite
0.8
|
00001 /* 00002 * BundleMerger.h 00003 * 00004 * Created on: 25.01.2010 00005 * Author: morgenro 00006 */ 00007 00008 #ifndef BUNDLEMERGER_H_ 00009 #define BUNDLEMERGER_H_ 00010 00011 #include "ibrcommon/data/BLOB.h" 00012 #include "ibrdtn/data/Bundle.h" 00013 #include <set> 00014 00015 namespace dtn 00016 { 00017 namespace data 00018 { 00019 class BundleMerger 00020 { 00021 public: 00022 class Chunk 00023 { 00024 public: 00025 Chunk(size_t, size_t); 00026 virtual ~Chunk(); 00027 00028 bool operator<(const Chunk &other) const; 00029 00030 size_t offset; 00031 size_t length; 00032 00033 static bool isComplete(size_t length, const std::set<Chunk> &chunks); 00034 }; 00035 00036 class Container 00037 { 00038 public: 00039 Container(ibrcommon::BLOB::Reference &ref); 00040 virtual ~Container(); 00041 bool isComplete(); 00042 00043 Bundle& getBundle(); 00044 00045 friend Container &operator<<(Container &c, dtn::data::Bundle &obj); 00046 00047 private: 00048 bool contains(size_t offset, size_t length) const; 00049 void add(size_t offset, size_t length); 00050 00051 dtn::data::Bundle _bundle; 00052 ibrcommon::BLOB::Reference _blob; 00053 bool _initialized; 00054 00055 std::set<Chunk> _chunks; 00056 size_t _appdatalength; 00057 }; 00058 00059 static Container getContainer(); 00060 static Container getContainer(ibrcommon::BLOB::Reference &ref); 00061 }; 00062 } 00063 } 00064 00065 00066 #endif /* BUNDLEMERGER_H_ */