LEFT | RIGHT |
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) 2008 INRIA | 3 * Copyright (c) 2008 INRIA |
4 * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle. | 4 * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle. |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License version 2 as | 7 * it under the terms of the GNU General Public License version 2 as |
8 * published by the Free Software Foundation; | 8 * published by the Free Software Foundation; |
9 * | 9 * |
10 * This program is distributed in the hope that it will be useful, | 10 * This program is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 * GNU General Public License for more details. | 13 * GNU General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU General Public License | 15 * You should have received a copy of the GNU General Public License |
16 * along with this program; if not, write to the Free Software | 16 * along with this program; if not, write to the Free Software |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 * | 18 * |
19 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 19 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
20 * Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu> | 20 * Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu> |
21 */ | 21 */ |
22 | 22 |
23 #include "energy-source-container.h" | 23 #include "energy-source-container.h" |
24 #include "ns3/names.h" | 24 #include "ns3/names.h" |
25 | 25 |
26 namespace ns3 { | 26 namespace ns3 { |
27 | 27 |
| 28 TypeId |
| 29 EnergySourceContainer::GetTypeId (void) |
| 30 { |
| 31 static TypeId tid = TypeId ("ns3::EnergySourceContainer") |
| 32 .SetParent<Object> () |
| 33 .AddConstructor<EnergySourceContainer> () |
| 34 ; |
| 35 return tid; |
| 36 } |
| 37 |
28 EnergySourceContainer::EnergySourceContainer () | 38 EnergySourceContainer::EnergySourceContainer () |
| 39 { |
| 40 } |
| 41 |
| 42 EnergySourceContainer::~EnergySourceContainer () |
29 { | 43 { |
30 } | 44 } |
31 | 45 |
32 EnergySourceContainer::EnergySourceContainer (Ptr<EnergySource> source) | 46 EnergySourceContainer::EnergySourceContainer (Ptr<EnergySource> source) |
33 { | 47 { |
34 NS_ASSERT (source != NULL); | 48 NS_ASSERT (source != NULL); |
35 m_sources.push_back (source); | 49 m_sources.push_back (source); |
36 } | 50 } |
37 | 51 |
38 EnergySourceContainer::EnergySourceContainer (std::string sourceName) | 52 EnergySourceContainer::EnergySourceContainer (std::string sourceName) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 104 } |
91 | 105 |
92 void | 106 void |
93 EnergySourceContainer::Add (std::string sourceName) | 107 EnergySourceContainer::Add (std::string sourceName) |
94 { | 108 { |
95 Ptr<EnergySource> source = Names::Find<EnergySource> (sourceName); | 109 Ptr<EnergySource> source = Names::Find<EnergySource> (sourceName); |
96 NS_ASSERT (source != NULL); | 110 NS_ASSERT (source != NULL); |
97 m_sources.push_back (source); | 111 m_sources.push_back (source); |
98 } | 112 } |
99 | 113 |
| 114 /* |
| 115 * Private functions start here. |
| 116 */ |
| 117 |
| 118 void |
| 119 EnergySourceContainer::DoDispose (void) |
| 120 { |
| 121 // call Object::Dispose for all EnergySource objects |
| 122 for (std::vector< Ptr<EnergySource> >::iterator i = m_sources.begin (); |
| 123 i != m_sources.end (); i++) |
| 124 { |
| 125 (*i)->DisposeDeviceModels (); |
| 126 (*i)->Dispose (); |
| 127 } |
| 128 m_sources.clear (); |
| 129 } |
| 130 |
| 131 void |
| 132 EnergySourceContainer::DoStart (void) |
| 133 { |
| 134 // call Object::Start for all EnergySource objects |
| 135 for (std::vector< Ptr<EnergySource> >::iterator i = m_sources.begin (); |
| 136 i != m_sources.end (); i++) |
| 137 { |
| 138 (*i)->Start (); |
| 139 (*i)->StartDeviceModels (); |
| 140 } |
| 141 } |
| 142 |
100 } // namespace ns3 | 143 } // namespace ns3 |
LEFT | RIGHT |