blob: ecb29d96ccaec2684e35a0d48a5589038c895ed5 [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
21#ifndef CCNX_FACE_CONTAINER_H
22#define CCNX_FACE_CONTAINER_H
23
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 Afanasyev45b92d42011-08-14 23:11:38 -070029
30namespace ns3 {
31
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070032class CcnxFace;
33
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070034/**
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070035 * \ingroup ccnx-helpers
Alexander Afanasyev7112f482011-08-17 14:05:57 -070036 * \brief A pool for CCNx faces
37 *
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 Afanasyev0ab833e2011-08-18 15:49:13 -070041 * \see CcnxStackHelper
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070042 */
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070043class CcnxFaceContainer : public SimpleRefCount<CcnxFaceContainer>
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070044{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070045private:
46 typedef std::vector<Ptr<CcnxFace> > FaceContainer;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070047public:
Alexander Afanasyev7112f482011-08-17 14:05:57 -070048 typedef FaceContainer::const_iterator Iterator; ///< \brief Iterator over CcnxFaceContainer
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070049
50 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070051 * \brief Create an empty CcnxFaceContainer.
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070052 */
53 CcnxFaceContainer ();
54
55 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070056 * \brief Copy constructor for CcnxFaceContainer. Calls AddAll method
57 *
58 * \see CcnxFaceContainer::AddAll
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070059 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -070060 CcnxFaceContainer (const CcnxFaceContainer &other);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070061
62 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070063 * \brief Copy operator for CcnxFaceContainer. Empties vector and calls AddAll method
64 *
65 * All previously obtained iterators (Begin() and End()) will be invalidated
66 *
67 * \see CcnxFaceContainer::AddAll
68 */
69 CcnxFaceContainer& operator= (const CcnxFaceContainer &other);
70
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 */
76 void AddAll (Ptr<CcnxFaceContainer> other);
77
78 /**
79 * \brief Add all entries from other container
80 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070081 * \param other container
82 */
83 void AddAll (const CcnxFaceContainer &other);
84
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
108 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700109 * \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
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700112 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700113 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 Afanasyev7112f482011-08-17 14:05:57 -0700118 * \param face a smart pointer to a CcnxFace-derived object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700119 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700120 * @see CcnxFace
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700121 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700122 void Add (const Ptr<CcnxFace> &face);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700123
124 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700125 * Get a smart pointer to CcnxFace-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 *
131 * @see CcnxFace
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700132 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700133 Ptr<CcnxFace> Get (Iterator i) const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700134
135private:
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700136 FaceContainer m_faces;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700137};
138
139} // namespace ns3
140
141#endif /* CCNX_FACE_CONTAINER_H */