Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 UCLA |
| 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 | */ |
| 20 | |
| 21 | #ifndef CCNX_GLOBAL_ROUTER_H |
| 22 | #define CCNX_GLOBAL_ROUTER_H |
| 23 | |
| 24 | #include "ns3/object.h" |
| 25 | #include "ns3/ptr.h" |
| 26 | |
| 27 | #include <list> |
| 28 | #include <boost/tuple/tuple.hpp> |
| 29 | |
| 30 | namespace ns3 { |
| 31 | |
| 32 | class Channel; |
| 33 | class Ccnx; |
| 34 | class CcnxFace; |
| 35 | class CcnxNameComponents; |
| 36 | |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 37 | /** |
| 38 | * @brief Class representing global router interface for ndnSIM |
| 39 | */ |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 40 | class CcnxGlobalRouter : public Object |
| 41 | { |
| 42 | public: |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 43 | /** |
| 44 | * @brief Graph edge |
| 45 | */ |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 46 | typedef boost::tuple< Ptr< CcnxGlobalRouter >, Ptr< CcnxFace >, Ptr< CcnxGlobalRouter > > Incidency; |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 47 | /** |
| 48 | * @brief List of graph edges |
| 49 | */ |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 50 | typedef std::list< Incidency > IncidencyList; |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 51 | /** |
| 52 | * @brief List of locally exported prefixes |
| 53 | */ |
Alexander Afanasyev | 8e2f112 | 2012-04-17 15:01:11 -0700 | [diff] [blame] | 54 | typedef std::list< Ptr<CcnxNameComponents> > LocalPrefixList; |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 55 | |
| 56 | /** |
| 57 | * \brief Interface ID |
| 58 | * |
| 59 | * \return interface ID |
| 60 | */ |
| 61 | static TypeId |
| 62 | GetTypeId (); |
| 63 | |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 64 | /** |
| 65 | * @brief Default constructor |
| 66 | */ |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 67 | CcnxGlobalRouter (); |
| 68 | |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 69 | /** |
| 70 | * @brief Get numeric ID of the node (internally assigned) |
| 71 | */ |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 72 | uint32_t |
| 73 | GetId () const; |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * @brief Helper function to get smart pointer to Ccnx object (basically, self) |
| 77 | */ |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 78 | Ptr<Ccnx> |
| 79 | GetCcnx () const; |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * @brief Add new locally exported prefix |
| 83 | * @param prefix Prefix |
| 84 | */ |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 85 | void |
| 86 | AddLocalPrefix (Ptr< CcnxNameComponents > prefix); |
| 87 | |
| 88 | /** |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 89 | * @brief Add edge to the node |
| 90 | * @param face Face of the edge |
| 91 | * @param ccnx CcnxGlobalRouter of another node |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 92 | */ |
| 93 | void |
| 94 | AddIncidency (Ptr< CcnxFace > face, Ptr< CcnxGlobalRouter > ccnx); |
| 95 | |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 96 | /** |
| 97 | * @brief Get list of edges that are connected to this node |
| 98 | */ |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 99 | IncidencyList & |
| 100 | GetIncidencies (); |
| 101 | |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 102 | /** |
| 103 | * @brief Get list of locally exported prefixes |
| 104 | */ |
Alexander Afanasyev | 8e2f112 | 2012-04-17 15:01:11 -0700 | [diff] [blame] | 105 | const LocalPrefixList & |
| 106 | GetLocalPrefixes () const; |
| 107 | |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 108 | // ?? |
| 109 | protected: |
| 110 | virtual void |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 111 | NotifyNewAggregate (); ///< @brief Notify when the object is aggregated to another object (e.g., Node) |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 112 | |
| 113 | private: |
| 114 | uint32_t m_id; |
| 115 | |
| 116 | Ptr<Ccnx> m_ccnx; |
Alexander Afanasyev | 8e2f112 | 2012-04-17 15:01:11 -0700 | [diff] [blame] | 117 | LocalPrefixList m_localPrefixes; |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 118 | IncidencyList m_incidencies; |
| 119 | |
| 120 | static uint32_t m_idCounter; |
| 121 | }; |
| 122 | |
| 123 | inline bool |
| 124 | operator == (const CcnxGlobalRouter::Incidency &a, |
| 125 | const CcnxGlobalRouter::Incidency &b) |
| 126 | { |
| 127 | return a.get<0> () == b.get<0> () && |
| 128 | a.get<1> () == b.get<1> () && |
| 129 | a.get<2> () == b.get<2> (); |
| 130 | } |
| 131 | |
| 132 | inline bool |
| 133 | operator != (const CcnxGlobalRouter::Incidency &a, |
| 134 | const CcnxGlobalRouter::Incidency &b) |
| 135 | { |
| 136 | return ! (a == b); |
| 137 | } |
| 138 | |
| 139 | } |
| 140 | |
| 141 | #endif // CCNX_GLOBAL_ROUTER_H |