A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
channel.h
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation;
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 */
15
16#ifndef NS3_CHANNEL_H
17#define NS3_CHANNEL_H
18
19#include "ns3/object.h"
20#include "ns3/ptr.h"
21
22#include <stdint.h>
23#include <string>
24
25namespace ns3
26{
27
28class NetDevice;
29
30/**
31 * \ingroup network
32 * \defgroup channel Channel
33 */
34/**
35 * \ingroup channel
36 * \brief Abstract Channel Base Class.
37 *
38 * A channel is a logical path over which information flows. The path can
39 * be as simple as a short piece of wire, or as complicated as space-time.
40 *
41 * Subclasses must use Simulator::ScheduleWithContext to correctly update
42 * event contexts when scheduling an event from one node to another one.
43 */
44class Channel : public Object
45{
46 public:
47 /**
48 * \brief Get the type ID.
49 * \return the object TypeId
50 */
51 static TypeId GetTypeId();
52
53 Channel();
54 ~Channel() override;
55
56 /**
57 * \returns the unique id of this channel
58 *
59 * This unique id happens to be also the index of the Channel into
60 * the ChannelList.
61 */
62 uint32_t GetId() const;
63
64 /**
65 * \returns the number of NetDevices connected to this Channel.
66 *
67 * This method must be implemented by subclasses.
68 */
69 virtual std::size_t GetNDevices() const = 0;
70 /**
71 * \param i index of NetDevice to retrieve
72 * \returns one of the NetDevices connected to this channel.
73 *
74 * This method must be implemented by subclasses.
75 */
76 virtual Ptr<NetDevice> GetDevice(std::size_t i) const = 0;
77
78 private:
79 uint32_t m_id; //!< Channel id for this channel
80};
81
82} // namespace ns3
83
84#endif /* NS3_CHANNEL_H */
Abstract Channel Base Class.
Definition: channel.h:45
uint32_t m_id
Channel id for this channel.
Definition: channel.h:79
virtual Ptr< NetDevice > GetDevice(std::size_t i) const =0
uint32_t GetId() const
Definition: channel.cc:61
virtual std::size_t GetNDevices() const =0
static TypeId GetTypeId()
Get the type ID.
Definition: channel.cc:34
~Channel() override
Definition: channel.cc:55
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.