blob: 6d5194b83e968f637b01a28a72d3c9fb80f09649 [file] [log] [blame]
Yingdi Yu7640cb32014-01-29 20:00:50 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Yingdi Yu <yingdi@cs.ucla.edu>
5 * See COPYING for copyright and distribution information.
6 */
7
8#ifndef NDN_CERTIFICATE_CACHE_TTL_HPP
9#define NDN_CERTIFICATE_CACHE_TTL_HPP
10
11#include "certificate-cache.hpp"
12#include "../util/scheduler.hpp"
13#include "../util/time.hpp"
14
15#include <unistd.h>
16#include <map>
17
18namespace ndn
19{
20
21class CertificateCacheTtl : public CertificateCache
22{
23public:
24 CertificateCacheTtl(shared_ptr<boost::asio::io_service> io, int defaultTtl = 3600);
25
26 virtual
27 ~CertificateCacheTtl();
28
29 virtual void
30 insertCertificate(ptr_lib::shared_ptr<const IdentityCertificate> certificate);
31
32 virtual ptr_lib::shared_ptr<const IdentityCertificate>
33 getCertificate(const Name & certificateNameWithoutVersion);
34
35private:
36 void
37 insert(ptr_lib::shared_ptr<const IdentityCertificate> certificate);
38
39 void
40 remove(const Name &certificateName);
41
42protected:
43 typedef std::map<Name, ptr_lib::shared_ptr<const IdentityCertificate> > Cache;
44 typedef std::map<Name, EventId> EventTracker;
45
46 int m_defaultTtl;
47 Cache m_cache;
48 EventTracker m_tracker;
49 Scheduler m_scheduler;
50};
51
52}//ndn
53
54#endif