blob: 692daf6686adbec9afd8d5a62403f86cafd7b815 [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
24#include <stdint.h>
25#include <vector>
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070026
27#include "ns3/ptr.h"
28#include "ns3/simple-ref-count.h"
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070029#include "ns3/ndn-face.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070030
31namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070032namespace ndn {
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070033
34/**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070035 * \ingroup ndn-helpers
36 * \brief A pool for Ndn faces
Alexander Afanasyev7112f482011-08-17 14:05:57 -070037 *
38 * Provides tools to perform basic manipulation on faces, such as
39 * setting metrics and states on faces
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070040 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070041 * \see NdnStackHelper
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070042 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070043class FaceContainer : public SimpleRefCount<FaceContainer>
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070044{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070045private:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070046 typedef std::vector< Ptr<Face> > Container;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070047public:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070048 typedef Container::const_iterator Iterator; ///< \brief Iterator over FaceContainer
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070049
50 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070051 * \brief Create an empty FaceContainer.
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070052 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070053 FaceContainer ();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070054
55 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070056 * \brief Copy constructor for FaceContainer. Calls AddAll method
Alexander Afanasyev7112f482011-08-17 14:05:57 -070057 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070058 * \see FaceContainer::AddAll
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070059 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070060 FaceContainer (const FaceContainer &other);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070061
62 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070063 * \brief Copy operator for FaceContainer. Empties vector and calls AddAll method
Alexander Afanasyev7112f482011-08-17 14:05:57 -070064 *
65 * All previously obtained iterators (Begin() and End()) will be invalidated
66 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070067 * \see FaceContainer::AddAll
Alexander Afanasyev7112f482011-08-17 14:05:57 -070068 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070069 FaceContainer& operator= (const FaceContainer &other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070070
71 /**
72 * \brief Add all entries from other container
73 *
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070074 * \param other smart pointer to a container
75 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070076 void AddAll (Ptr<FaceContainer> other);
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070077
78 /**
79 * \brief Add all entries from other container
80 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070081 * \param other container
82 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070083 void AddAll (const FaceContainer &other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070084
85 /**
86 * \brief Get an iterator which refers to the first pair in the
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070087 * container.
88 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070089 * \returns an iterator which refers to the first pair in the container.
90 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -070091 Iterator Begin () const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070092
93 /**
94 * \brief Get an iterator which indicates past-the-last Node in the
95 * container.
96 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070097 * \returns an iterator which indicates an ending condition for a loop.
98 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -070099 Iterator End () const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700100
101 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700102 * \brief Get the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700103 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700104 * \returns the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700105 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700106 uint32_t GetN () const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700107
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700108 // /**
109 // * \brief Set a metric for all faces in the container
110 // *
111 // * \param metric value of metric to assign to all faces in the container
112 // */
113 // void SetMetricToAll (uint16_t metric);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700114
115 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700116 * Add an entry to the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700117 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700118 * \param face a smart pointer to a Face-derived object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700119 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700120 * @see Face
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700121 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700122 void Add (const Ptr<Face> &face);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700123
124 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700125 * Get a smart pointer to Face-derived object stored in the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700126 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700127 * \param i the iterator corresponding to the requested object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700128 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700129 * This method is redundant and simple dereferencing of the iterator should be used instead
130 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700131 * @see Face
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700132 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700133 Ptr<Face> Get (Iterator i) const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700134
135private:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700136 Container m_faces;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700137};
138
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700139} // namespace ndn
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700140} // namespace ns3
141
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700142#endif /* NDN_FACE_CONTAINER_H */