NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ndn-content-store.cc
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011,2012 University of California, Los Angeles
4  *
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  *
18  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19  * Ilya Moiseenko <iliamo@cs.ucla.edu>
20  *
21  */
22 
23 #include "ndn-content-store.h"
24 #include "ns3/log.h"
25 #include "ns3/packet.h"
26 #include "ns3/ndn-name.h"
27 #include "ns3/ndn-interest.h"
28 #include "ns3/ndn-data.h"
29 
30 NS_LOG_COMPONENT_DEFINE ("ndn.cs.ContentStore");
31 
32 namespace ns3 {
33 namespace ndn {
34 
35 NS_OBJECT_ENSURE_REGISTERED (ContentStore);
36 
37 TypeId
39 {
40  static TypeId tid = TypeId ("ns3::ndn::ContentStore")
41  .SetGroupName ("Ndn")
42  .SetParent<Object> ()
43 
44  .AddTraceSource ("CacheHits", "Trace called every time there is a cache hit",
45  MakeTraceSourceAccessor (&ContentStore::m_cacheHitsTrace))
46 
47  .AddTraceSource ("CacheMisses", "Trace called every time there is a cache miss",
48  MakeTraceSourceAccessor (&ContentStore::m_cacheMissesTrace))
49  ;
50 
51  return tid;
52 }
53 
54 
56 {
57 }
58 
59 namespace cs {
60 
62 
63 Entry::Entry (Ptr<ContentStore> cs, Ptr<const Data> data)
64  : m_cs (cs)
65  , m_data (data)
66 {
67 }
68 
69 const Name&
71 {
72  return m_data->GetName ();
73 }
74 
75 Ptr<const Data>
77 {
78  return m_data;
79 }
80 
81 Ptr<ContentStore>
83 {
84  return m_cs;
85 }
86 
87 
88 } // namespace cs
89 } // namespace ndn
90 } // namespace ns3
const Name & GetName() const
Get prefix of the stored entry.
Class for NDN Name.
Definition: name.h:29
TracedCallback< Ptr< const Interest >, Ptr< const Data > > m_cacheHitsTrace
trace of cache hits
virtual ~ContentStore()
Virtual destructor.
TracedCallback< Ptr< const Interest > > m_cacheMissesTrace
trace of cache misses
static TypeId GetTypeId()
Interface ID.
Ptr< const Data > GetData() const
Get Data of the stored entry.
Ptr< ContentStore > GetContentStore()
Get pointer to access store, to which this entry is added.
Entry(Ptr< ContentStore > cs, Ptr< const Data > data)
Construct content store entry.