Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * File: ndn_rit.h |
| 3 | * Author: cawka |
| 4 | * |
| 5 | * Created on December 15, 2010, 2:02 PM |
| 6 | */ |
| 7 | |
| 8 | #ifndef NDN_RIT_H |
| 9 | #define NDN_RIT_H |
| 10 | |
| 11 | #include "hash_helper.h" |
| 12 | #include <qualnet_mutex.h> |
| 13 | #include <clock.h> |
| 14 | #include <list> |
| 15 | using namespace std; |
| 16 | |
| 17 | //recent interest |
| 18 | struct RitEntry |
| 19 | { |
| 20 | int nonce; |
| 21 | clocktype expireTime; //RIT entries will stay in the table for a while before being cleaned out |
| 22 | }; |
| 23 | |
| 24 | typedef int_key_hash_t<RitEntry>::point_iterator RitIterator; |
| 25 | typedef int_key_hash_t<RitEntry>::iterator RitRangeIterator; |
| 26 | |
| 27 | class NdnRit |
| 28 | { |
| 29 | public: |
| 30 | NdnRit( ); |
| 31 | virtual ~NdnRit( ); |
| 32 | |
| 33 | //Find corresponding RIT entry for the given content name |
| 34 | RitIterator lookup( int nonce ); |
| 35 | bool isValid( const RitIterator &it ) { return it!=_rit.end(); } |
| 36 | |
| 37 | //add new RIT entry |
| 38 | bool add( int nonce, clocktype expireTime ); |
| 39 | |
| 40 | // Delete expired records |
| 41 | void cleanExpired( clocktype time ); |
| 42 | |
| 43 | private: |
| 44 | int_key_hash_t<RitEntry> _rit; |
| 45 | |
| 46 | list<RitEntry*> _ritExpirationList; |
| 47 | |
| 48 | QNThreadMutex _ritMutex; |
| 49 | }; |
| 50 | |
| 51 | #endif /* NdnRit_H */ |
| 52 | |