OLD | NEW |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle. | 3 * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle. |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 29 matching lines...) Expand all Loading... |
40 { | 40 { |
41 } | 41 } |
42 | 42 |
43 EnergySource::~EnergySource () | 43 EnergySource::~EnergySource () |
44 { | 44 { |
45 } | 45 } |
46 | 46 |
47 void | 47 void |
48 EnergySource::SetNode (Ptr<Node> node) | 48 EnergySource::SetNode (Ptr<Node> node) |
49 { | 49 { |
50 NS_LOG_FUNCTION (this << node); | |
51 NS_ASSERT (node != NULL); | 50 NS_ASSERT (node != NULL); |
52 m_node = node; | 51 m_node = node; |
53 } | 52 } |
54 | 53 |
55 Ptr<Node> | 54 Ptr<Node> |
56 EnergySource::GetNode (void) const | 55 EnergySource::GetNode (void) const |
57 { | 56 { |
58 NS_LOG_FUNCTION (this); | |
59 return m_node; | 57 return m_node; |
60 } | 58 } |
61 | 59 |
62 void | 60 void |
63 EnergySource::AppendDeviceEnergyModel (Ptr<DeviceEnergyModel> deviceEnergyModelP
tr) | 61 EnergySource::AppendDeviceEnergyModel (Ptr<DeviceEnergyModel> deviceEnergyModelP
tr) |
64 { | 62 { |
65 NS_LOG_FUNCTION (this << deviceEnergyModelPtr); | 63 NS_LOG_FUNCTION (this << deviceEnergyModelPtr); |
66 NS_ASSERT (deviceEnergyModelPtr != NULL); // model must exist | 64 NS_ASSERT (deviceEnergyModelPtr != NULL); // model must exist |
67 m_models.Add (deviceEnergyModelPtr); | 65 m_models.Add (deviceEnergyModelPtr); |
68 } | 66 } |
(...skipping 23 matching lines...) Expand all Loading... |
92 for (i = m_models.Begin (); i != m_models.End (); i++) | 90 for (i = m_models.Begin (); i != m_models.End (); i++) |
93 { | 91 { |
94 if ((*i)->GetInstanceTypeId ().GetName ().compare (name) == 0) | 92 if ((*i)->GetInstanceTypeId ().GetName ().compare (name) == 0) |
95 { | 93 { |
96 container.Add (*i); | 94 container.Add (*i); |
97 } | 95 } |
98 } | 96 } |
99 return container; | 97 return container; |
100 } | 98 } |
101 | 99 |
| 100 void |
| 101 EnergySource::StartDeviceModels (void) |
| 102 { |
| 103 /* |
| 104 * Device models are not aggregated to the node, hence we have to manually |
| 105 * call dispose method here. |
| 106 */ |
| 107 DeviceEnergyModelContainer::Iterator i; |
| 108 for (i = m_models.Begin (); i != m_models.End (); i++) |
| 109 { |
| 110 (*i)->Start (); |
| 111 } |
| 112 } |
| 113 |
| 114 void |
| 115 EnergySource::DisposeDeviceModels (void) |
| 116 { |
| 117 /* |
| 118 * Device models are not aggregated to the node, hence we have to manually |
| 119 * call dispose method here. |
| 120 */ |
| 121 DeviceEnergyModelContainer::Iterator i; |
| 122 for (i = m_models.Begin (); i != m_models.End (); i++) |
| 123 { |
| 124 (*i)->Dispose (); |
| 125 } |
| 126 } |
| 127 |
102 /* | 128 /* |
103 * Private function starts here. | 129 * Private function starts here. |
104 */ | 130 */ |
105 | 131 |
106 void | 132 void |
107 EnergySource::DoDispose (void) | 133 EnergySource::DoDispose (void) |
108 { | 134 { |
109 NS_LOG_FUNCTION (this); | 135 NS_LOG_FUNCTION (this); |
110 m_models.Clear (); | 136 BreakDeviceEnergyModelRefCycle (); |
111 } | 137 } |
112 | 138 |
113 /* | 139 /* |
114 * Protected functions start here. | 140 * Protected functions start here. |
115 */ | 141 */ |
116 | 142 |
117 double | 143 double |
118 EnergySource::CalculateTotalCurrent (void) | 144 EnergySource::CalculateTotalCurrent (void) |
119 { | 145 { |
120 NS_LOG_FUNCTION (this); | 146 NS_LOG_FUNCTION (this); |
(...skipping 20 matching lines...) Expand all Loading... |
141 | 167 |
142 void | 168 void |
143 EnergySource::BreakDeviceEnergyModelRefCycle (void) | 169 EnergySource::BreakDeviceEnergyModelRefCycle (void) |
144 { | 170 { |
145 NS_LOG_FUNCTION (this); | 171 NS_LOG_FUNCTION (this); |
146 m_models.Clear (); | 172 m_models.Clear (); |
147 m_node = NULL; | 173 m_node = NULL; |
148 } | 174 } |
149 | 175 |
150 } // namespace ns3 | 176 } // namespace ns3 |
OLD | NEW |