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-limits.cc
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2011 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  */
20 
21 #include "ndn-limits.h"
22 
23 #include "ns3/log.h"
24 #include "ns3/simulator.h"
25 #include "ns3/random-variable.h"
26 
27 NS_LOG_COMPONENT_DEFINE ("ndn.Limits");
28 
29 namespace ns3 {
30 namespace ndn {
31 
32 TypeId
33 Limits::GetTypeId ()
34 {
35  static TypeId tid = TypeId ("ns3::ndn::Limits")
36  .SetGroupName ("Ndn")
37  .SetParent <Object> ()
38 
39  ;
40  return tid;
41 }
42 
44  : m_maxRate (-1)
45  , m_maxDelay (1.0)
46  , m_handler (MakeNullCallback<void> ())
47  , m_linkDelay (0)
48 {
49 }
50 
51 
52 void
53 Limits::RegisterAvailableSlotCallback (CallbackHandler handler)
54 {
55  m_handler = handler;
56 }
57 
58 void
59 Limits::FireAvailableSlotCallback ()
60 {
61  if (!m_handler.IsNull ())
62  m_handler ();
63 }
64 
65 
66 } // namespace ndn
67 } // namespace ns3
Limits()
Default constructor.
Definition: ndn-limits.cc:43
void RegisterAvailableSlotCallback(CallbackHandler handler)
Set callback which will be called when exhausted limit gets a new slot.
Definition: ndn-limits.cc:53