00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "VolatileBundleStore.h"
00032 #include "Node.h"
00033
00034 using namespace DTN;
00035
00036 void
00037 VolatileBundleStore::clean()
00038 {
00039
00040 BundlePointer itr = p_getPointer( BundlePointer() );
00041 BundlePointer prev;
00042 while ( ! itr.isNull() )
00043 {
00044 Bundle* b = itr.repr()->bundle();
00045 if ( b->expired() )
00046 {
00047 itr = prev;
00048 p_deleteBundle( b );
00049 m_owner->drop( b, ExpiryDrop::inst );
00050 }
00051 prev = itr;
00052 if ( itr.isNull() )
00053 {
00054 itr = p_getPointer( BundlePointer() );
00055 }
00056 else
00057 {
00058 itr = itr.next();
00059 }
00060 }
00061 }
00062
00063 BundlePointer
00064 VolatileBundleStore::addBundle( Bundle* b )
00065 {
00066 clean();
00067 return p_addBundle(b);
00068 }
00069
00070 void
00071 VolatileBundleStore::deleteBundle( Bundle* b )
00072 {
00073 clean();
00074 p_deleteBundle(b);
00075 }
00076
00077 BundlePointer
00078 VolatileBundleStore::getPointer( const BundlePointer& p )
00079 {
00080 clean();
00081 return p_getPointer(p);
00082 }
00083
00084 BundlePointer
00085 VolatileBundleStore::getPointer( const ByteString& sender,
00086 uint32_t seqNum )
00087 {
00088 clean();
00089 return p_getPointer(sender,seqNum);
00090 }
00091
00092 bool
00093 VolatileBundleStore::validatePointer( const BundlePointer& p )
00094 {
00095 clean();
00096 return p_validatePointer(p);
00097 }
00098
00099 size_t
00100 VolatileBundleStore::bytesUsed( bool cleanup )
00101 {
00102 if ( cleanup ) clean();
00103 return p_bytesUsed();
00104 }
00105
00106 size_t
00107 VolatileBundleStore::bundles( bool cleanup )
00108 {
00109 if ( cleanup ) clean();
00110 return p_bundles();
00111 }
00112
00113 void
00114 VolatileBundleStore::shrinkStore( size_t s )
00115 {
00116 clean();
00117 p_shrinkStore(s);
00118 }