blob: 4e5f48fb40a1385b74a9604776f7597966f48eae [file] [log] [blame]
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -07001/* -*- 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"
Alexander Afanasyev6a3bb132012-08-15 09:47:35 -070025#include "ns3/random-variable.h"
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070026
27NS_LOG_COMPONENT_DEFINE ("ndn.Limits");
28
29namespace ns3 {
30namespace ndn {
31
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070032TypeId
33Limits::GetTypeId ()
34{
35 static TypeId tid = TypeId ("ns3::ndn::Limits")
36 .SetGroupName ("Ndn")
37 .SetParent <Object> ()
Alexander Afanasyev6a3bb132012-08-15 09:47:35 -070038
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070039 .AddTraceSource ("CurMaxLimit",
40 "Current maximum limit",
41 MakeTraceSourceAccessor (&Limits::m_curMaxLimit))
42
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070043 ;
44 return tid;
45}
46
47void
Alexander Afanasyeva28ec562012-10-25 14:07:32 -070048Limits::UpdateCurrentLimit (double limit)
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070049{
Alexander Afanasyeva28ec562012-10-25 14:07:32 -070050 NS_ASSERT_MSG (limit >= 0.0, "Limit should be greater or equal to zero");
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070051
Alexander Afanasyeva28ec562012-10-25 14:07:32 -070052 m_curMaxLimit = std::min (limit, m_maxLimit);
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070053}
54
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070055} // namespace ndn
56} // namespace ns3