blob: a35c08b1ce19a64712f176acb5764e9000ea4847 [file] [log] [blame]
Alexander Afanasyevad3757f2012-04-17 10:27:59 -07001/* -*- 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
30namespace ns3 {
31
32class Channel;
33class Ccnx;
34class CcnxFace;
35class CcnxNameComponents;
36
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070037/**
38 * @brief Class representing global router interface for ndnSIM
39 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070040class CcnxGlobalRouter : public Object
41{
42public:
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070043 /**
44 * @brief Graph edge
45 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070046 typedef boost::tuple< Ptr< CcnxGlobalRouter >, Ptr< CcnxFace >, Ptr< CcnxGlobalRouter > > Incidency;
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070047 /**
48 * @brief List of graph edges
49 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070050 typedef std::list< Incidency > IncidencyList;
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070051 /**
52 * @brief List of locally exported prefixes
53 */
Alexander Afanasyev8e2f1122012-04-17 15:01:11 -070054 typedef std::list< Ptr<CcnxNameComponents> > LocalPrefixList;
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070055
56 /**
57 * \brief Interface ID
58 *
59 * \return interface ID
60 */
61 static TypeId
62 GetTypeId ();
63
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070064 /**
65 * @brief Default constructor
66 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070067 CcnxGlobalRouter ();
68
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070069 /**
70 * @brief Get numeric ID of the node (internally assigned)
71 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070072 uint32_t
73 GetId () const;
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070074
75 /**
76 * @brief Helper function to get smart pointer to Ccnx object (basically, self)
77 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070078 Ptr<Ccnx>
79 GetCcnx () const;
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070080
81 /**
82 * @brief Add new locally exported prefix
83 * @param prefix Prefix
84 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070085 void
86 AddLocalPrefix (Ptr< CcnxNameComponents > prefix);
87
88 /**
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070089 * @brief Add edge to the node
90 * @param face Face of the edge
91 * @param ccnx CcnxGlobalRouter of another node
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070092 */
93 void
94 AddIncidency (Ptr< CcnxFace > face, Ptr< CcnxGlobalRouter > ccnx);
95
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070096 /**
97 * @brief Get list of edges that are connected to this node
98 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070099 IncidencyList &
100 GetIncidencies ();
101
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -0700102 /**
103 * @brief Get list of locally exported prefixes
104 */
Alexander Afanasyev8e2f1122012-04-17 15:01:11 -0700105 const LocalPrefixList &
106 GetLocalPrefixes () const;
107
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700108 // ??
109protected:
110 virtual void
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -0700111 NotifyNewAggregate (); ///< @brief Notify when the object is aggregated to another object (e.g., Node)
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700112
113private:
114 uint32_t m_id;
115
116 Ptr<Ccnx> m_ccnx;
Alexander Afanasyev8e2f1122012-04-17 15:01:11 -0700117 LocalPrefixList m_localPrefixes;
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700118 IncidencyList m_incidencies;
119
120 static uint32_t m_idCounter;
121};
122
123inline bool
124operator == (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
132inline bool
133operator != (const CcnxGlobalRouter::Incidency &a,
134 const CcnxGlobalRouter::Incidency &b)
135{
136 return ! (a == b);
137}
138
139}
140
141#endif // CCNX_GLOBAL_ROUTER_H