1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
|
2 /* |
|
3 * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle. |
|
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 * Authors: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu> |
|
19 */ |
|
20 |
|
21 #ifndef ENERGY_MODEL_HELPER_H |
|
22 #define ENERGY_MODEL_HELPER_H |
|
23 |
|
24 #include "ns3/attribute.h" |
|
25 #include "ns3/object-factory.h" |
|
26 #include "ns3/node-container.h" |
|
27 #include "ns3/ptr.h" |
|
28 #include "ns3/net-device.h" |
|
29 #include "ns3/net-device-container.h" |
|
30 #include "ns3/energy-source.h" |
|
31 #include "ns3/device-energy-model.h" |
|
32 #include "ns3/device-energy-model-container.h" |
|
33 #include "energy-source-container.h" |
|
34 |
|
35 namespace ns3 { |
|
36 |
|
37 /** |
|
38 * \brief Creates EnergySource objects. |
|
39 * |
|
40 * This class creates and installs an energy source onto network nodes. Only a |
|
41 * single source can exist on a network node. |
|
42 */ |
|
43 class EnergySourceHelper |
|
44 { |
|
45 public: |
|
46 virtual ~EnergySourceHelper (); |
|
47 |
|
48 /** |
|
49 * \param name Name of attribute to set. |
|
50 * \param v Value of the attribute. |
|
51 * |
|
52 * Sets one of the attributes of underlying EnergySource. |
|
53 */ |
|
54 virtual void Set (std::string name, const AttributeValue &v) = 0; |
|
55 |
|
56 /** |
|
57 * \param node Pointer to the node where EnergySource will be installed. |
|
58 * \returns An EnergySourceContainer which contains all the EnergySources. |
|
59 * |
|
60 * This function installs an EnergySource onto a node. |
|
61 */ |
|
62 EnergySourceContainer Install (Ptr<Node> node) const; |
|
63 |
|
64 /** |
|
65 * \param c List of nodes where EnergySource will be installed. |
|
66 * \returns An EnergySourceContainer which contains all the EnergySources. |
|
67 * |
|
68 * This function installs an EnergySource onto a list of nodes. |
|
69 */ |
|
70 EnergySourceContainer Install (NodeContainer c) const; |
|
71 |
|
72 /** |
|
73 * \param nodeName Name of node where EnergySource will be installed. |
|
74 * \returns An EnergySourceContainer which contains all the EnergySources. |
|
75 * |
|
76 * This function installs an EnergySource onto a node. |
|
77 */ |
|
78 EnergySourceContainer Install (std::string nodeName) const; |
|
79 |
|
80 /** |
|
81 * \brief This function installs an EnergySource on all nodes in simulation. |
|
82 * |
|
83 * \returns An EnergySourceContainer which contains all the EnergySources. |
|
84 */ |
|
85 EnergySourceContainer InstallAll (void) const; |
|
86 |
|
87 |
|
88 private: |
|
89 /** |
|
90 * \param node Pointer to node where the energy source is to be installed. |
|
91 * \returns Pointer to the created EnergySource. |
|
92 * |
|
93 * Child classes of EnergySourceHelper only have to implement this function, |
|
94 * to create and aggregate an EnergySource object onto a single node. Rest of |
|
95 * the installation process (eg. installing EnergySource on set of nodes) is |
|
96 * implemented in the EnergySourceHelper base class. |
|
97 */ |
|
98 virtual Ptr<EnergySource> DoInstall (Ptr<Node> node) const = 0; |
|
99 |
|
100 }; |
|
101 |
|
102 |
|
103 /** |
|
104 * \brief Creates DeviceEnergyModel objects. |
|
105 * |
|
106 * This class helps to create and install DeviceEnergyModel onto NetDevice. A |
|
107 * DeviceEnergyModel is connected to a NetDevice (or PHY object) by callbacks. |
|
108 * Note that DeviceEnergyModel objects are *not* aggregated onto the node. They |
|
109 * can be accessed through the EnergySource object, which *is* aggregated onto |
|
110 * the node. |
|
111 */ |
|
112 class DeviceEnergyModelHelper |
|
113 { |
|
114 public: |
|
115 virtual ~DeviceEnergyModelHelper (); |
|
116 |
|
117 /** |
|
118 * \param name Name of attribute to set. |
|
119 * \param v Value of the attribute. |
|
120 * |
|
121 * Sets one of the attributes of underlying DeviceEnergyModel. |
|
122 */ |
|
123 virtual void Set (std::string name, const AttributeValue &v) = 0; |
|
124 |
|
125 /** |
|
126 * \param device Pointer to the NetDevice to install DeviceEnergyModel. |
|
127 * \param source The EnergySource the DeviceEnergyModel will be using. |
|
128 * \returns An DeviceEnergyModelContainer contains all the DeviceEnergyModels. |
|
129 * |
|
130 * Installs an DeviceEnergyModel with a specified EnergySource onto a |
|
131 * xNetDevice. |
|
132 */ |
|
133 DeviceEnergyModelContainer Install (Ptr<NetDevice> device, |
|
134 Ptr<EnergySource> source) const; |
|
135 |
|
136 /** |
|
137 * \param deviceContainer List of NetDevices to be install DeviceEnergyModel |
|
138 * objects. |
|
139 * \param sourceContainer List of EnergySource the DeviceEnergyModel will be |
|
140 * using. |
|
141 * \returns An DeviceEnergyModelContainer contains all the DeviceEnergyModels. |
|
142 * |
|
143 * Installs DeviceEnergyModels with specified EnergySources onto a list of |
|
144 * NetDevices. |
|
145 */ |
|
146 DeviceEnergyModelContainer Install (NetDeviceContainer deviceContainer, |
|
147 EnergySourceContainer sourceContainer) const; |
|
148 |
|
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 */ |
|
161 virtual Ptr<DeviceEnergyModel> DoInstall (Ptr<NetDevice> device, |
|
162 Ptr<EnergySource> source) const = 0; |
|
163 |
|
164 }; |
|
165 |
|
166 } // namespace ns3 |
|
167 |
|
168 #endif /* ENERGY_MODEL_HELPER_H */ |
|