blob: 8702c3afdf01a74454ed7d78df24e431fdabd539 [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
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080011#include "../common.hpp"
Yingdi Yu7640cb32014-01-29 20:00:50 -080012#include "certificate-cache.hpp"
13#include "../util/scheduler.hpp"
14#include "../util/time.hpp"
15
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080016namespace ndn {
Yingdi Yu7640cb32014-01-29 20:00:50 -080017
18class CertificateCacheTtl : public CertificateCache
19{
20public:
21 CertificateCacheTtl(shared_ptr<boost::asio::io_service> io, int defaultTtl = 3600);
22
23 virtual
24 ~CertificateCacheTtl();
25
26 virtual void
27 insertCertificate(ptr_lib::shared_ptr<const IdentityCertificate> certificate);
28
29 virtual ptr_lib::shared_ptr<const IdentityCertificate>
30 getCertificate(const Name & certificateNameWithoutVersion);
31
32private:
33 void
34 insert(ptr_lib::shared_ptr<const IdentityCertificate> certificate);
35
36 void
37 remove(const Name &certificateName);
38
39protected:
40 typedef std::map<Name, ptr_lib::shared_ptr<const IdentityCertificate> > Cache;
41 typedef std::map<Name, EventId> EventTracker;
42
43 int m_defaultTtl;
44 Cache m_cache;
45 EventTracker m_tracker;
46 Scheduler m_scheduler;
47};
48
49}//ndn
50
51#endif