OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari |
| 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: Giuseppe Piro <g.piro@poliba.it> |
| 19 */ |
| 20 |
| 21 #include <stdint.h> |
| 22 #include "ue-manager.h" |
| 23 #include "ns3/log.h" |
| 24 #include "ue-net-device.h" |
| 25 #include "enb-net-device.h" |
| 26 |
| 27 NS_LOG_COMPONENT_DEFINE ("UeManager"); |
| 28 |
| 29 namespace ns3 { |
| 30 NS_OBJECT_ENSURE_REGISTERED ( UeManager); |
| 31 |
| 32 UeManager::UeManager (void) |
| 33 { |
| 34 NS_LOG_FUNCTION (this); |
| 35 m_ueRecords = new std::vector<Ptr<UeRecord> > (); |
| 36 } |
| 37 |
| 38 |
| 39 UeManager::~UeManager (void) |
| 40 { |
| 41 m_ueRecords = 0; |
| 42 } |
| 43 |
| 44 |
| 45 void |
| 46 UeManager::CreateUeRecord (Ptr<UeNetDevice> ue, Ptr<EnbNetDevice> enb) |
| 47 { |
| 48 NS_LOG_FUNCTION (this); |
| 49 UeRecord *ueRecord = new UeRecord (ue, enb); |
| 50 m_ueRecords->push_back (ueRecord); |
| 51 } |
| 52 |
| 53 |
| 54 Ptr<UeRecord> |
| 55 UeManager::GetUeRecord (Ptr<UeNetDevice> ue)· |
| 56 { |
| 57 NS_LOG_FUNCTION (this); |
| 58 for (std::vector<Ptr<UeRecord> >::iterator iter = m_ueRecords->begin (); iter
!= m_ueRecords->end (); ++iter) |
| 59 { |
| 60 ······ |
| 61 if ((*iter)->GetUe ()->GetAddress () == ue->GetAddress ()) |
| 62 { |
| 63 return *iter; |
| 64 } |
| 65 } |
| 66 |
| 67 NS_LOG_DEBUG ("GetUeRecord: UeRecord not found!"); |
| 68 return 0; |
| 69 } |
| 70 |
| 71 |
| 72 Ptr<UeRecord> |
| 73 UeManager::GetUeRecord (const Mac48Address macAddress)· |
| 74 { |
| 75 NS_LOG_FUNCTION (this); |
| 76 |
| 77 for (std::vector<Ptr<UeRecord> >::iterator iter = m_ueRecords->begin (); iter
!= m_ueRecords->end (); ++iter) |
| 78 { |
| 79 |
| 80 NS_LOG_LOGIC ("find " << macAddress << ", here:" << (*iter)->GetUe ()->Ge
tAddress ()); |
| 81 |
| 82 if ((*iter)->GetUe ()->GetAddress () == macAddress) |
| 83 { |
| 84 return *iter; |
| 85 } |
| 86 } |
| 87 NS_LOG_DEBUG ("GetUeRecord: UeRecord not found!"); |
| 88 · |
| 89 return 0; |
| 90 } |
| 91 |
| 92 |
| 93 bool |
| 94 UeManager::IsRegistered (Ptr<UeNetDevice> ue) const |
| 95 { |
| 96 NS_LOG_FUNCTION (this); |
| 97 for (std::vector<Ptr<UeRecord> >::iterator iter = m_ueRecords->begin (); iter
!= m_ueRecords->end (); ++iter) |
| 98 { |
| 99 if ((*iter)->GetUe ()->GetAddress () == ue->GetAddress ()) |
| 100 { |
| 101 return true; |
| 102 } |
| 103 } |
| 104 return false; |
| 105 } |
| 106 |
| 107 |
| 108 bool |
| 109 UeManager::IsRegistered (const Mac48Address &macAddress) const |
| 110 { |
| 111 NS_LOG_FUNCTION (this); |
| 112 /* |
| 113 for (std::vector<UeRecord*>::iterator iter = m_ueRecords->begin (); iter != m_
ueRecords->end (); ++iter) |
| 114 { |
| 115 if ((*iter)->GetUe ()->GetAddress () == macAddress) |
| 116 { |
| 117 return true; |
| 118 } |
| 119 } |
| 120 */·· |
| 121 return false; |
| 122 } |
| 123 |
| 124 |
| 125 void |
| 126 UeManager::DeleteUeRecord (Ptr<UeNetDevice> ue) |
| 127 { |
| 128 NS_LOG_FUNCTION (this); |
| 129 for (std::vector<Ptr<UeRecord> >::iterator iter = m_ueRecords->begin (); iter
!= m_ueRecords->end (); ++iter) |
| 130 { |
| 131 if ((*iter)->GetUe ()->GetAddress () == ue->GetAddress ()) |
| 132 { |
| 133 m_ueRecords->erase (iter); |
| 134 return; |
| 135 } |
| 136 } |
| 137 } |
| 138 |
| 139 |
| 140 void |
| 141 UeManager::DeleteUeRecord (const Mac48Address &macAddress) |
| 142 { |
| 143 NS_LOG_FUNCTION (this); |
| 144 /* |
| 145 for (std::vector<UeRecord*>::iterator iter = m_ueRecords->begin (); iter != m_
ueRecords->end (); ++iter) |
| 146 { |
| 147 if ((*iter)->GetUe ()->GetAddress () == macAddress) |
| 148 { |
| 149 m_ueRecords->erase (iter); |
| 150 return; |
| 151 } |
| 152 } |
| 153 */ |
| 154 } |
| 155 |
| 156 |
| 157 std::vector<Ptr<UeRecord> >*· |
| 158 UeManager::GetUeRecords (void) |
| 159 { |
| 160 NS_LOG_FUNCTION (this); |
| 161 return m_ueRecords; |
| 162 } |
| 163 |
| 164 |
| 165 uint32_t· |
| 166 UeManager::GetNRegisteredUes (void) const |
| 167 { |
| 168 NS_LOG_FUNCTION (this); |
| 169 return m_ueRecords->size(); |
| 170 } |
| 171 |
| 172 } // namespace ns3 |
| 173 |
| 174 |
OLD | NEW |