blob: fc90ad6a59d6c43ded75540227fd5785d15752a5 [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 Afanasyev4aac5572012-08-09 10:49:55 -070021#ifndef NDN_FACE_CONTAINER_H
22#define NDN_FACE_CONTAINER_H
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070023
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070024#include "ns3/ndnSIM/model/ndn-common.hpp"
25
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070026#include <stdint.h>
27#include <vector>
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070028
29#include "ns3/ptr.h"
30#include "ns3/simple-ref-count.h"
Alexander Afanasyev0c395372014-12-20 15:54:02 -080031#include "ns3/ndn-face.hpp"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070032
33namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070034namespace ndn {
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070035
36/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070037 * @ingroup ndn-helpers
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070038 * \brief A pool for Ndn faces
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080039 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070040 * Provides tools to perform basic manipulation on faces, such as
41 * setting metrics and states on faces
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070042 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070043 * \see NdnStackHelper
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070044 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080045class FaceContainer : public SimpleRefCount<FaceContainer> {
Alexander Afanasyev7112f482011-08-17 14:05:57 -070046private:
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070047 typedef std::vector<shared_ptr<Face>> Container;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080048
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070049public:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070050 typedef Container::const_iterator Iterator; ///< \brief Iterator over FaceContainer
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070051
52 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070053 * \brief Create an empty FaceContainer.
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070054 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055 FaceContainer();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070056
57 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070058 * \brief Copy constructor for FaceContainer. Calls AddAll method
Alexander Afanasyev7112f482011-08-17 14:05:57 -070059 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070060 * \see FaceContainer::AddAll
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070061 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080062 FaceContainer(const FaceContainer& other);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070063
64 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070065 * \brief Copy operator for FaceContainer. Empties vector and calls AddAll method
Alexander Afanasyev7112f482011-08-17 14:05:57 -070066 *
67 * All previously obtained iterators (Begin() and End()) will be invalidated
68 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070069 * \see FaceContainer::AddAll
Alexander Afanasyev7112f482011-08-17 14:05:57 -070070 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080071 FaceContainer&
72 operator=(const FaceContainer& other);
73
Alexander Afanasyev7112f482011-08-17 14:05:57 -070074 /**
75 * \brief Add all entries from other container
76 *
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070077 * \param other smart pointer to a container
78 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080079 void
80 AddAll(Ptr<FaceContainer> other);
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070081
82 /**
83 * \brief Add all entries from other container
84 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070085 * \param other container
86 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080087 void
88 AddAll(const FaceContainer& other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070089
90 /**
91 * \brief Get an iterator which refers to the first pair in the
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070092 * container.
93 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070094 * \returns an iterator which refers to the first pair in the container.
95 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080096 Iterator
97 Begin() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070098
99 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800100 * \brief Get an iterator which indicates past-the-last Node in the
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700101 * container.
102 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700103 * \returns an iterator which indicates an ending condition for a loop.
104 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800105 Iterator
106 End() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700107
108 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700109 * \brief Get the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700110 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700111 * \returns the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700112 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800113 uint32_t
114 GetN() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700115
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700116 // /**
117 // * \brief Set a metric for all faces in the container
118 // *
119 // * \param metric value of metric to assign to all faces in the container
120 // */
121 // void SetMetricToAll (uint16_t metric);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700122
123 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700124 * Add an entry to the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700125 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700126 * \param face a smart pointer to a Face-derived object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700127 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700128 * @see Face
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700129 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800130 void
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -0700131 Add(const shared_ptr<Face>& face);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700132
133 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700134 * Get a smart pointer to Face-derived object stored in the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700135 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700136 * \param i the iterator corresponding to the requested object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700137 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700138 * This method is redundant and simple dereferencing of the iterator should be used instead
139 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700140 * @see Face
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700141 */
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -0700142 shared_ptr<Face>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800143 Get(Iterator i) const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700144
145private:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700146 Container m_faces;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700147};
148
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700149} // namespace ndn
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700150} // namespace ns3
151
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700152#endif /* NDN_FACE_CONTAINER_H */