blob: 1c37be70c3212a67293ae7347ec6497a98f45fb5 [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyev7112f482011-08-17 14:05:57 -07004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyev7112f482011-08-17 14:05:57 -07007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Alexander Afanasyev7112f482011-08-17 14:05:57 -070011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyev7112f482011-08-17 14:05:57 -070015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070019
Alexander Afanasyev0c395372014-12-20 15:54:02 -080020#include "ndn-face-container.hpp"
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070021
Alexander Afanasyev7112f482011-08-17 14:05:57 -070022#include <algorithm>
23
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070024namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070025namespace ndn {
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070026
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080027FaceContainer::FaceContainer()
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070028{
29}
30
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080031FaceContainer::FaceContainer(const FaceContainer& other)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070032{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080033 AddAll(other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070034}
35
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070036FaceContainer&
37FaceContainer::operator= (const FaceContainer &other)
Alexander Afanasyev7112f482011-08-17 14:05:57 -070038{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080039 m_faces.clear();
40 AddAll(other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070041
42 return *this;
43}
44
Alexander Afanasyev7112f482011-08-17 14:05:57 -070045void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080046FaceContainer::AddAll(Ptr<FaceContainer> other)
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070047{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080048 AddAll(*other);
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070049}
50
51void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080052FaceContainer::AddAll(const FaceContainer& other)
Alexander Afanasyev7112f482011-08-17 14:05:57 -070053{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080054 m_faces.insert(m_faces.end(), other.m_faces.begin(), other.m_faces.end());
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070055}
56
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070057FaceContainer::Iterator
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080058FaceContainer::Begin(void) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070059{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080060 return m_faces.begin();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070061}
62
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070063FaceContainer::Iterator
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080064FaceContainer::End(void) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070065{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066 return m_faces.end();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070067}
68
69uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080070FaceContainer::GetN(void) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070071{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080072 return m_faces.size();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070073}
74
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080075// void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070076// FaceContainer::SetMetricToAll (uint16_t metric)
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070077// {
78// for (FaceContainer::iterator it=m_faces.begin ();
79// it != m_faces.end ();
80// it++)
81// {
82// (*it)->SetMetric (metric);
83// }
84// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070085
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080086void
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070087FaceContainer::Add(const shared_ptr<Face>& face)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070088{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080089 m_faces.push_back(face);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070090}
91
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070092shared_ptr<Face>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080093FaceContainer::Get(FaceContainer::Iterator i) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070094{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070095 return *i;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070096}
97
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070098} // namespace ndn
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070099} // namespace ns3