blob: 9f7af30b70b287b56a0f22783030c2eea9cbe5c0 [file] [log] [blame]
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -07003 * Copyright (c) 2011,2012 University of California, Los Angeles
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -07004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070018 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 * Ilya Moiseenko <iliamo@cs.ucla.edu>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080020 *
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -070021 */
22
Alexander Afanasyev0c395372014-12-20 15:54:02 -080023#include "ndn-content-store.hpp"
24
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -070025#include "ns3/log.h"
Alexander Afanasyev070aa482011-08-20 00:38:25 -070026#include "ns3/packet.h"
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -070027
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080028NS_LOG_COMPONENT_DEFINE("ndn.cs.ContentStore");
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -070029
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070030namespace ns3 {
31namespace ndn {
Alexander Afanasyev070aa482011-08-20 00:38:25 -070032
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080033NS_OBJECT_ENSURE_REGISTERED(ContentStore);
Alexander Afanasyev070aa482011-08-20 00:38:25 -070034
Alexander Afanasyevb989b122013-07-10 17:15:46 -070035TypeId
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080036ContentStore::GetTypeId(void)
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070037{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080038 static TypeId tid =
39 TypeId("ns3::ndn::ContentStore")
40 .SetGroupName("Ndn")
41 .SetParent<Object>()
Alexander Afanasyev39485d82012-06-08 17:51:47 -070042
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080043 .AddTraceSource("CacheHits", "Trace called every time there is a cache hit",
44 MakeTraceSourceAccessor(&ContentStore::m_cacheHitsTrace))
Alexander Afanasyevf034cbd2012-06-29 14:28:31 -070045
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080046 .AddTraceSource("CacheMisses", "Trace called every time there is a cache miss",
47 MakeTraceSourceAccessor(&ContentStore::m_cacheMissesTrace));
Alexander Afanasyev070aa482011-08-20 00:38:25 -070048
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070049 return tid;
50}
Alexander Afanasyev070aa482011-08-20 00:38:25 -070051
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080052ContentStore::~ContentStore()
Alexander Afanasyevfccdb9e2011-08-22 19:27:14 -070053{
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070054}
Alexander Afanasyevfccdb9e2011-08-22 19:27:14 -070055
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070056namespace cs {
57
Alexander Afanasyevfccdb9e2011-08-22 19:27:14 -070058//////////////////////////////////////////////////////////////////////
59
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070060Entry::Entry(Ptr<ContentStore> cs, shared_ptr<const Data> data)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061 : m_cs(cs)
62 , m_data(data)
Alexander Afanasyev070aa482011-08-20 00:38:25 -070063{
Alexander Afanasyev070aa482011-08-20 00:38:25 -070064}
65
Alexander Afanasyevcfdc14f2013-03-15 14:38:44 -070066const Name&
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080067Entry::GetName() const
Ilya Moiseenko1c570bc2011-08-17 19:18:02 -070068{
Spyridon Mastorakis1f1cd5e2014-12-04 11:12:40 -080069 return m_data->getName();
Alexander Afanasyev070aa482011-08-20 00:38:25 -070070}
71
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070072shared_ptr<const Data>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080073Entry::GetData() const
Alexander Afanasyev070aa482011-08-20 00:38:25 -070074{
Alexander Afanasyevb989b122013-07-10 17:15:46 -070075 return m_data;
Alexander Afanasyev070aa482011-08-20 00:38:25 -070076}
77
Alexander Afanasyev0e4ae8e2013-03-12 15:59:18 -070078Ptr<ContentStore>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080079Entry::GetContentStore()
Alexander Afanasyev0e4ae8e2013-03-12 15:59:18 -070080{
81 return m_cs;
82}
83
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070084} // namespace cs
85} // namespace ndn
Alexander Afanasyev070aa482011-08-20 00:38:25 -070086} // namespace ns3