blob: 150eea3c0f0751388d30cbb0108a74707e42d564 [file] [log] [blame]
Alexander Afanasyev7112f482011-08-17 14:05:57 -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 */
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070020
Alexander Afanasyev0c395372014-12-20 15:54:02 -080021#include "ndn-face-container.hpp"
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070022
Alexander Afanasyev7112f482011-08-17 14:05:57 -070023#include <algorithm>
24
Alexander Afanasyev0c395372014-12-20 15:54:02 -080025#include "ns3/ndn-face.hpp"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070026
27namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070028namespace ndn {
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070029
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080030FaceContainer::FaceContainer()
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070031{
32}
33
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080034FaceContainer::FaceContainer(const FaceContainer& other)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070035{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080036 AddAll(other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070037}
38
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070039FaceContainer&
40FaceContainer::operator= (const FaceContainer &other)
Alexander Afanasyev7112f482011-08-17 14:05:57 -070041{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080042 m_faces.clear();
43 AddAll(other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070044
45 return *this;
46}
47
Alexander Afanasyev7112f482011-08-17 14:05:57 -070048void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080049FaceContainer::AddAll(Ptr<FaceContainer> other)
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070050{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080051 AddAll(*other);
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070052}
53
54void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055FaceContainer::AddAll(const FaceContainer& other)
Alexander Afanasyev7112f482011-08-17 14:05:57 -070056{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080057 m_faces.insert(m_faces.end(), other.m_faces.begin(), other.m_faces.end());
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070058}
59
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070060FaceContainer::Iterator
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061FaceContainer::Begin(void) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070062{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080063 return m_faces.begin();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070064}
65
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070066FaceContainer::Iterator
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080067FaceContainer::End(void) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070068{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080069 return m_faces.end();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070070}
71
72uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080073FaceContainer::GetN(void) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070074{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080075 return m_faces.size();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070076}
77
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080078// void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070079// FaceContainer::SetMetricToAll (uint16_t metric)
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070080// {
81// for (FaceContainer::iterator it=m_faces.begin ();
82// it != m_faces.end ();
83// it++)
84// {
85// (*it)->SetMetric (metric);
86// }
87// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070088
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080089void
90FaceContainer::Add(const Ptr<Face>& face)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070091{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080092 m_faces.push_back(face);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070093}
94
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070095Ptr<Face>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080096FaceContainer::Get(FaceContainer::Iterator i) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070097{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070098 return *i;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070099}
100
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700101} // namespace ndn
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700102} // namespace ns3