00001 #ifndef SIMPLEBUNDLESTORAGE_H_ 00002 #define SIMPLEBUNDLESTORAGE_H_ 00003 00004 #include "core/BundleCore.h" 00005 #include "core/AbstractBundleStorage.h" 00006 #include "core/Node.h" 00007 #include "data/Bundle.h" 00008 #include "utils/Service.h" 00009 #include "utils/MutexLock.h" 00010 #include "utils/Mutex.h" 00011 #include "utils/Conditional.h" 00012 #include <list> 00013 #include <map> 00014 00015 using namespace dtn::data; 00016 using namespace dtn::utils; 00017 00018 namespace dtn 00019 { 00020 namespace core 00021 { 00025 class SimpleBundleStorage : public Service, public AbstractBundleStorage 00026 { 00027 public: 00033 SimpleBundleStorage(unsigned int size = 1024 * 1024, unsigned int bundle_maxsize = 1024); 00034 00038 virtual ~SimpleBundleStorage(); 00039 00043 void store(const BundleSchedule &schedule); 00044 00048 Bundle* storeFragment(const Bundle &bundle); 00049 00053 BundleSchedule getSchedule(unsigned int dtntime); 00054 00058 BundleSchedule getSchedule(string destination); 00059 00063 void clear(); 00064 00068 bool isEmpty(); 00069 00073 unsigned int getCount(); 00074 00075 protected: 00079 virtual void tick(); 00080 00081 void terminate(); 00082 00083 void eventNodeAvailable(const Node &node); 00084 void eventNodeUnavailable(const Node &node); 00085 00086 private: 00087 list<BundleSchedule> m_schedules; 00088 list<list<Bundle> > m_fragments; 00089 00094 void deleteDeprecated(); 00095 00099 unsigned int m_nextdeprecation; 00100 00101 time_t m_last_compress; 00102 00103 unsigned int m_size; 00104 unsigned int m_bundle_maxsize; 00105 00106 unsigned int m_currentsize; 00107 00108 bool m_nocleanup; 00109 00110 Mutex m_readlock; 00111 Mutex m_fragmentslock; 00112 00113 map<string,Node> m_neighbours; 00114 }; 00115 } 00116 } 00117 00118 #endif /*SIMPLEBUNDLESTORAGE_H_*/
1.5.6