blob: 416bde34429e9945a29eabdfce9a57ba3c0b2baf [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -07004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -07007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -070011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -070015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -070019
Alexander Afanasyev0c395372014-12-20 15:54:02 -080020#include "ndn-content-store.hpp"
21
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -070022#include "ns3/log.h"
Alexander Afanasyev070aa482011-08-20 00:38:25 -070023#include "ns3/packet.h"
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -070024
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080025NS_LOG_COMPONENT_DEFINE("ndn.cs.ContentStore");
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -070026
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070027namespace ns3 {
28namespace ndn {
Alexander Afanasyev070aa482011-08-20 00:38:25 -070029
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080030NS_OBJECT_ENSURE_REGISTERED(ContentStore);
Alexander Afanasyev070aa482011-08-20 00:38:25 -070031
Alexander Afanasyevb989b122013-07-10 17:15:46 -070032TypeId
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080033ContentStore::GetTypeId(void)
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070034{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080035 static TypeId tid =
36 TypeId("ns3::ndn::ContentStore")
37 .SetGroupName("Ndn")
38 .SetParent<Object>()
Alexander Afanasyev39485d82012-06-08 17:51:47 -070039
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080040 .AddTraceSource("CacheHits", "Trace called every time there is a cache hit",
Alexander Afanasyevd6453cd2015-08-20 21:45:36 -070041 MakeTraceSourceAccessor(&ContentStore::m_cacheHitsTrace),
42 "ns3::ndn::ContentStore::CacheHitsCallback")
Alexander Afanasyevf034cbd2012-06-29 14:28:31 -070043
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080044 .AddTraceSource("CacheMisses", "Trace called every time there is a cache miss",
Alexander Afanasyevd6453cd2015-08-20 21:45:36 -070045 MakeTraceSourceAccessor(&ContentStore::m_cacheMissesTrace),
46 "ns3::ndn::ContentStrore::CacheMissesCallback");
Alexander Afanasyev070aa482011-08-20 00:38:25 -070047
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070048 return tid;
49}
Alexander Afanasyev070aa482011-08-20 00:38:25 -070050
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080051ContentStore::~ContentStore()
Alexander Afanasyevfccdb9e2011-08-22 19:27:14 -070052{
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070053}
Alexander Afanasyevfccdb9e2011-08-22 19:27:14 -070054
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070055namespace cs {
56
Alexander Afanasyevfccdb9e2011-08-22 19:27:14 -070057//////////////////////////////////////////////////////////////////////
58
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070059Entry::Entry(Ptr<ContentStore> cs, shared_ptr<const Data> data)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080060 : m_cs(cs)
61 , m_data(data)
Alexander Afanasyev070aa482011-08-20 00:38:25 -070062{
Alexander Afanasyev070aa482011-08-20 00:38:25 -070063}
64
Alexander Afanasyevcfdc14f2013-03-15 14:38:44 -070065const Name&
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066Entry::GetName() const
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -070067{
Spyridon Mastorakis1f1cd5e2014-12-04 11:12:40 -080068 return m_data->getName();
Alexander Afanasyev070aa482011-08-20 00:38:25 -070069}
70
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070071shared_ptr<const Data>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080072Entry::GetData() const
Alexander Afanasyev070aa482011-08-20 00:38:25 -070073{
Alexander Afanasyevb989b122013-07-10 17:15:46 -070074 return m_data;
Alexander Afanasyev070aa482011-08-20 00:38:25 -070075}
76
Alexander Afanasyev0e4ae8e2013-03-12 15:59:18 -070077Ptr<ContentStore>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080078Entry::GetContentStore()
Alexander Afanasyev0e4ae8e2013-03-12 15:59:18 -070079{
80 return m_cs;
81}
82
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070083} // namespace cs
84} // namespace ndn
Alexander Afanasyev070aa482011-08-20 00:38:25 -070085} // namespace ns3