• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

daemon/src/core/BundleStorage.h

Go to the documentation of this file.
00001 /*
00002  * BundleStorage.h
00003  *
00004  *  Created on: 24.03.2009
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef BUNDLESTORAGE_H_
00009 #define BUNDLESTORAGE_H_
00010 
00011 #include <ibrdtn/data/Bundle.h>
00012 #include <ibrdtn/data/BundleID.h>
00013 #include <ibrdtn/data/MetaBundle.h>
00014 #include <ibrcommon/data/BloomFilter.h>
00015 
00016 #include <stdexcept>
00017 #include <iterator>
00018 #include <set>
00019 
00020 namespace dtn
00021 {
00022         namespace core
00023         {
00024                 class BundleStorage
00025                 {
00026                 public:
00027                         class NoBundleFoundException : public dtn::MissingObjectException
00028                         {
00029                         public:
00030                                 NoBundleFoundException(string what = "No bundle match the specified criteria.") throw() : dtn::MissingObjectException(what)
00031                                 {
00032                                 };
00033                         };
00034 
00035                         class BundleLoadException : public NoBundleFoundException
00036                         {
00037                         public:
00038                                 BundleLoadException(string what = "Error while loading bundle data.") throw() : NoBundleFoundException(what)
00039                                 {
00040                                 };
00041                         };
00042 
00043                         class StorageSizeExeededException : public ibrcommon::Exception
00044                         {
00045                         public:
00046                                 StorageSizeExeededException(string what = "No space left in the storage.") throw() : ibrcommon::Exception(what)
00047                                 {
00048                                 };
00049                         };
00050 
00051                         class BundleFilterCallback
00052                         {
00053                         public:
00054                                 virtual ~BundleFilterCallback() {};
00055 
00060                                 virtual size_t limit() const { return 1; };
00061 
00068                                 virtual bool shouldAdd(const dtn::data::MetaBundle&) const { return false; };
00069                         };
00070 
00074                         virtual ~BundleStorage() = 0;
00075 
00080                         virtual void store(const dtn::data::Bundle &bundle) = 0;
00081 
00087                         virtual dtn::data::Bundle get(const dtn::data::BundleID &id) = 0;
00088 
00095                         virtual const std::list<dtn::data::MetaBundle> get(BundleFilterCallback &cb) = 0;
00096 
00102                         virtual void remove(const dtn::data::BundleID &id) = 0;
00103 
00109                         void remove(const dtn::data::Bundle &b);
00110 
00116                         virtual dtn::data::MetaBundle remove(const ibrcommon::BloomFilter &filter) = 0;
00117 
00121                         virtual void clear() {};
00122 
00126                         virtual bool empty() { return true; };
00127 
00131                         virtual unsigned int count() { return 0; };
00132 
00138                         virtual void releaseCustody(const dtn::data::EID &custodian, const dtn::data::BundleID &id) = 0;
00139 
00146                         const dtn::data::EID acceptCustody(const dtn::data::MetaBundle &meta);
00147 
00153                         void rejectCustody(const dtn::data::MetaBundle &meta);
00154 
00155                 protected:
00159                         BundleStorage();
00160                 };
00161         }
00162 }
00163 
00164 #endif /* BUNDLESTORAGE_H_ */

Generated on Wed Mar 30 2011 11:11:49 for IBR-DTNSuite by  doxygen 1.7.1