blob: 02ce59cdaac120fa138467c79d075fe26ac89d83 [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
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070037 * \brief A pool for Ndn faces
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080038 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070039 * Provides tools to perform basic manipulation on faces, such as
40 * setting metrics and states on faces
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070041 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070042 * \see NdnStackHelper
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 Afanasyev2b4c9472012-08-09 15:00:38 -070049 typedef Container::const_iterator Iterator; ///< \brief Iterator over FaceContainer
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070050
51 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -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 Afanasyev2b4c9472012-08-09 15:00:38 -070057 * \brief Copy constructor for FaceContainer. Calls AddAll method
Alexander Afanasyev7112f482011-08-17 14:05:57 -070058 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -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 Afanasyev2b4c9472012-08-09 15:00:38 -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 Afanasyev2b4c9472012-08-09 15:00:38 -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 /**
74 * \brief Add all entries from other container
75 *
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070076 * \param other smart pointer to a container
77 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080078 void
79 AddAll(Ptr<FaceContainer> other);
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070080
81 /**
82 * \brief Add all entries from other container
83 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070084 * \param other container
85 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080086 void
87 AddAll(const FaceContainer& other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070088
89 /**
90 * \brief Get an iterator which refers to the first pair in the
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070091 * container.
92 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070093 * \returns an iterator which refers to the first pair in the container.
94 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080095 Iterator
96 Begin() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070097
98 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080099 * \brief Get an iterator which indicates past-the-last Node in the
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700100 * container.
101 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700102 * \returns an iterator which indicates an ending condition for a loop.
103 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800104 Iterator
105 End() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700106
107 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700108 * \brief Get the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700109 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700110 * \returns the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700111 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800112 uint32_t
113 GetN() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700114
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700115 // /**
116 // * \brief Set a metric for all faces in the container
117 // *
118 // * \param metric value of metric to assign to all faces in the container
119 // */
120 // void SetMetricToAll (uint16_t metric);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700121
122 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700123 * Add an entry to the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700124 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700125 * \param face a smart pointer to a Face-derived object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700126 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700127 * @see Face
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700128 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800129 void
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -0700130 Add(const shared_ptr<Face>& face);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700131
132 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700133 * Get a smart pointer to Face-derived object stored in the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700134 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700135 * \param i the iterator corresponding to the requested object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700136 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700137 * This method is redundant and simple dereferencing of the iterator should be used instead
138 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700139 * @see Face
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700140 */
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -0700141 shared_ptr<Face>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800142 Get(Iterator i) const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700143
144private:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700145 Container m_faces;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700146};
147
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700148} // namespace ndn
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700149} // namespace ns3
150
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700151#endif /* NDN_FACE_CONTAINER_H */