blob: 02a13cbd12091c1c4d621d91241de1d7abf81a6d [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",
41 MakeTraceSourceAccessor(&ContentStore::m_cacheHitsTrace))
Alexander Afanasyevf034cbd2012-06-29 14:28:31 -070042
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080043 .AddTraceSource("CacheMisses", "Trace called every time there is a cache miss",
44 MakeTraceSourceAccessor(&ContentStore::m_cacheMissesTrace));
Alexander Afanasyev070aa482011-08-20 00:38:25 -070045
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070046 return tid;
47}
Alexander Afanasyev070aa482011-08-20 00:38:25 -070048
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080049ContentStore::~ContentStore()
Alexander Afanasyevfccdb9e2011-08-22 19:27:14 -070050{
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070051}
Alexander Afanasyevfccdb9e2011-08-22 19:27:14 -070052
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070053namespace cs {
54
Alexander Afanasyevfccdb9e2011-08-22 19:27:14 -070055//////////////////////////////////////////////////////////////////////
56
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070057Entry::Entry(Ptr<ContentStore> cs, shared_ptr<const Data> data)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080058 : m_cs(cs)
59 , m_data(data)
Alexander Afanasyev070aa482011-08-20 00:38:25 -070060{
Alexander Afanasyev070aa482011-08-20 00:38:25 -070061}
62
Alexander Afanasyevcfdc14f2013-03-15 14:38:44 -070063const Name&
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080064Entry::GetName() const
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -070065{
Spyridon Mastorakis1f1cd5e2014-12-04 11:12:40 -080066 return m_data->getName();
Alexander Afanasyev070aa482011-08-20 00:38:25 -070067}
68
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070069shared_ptr<const Data>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080070Entry::GetData() const
Alexander Afanasyev070aa482011-08-20 00:38:25 -070071{
Alexander Afanasyevb989b122013-07-10 17:15:46 -070072 return m_data;
Alexander Afanasyev070aa482011-08-20 00:38:25 -070073}
74
Alexander Afanasyev0e4ae8e2013-03-12 15:59:18 -070075Ptr<ContentStore>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080076Entry::GetContentStore()
Alexander Afanasyev0e4ae8e2013-03-12 15:59:18 -070077{
78 return m_cs;
79}
80
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070081} // namespace cs
82} // namespace ndn
Alexander Afanasyev070aa482011-08-20 00:38:25 -070083} // namespace ns3