blob: 4a03bdaa2a68d9b3a0246534ffc1ba9d369ad67d [file] [log] [blame]
Alexander Afanasyevc74a6022011-08-15 20:01:35 -07001/*
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>
15using namespace std;
16
17//recent interest
18struct RitEntry
19{
20 int nonce;
21 clocktype expireTime; //RIT entries will stay in the table for a while before being cleaned out
22};
23
24typedef int_key_hash_t<RitEntry>::point_iterator RitIterator;
25typedef int_key_hash_t<RitEntry>::iterator RitRangeIterator;
26
27class NdnRit
28{
29public:
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
43private:
44 int_key_hash_t<RitEntry> _rit;
45
46 list<RitEntry*> _ritExpirationList;
47
48 QNThreadMutex _ritMutex;
49};
50
51#endif /* NdnRit_H */
52