Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | |
| 3 | #include "ccnx-face-container.h" |
| 4 | #include "ns3/node-list.h" |
| 5 | #include "ns3/names.h" |
| 6 | |
| 7 | namespace ns3 { |
| 8 | |
| 9 | CcnxFaceContainer::CcnxFaceContainer () |
| 10 | { |
| 11 | } |
| 12 | |
| 13 | void |
| 14 | CcnxFaceContainer::Add (CcnxFaceContainer other) |
| 15 | { |
| 16 | for (FaceVector::const_iterator i = other.m_faces.begin (); i != other.m_faces.end (); i++) |
| 17 | { |
| 18 | m_faces.push_back (*i); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | CcnxFaceContainer::Iterator |
| 23 | CcnxFaceContainer::Begin (void) const |
| 24 | { |
| 25 | return m_faces.begin (); |
| 26 | } |
| 27 | |
| 28 | CcnxFaceContainer::Iterator |
| 29 | CcnxFaceContainer::End (void) const |
| 30 | { |
| 31 | return m_faces.end (); |
| 32 | } |
| 33 | |
| 34 | uint32_t |
| 35 | CcnxFaceContainer::GetN (void) const |
| 36 | { |
| 37 | return m_faces.size (); |
| 38 | } |
| 39 | |
| 40 | // CcnxAddress |
| 41 | // CcnxFaceContainer::GetAddress (uint32_t i, uint32_t j) const |
| 42 | // { |
| 43 | // Ptr<Ccnx> ccnx = m_faces[i].first; |
| 44 | // uint32_t face = m_faces[i].second; |
| 45 | // return ccnx->GetAddress (face, j).GetLocal (); |
| 46 | // } |
| 47 | |
| 48 | void |
| 49 | CcnxFaceContainer::SetMetric (uint32_t i, uint16_t metric) |
| 50 | { |
| 51 | Ptr<Ccnx> ccnx = m_faces[i].first; |
| 52 | uint32_t face = m_faces[i].second; |
| 53 | ccnx->SetMetric (face, metric); |
| 54 | } |
| 55 | |
| 56 | void |
| 57 | CcnxFaceContainer::Add (Ptr<Ccnx> ccnx, uint32_t face) |
| 58 | { |
| 59 | m_faces.push_back (std::make_pair (ccnx, face)); |
| 60 | } |
| 61 | |
| 62 | void CcnxFaceContainer::Add (std::pair<Ptr<Ccnx>, uint32_t> a) |
| 63 | { |
| 64 | Add (a.first, a.second); |
| 65 | } |
| 66 | |
| 67 | void |
| 68 | CcnxFaceContainer::Add (std::string ccnxName, uint32_t face) |
| 69 | { |
| 70 | Ptr<Ccnx> ccnx = Names::Find<Ccnx> (ccnxName); |
| 71 | m_faces.push_back (std::make_pair (ccnx, face)); |
| 72 | } |
| 73 | |
| 74 | std::pair<Ptr<Ccnx>, uint32_t> |
| 75 | CcnxFaceContainer::Get (uint32_t i) const |
| 76 | { |
| 77 | return m_faces[i]; |
| 78 | } |
| 79 | |
| 80 | |
| 81 | } // namespace ns3 |