blob: e55cc2a4c668df83789ba864855383b2f8217987 [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 Afanasyev4aac5572012-08-09 10:49:55 -070020#ifndef NDN_FACE_CONTAINER_H
21#define NDN_FACE_CONTAINER_H
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070022
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070023#include "ns3/ndnSIM/model/ndn-common.hpp"
24
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070025#include <stdint.h>
26#include <vector>
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070027
28#include "ns3/ptr.h"
29#include "ns3/simple-ref-count.h"
Spyridon Mastorakis9760bd02014-11-12 13:32:55 -080030#include "ns3/ndnSIM/model/ndn-face.hpp"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070031
32namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070033namespace ndn {
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070034
35/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070036 * @ingroup ndn-helpers
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080037 * @brief A pool for Ndn faces
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080038 *
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080039 * Provides tools to perform basic manipulation on faces, such as setting metrics and
40 * states on faces
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070041 *
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080042 * @see ndn::StackHelper
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070043 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080044class FaceContainer : public SimpleRefCount<FaceContainer> {
Alexander Afanasyev7112f482011-08-17 14:05:57 -070045private:
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070046 typedef std::vector<shared_ptr<Face>> Container;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080047
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070048public:
Alexander Afanasyev241df872015-08-13 17:26:15 -070049 typedef Container::const_iterator Iterator; ///< @brief Iterator over FaceContainer
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070050
51 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -070052 * @brief Create an empty FaceContainer.
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070053 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080054 FaceContainer();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070055
56 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -070057 * @brief Copy constructor for FaceContainer. Calls AddAll method
Alexander Afanasyev7112f482011-08-17 14:05:57 -070058 *
Alexander Afanasyev241df872015-08-13 17:26:15 -070059 * @see FaceContainer::AddAll
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070060 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061 FaceContainer(const FaceContainer& other);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070062
63 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -070064 * @brief Copy operator for FaceContainer. Empties vector and calls AddAll method
Alexander Afanasyev7112f482011-08-17 14:05:57 -070065 *
66 * All previously obtained iterators (Begin() and End()) will be invalidated
67 *
Alexander Afanasyev241df872015-08-13 17:26:15 -070068 * @see FaceContainer::AddAll
Alexander Afanasyev7112f482011-08-17 14:05:57 -070069 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080070 FaceContainer&
71 operator=(const FaceContainer& other);
72
Alexander Afanasyev7112f482011-08-17 14:05:57 -070073 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -070074 * Add an entry to the container
Alexander Afanasyev7112f482011-08-17 14:05:57 -070075 *
Alexander Afanasyev241df872015-08-13 17:26:15 -070076 * @param face a smart pointer to a Face-derived object
77 */
78 void
79 Add(shared_ptr<Face> face);
80
81 /**
82 * @brief Add all entries from other container
83 *
84 * @param other smart pointer to a container
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070085 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080086 void
87 AddAll(Ptr<FaceContainer> other);
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070088
89 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -070090 * @brief Add all entries from other container
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070091 *
Alexander Afanasyev241df872015-08-13 17:26:15 -070092 * @param other container
Alexander Afanasyev7112f482011-08-17 14:05:57 -070093 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080094 void
95 AddAll(const FaceContainer& other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070096
Alexander Afanasyev241df872015-08-13 17:26:15 -070097public: // accessors
Alexander Afanasyev7112f482011-08-17 14:05:57 -070098 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -070099 * @brief Get an iterator which refers to the first pair in the
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700100 * container.
101 *
Alexander Afanasyev241df872015-08-13 17:26:15 -0700102 * @returns an iterator which refers to the first pair in the container.
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700103 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800104 Iterator
105 Begin() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700106
107 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -0700108 * @brief Get an iterator which indicates past-the-last Node in the
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700109 * container.
110 *
Alexander Afanasyev241df872015-08-13 17:26:15 -0700111 * @returns an iterator which indicates an ending condition for a loop.
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700112 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800113 Iterator
114 End() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700115
116 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -0700117 * @brief Get the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700118 *
Alexander Afanasyev241df872015-08-13 17:26:15 -0700119 * @returns the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700120 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800121 uint32_t
122 GetN() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700123
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700124 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -0700125 * Get a Face stored in the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700126 *
Alexander Afanasyev241df872015-08-13 17:26:15 -0700127 * @param pos index of the Face in the container
128 * @throw std::out_of_range if !(pos < GetN()).
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700129 */
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -0700130 shared_ptr<Face>
Alexander Afanasyev241df872015-08-13 17:26:15 -0700131 Get(size_t pos) const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700132
133private:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700134 Container m_faces;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700135};
136
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700137} // namespace ndn
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700138} // namespace ns3
139
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700140#endif /* NDN_FACE_CONTAINER_H */