A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
energy-model-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
18 */
19
20#ifndef ENERGY_MODEL_HELPER_H
21#define ENERGY_MODEL_HELPER_H
22
24
25#include "ns3/attribute.h"
26#include "ns3/device-energy-model-container.h"
27#include "ns3/device-energy-model.h"
28#include "ns3/energy-source.h"
29#include "ns3/net-device-container.h"
30#include "ns3/net-device.h"
31#include "ns3/node-container.h"
32#include "ns3/object-factory.h"
33#include "ns3/ptr.h"
34
35namespace ns3
36{
37
38/**
39 * \ingroup energy
40 * \brief Creates EnergySource objects.
41 *
42 * This class creates and installs an energy source onto network nodes.
43 * Multiple sources can exist on a network node.
44 *
45 */
47{
48 public:
49 virtual ~EnergySourceHelper();
50
51 /**
52 * \param name Name of attribute to set.
53 * \param v Value of the attribute.
54 *
55 * Sets one of the attributes of underlying EnergySource.
56 */
57 virtual void Set(std::string name, const AttributeValue& v) = 0;
58
59 /**
60 * \param node Pointer to the node where EnergySource will be installed.
61 * \returns An EnergySourceContainer which contains all the EnergySources.
62 *
63 * This function installs an EnergySource onto a node.
64 */
66
67 /**
68 * \param c List of nodes where EnergySource will be installed.
69 * \returns An EnergySourceContainer which contains all the EnergySources.
70 *
71 * This function installs an EnergySource onto a list of nodes.
72 */
74
75 /**
76 * \param nodeName Name of node where EnergySource will be installed.
77 * \returns An EnergySourceContainer which contains all the EnergySources.
78 *
79 * This function installs an EnergySource onto a node.
80 */
81 EnergySourceContainer Install(std::string nodeName) const;
82
83 /**
84 * \brief This function installs an EnergySource on all nodes in simulation.
85 *
86 * \returns An EnergySourceContainer which contains all the EnergySources.
87 */
89
90 private:
91 /**
92 * \param node Pointer to node where the energy source is to be installed.
93 * \returns Pointer to the created EnergySource.
94 *
95 * Child classes of EnergySourceHelper only have to implement this function,
96 * to create and aggregate an EnergySource object onto a single node. Rest of
97 * the installation process (eg. installing EnergySource on set of nodes) is
98 * implemented in the EnergySourceHelper base class.
99 */
100 virtual Ptr<EnergySource> DoInstall(Ptr<Node> node) const = 0;
101};
102
103/**
104 * \ingroup energy
105 * \brief Creates DeviceEnergyModel objects.
106 *
107 * This class helps to create and install DeviceEnergyModel onto NetDevice. A
108 * DeviceEnergyModel is connected to a NetDevice (or PHY object) by callbacks.
109 * Note that DeviceEnergyModel objects are *not* aggregated onto the node. They
110 * can be accessed through the EnergySource object, which *is* aggregated onto
111 * the node.
112 *
113 */
115{
116 public:
117 virtual ~DeviceEnergyModelHelper();
118
119 /**
120 * \param name Name of attribute to set.
121 * \param v Value of the attribute.
122 *
123 * Sets one of the attributes of underlying DeviceEnergyModel.
124 */
125 virtual void Set(std::string name, const AttributeValue& v) = 0;
126
127 /**
128 * \param device Pointer to the NetDevice to install DeviceEnergyModel.
129 * \param source The EnergySource the DeviceEnergyModel will be using.
130 * \returns An DeviceEnergyModelContainer contains all the DeviceEnergyModels.
131 *
132 * Installs an DeviceEnergyModel with a specified EnergySource onto a
133 * xNetDevice.
134 */
136
137 /**
138 * \param deviceContainer List of NetDevices to be install DeviceEnergyModel
139 * objects.
140 * \param sourceContainer List of EnergySource the DeviceEnergyModel will be
141 * using.
142 * \returns An DeviceEnergyModelContainer contains all the DeviceEnergyModels.
143 *
144 * Installs DeviceEnergyModels with specified EnergySources onto a list of
145 * NetDevices.
146 */
148 EnergySourceContainer sourceContainer) const;
149
150 private:
151 /**
152 * \param device The net device corresponding to DeviceEnergyModel object.
153 * \param source The EnergySource the DeviceEnergyModel will be using.
154 * \returns Pointer to the created DeviceEnergyModel.
155 *
156 * Child classes of DeviceEnergyModelHelper only have to implement this
157 * function, to create and aggregate an DeviceEnergyModel object onto a single
158 * node. The rest of the installation process (eg. installing EnergySource on
159 * set of nodes) is implemented in the DeviceEnergyModelHelper base class.
160 */
162 Ptr<EnergySource> source) const = 0;
163};
164
165} // namespace ns3
166
167#endif /* ENERGY_MODEL_HELPER_H */
Hold a value for an Attribute.
Definition: attribute.h:70
Holds a vector of ns3::DeviceEnergyModel pointers.
Creates DeviceEnergyModel objects.
DeviceEnergyModelContainer Install(Ptr< NetDevice > device, Ptr< EnergySource > source) const
virtual Ptr< DeviceEnergyModel > DoInstall(Ptr< NetDevice > device, Ptr< EnergySource > source) const =0
virtual void Set(std::string name, const AttributeValue &v)=0
Holds a vector of ns3::EnergySource pointers.
Creates EnergySource objects.
EnergySourceContainer Install(Ptr< Node > node) const
virtual Ptr< EnergySource > DoInstall(Ptr< Node > node) const =0
virtual void Set(std::string name, const AttributeValue &v)=0
EnergySourceContainer InstallAll() const
This function installs an EnergySource on all nodes in simulation.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Every class exported by the ns3 library is enclosed in the ns3 namespace.