1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3
* Copyright (c) 2008 INRIA
4
* Copyright (c) 2010 Network Security Lab, University of Washington, Seattle.
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
8
* published by the Free Software Foundation;
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
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
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20
* Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
23
#include "energy-source-container.h"
24
#include "ns3/names.h"
29
EnergySourceContainer::GetTypeId (void)
31
static TypeId tid = TypeId ("ns3::EnergySourceContainer")
33
.AddConstructor<EnergySourceContainer> ()
38
EnergySourceContainer::EnergySourceContainer ()
42
EnergySourceContainer::~EnergySourceContainer ()
46
EnergySourceContainer::EnergySourceContainer (Ptr<EnergySource> source)
48
NS_ASSERT (source != NULL);
49
m_sources.push_back (source);
52
EnergySourceContainer::EnergySourceContainer (std::string sourceName)
54
Ptr<EnergySource> source = Names::Find<EnergySource> (sourceName);
55
NS_ASSERT (source != NULL);
56
m_sources.push_back (source);
59
EnergySourceContainer::EnergySourceContainer (const EnergySourceContainer &a,
60
const EnergySourceContainer &b)
66
EnergySourceContainer::Iterator
67
EnergySourceContainer::Begin (void) const
69
return m_sources.begin ();
72
EnergySourceContainer::Iterator
73
EnergySourceContainer::End (void) const
75
return m_sources.end ();
79
EnergySourceContainer::GetN (void) const
81
return m_sources.size ();
85
EnergySourceContainer::Get (uint32_t i) const
91
EnergySourceContainer::Add (EnergySourceContainer container)
93
for (Iterator i = container.Begin (); i != container.End (); i++)
95
m_sources.push_back (*i);
100
EnergySourceContainer::Add (Ptr<EnergySource> source)
102
NS_ASSERT (source != NULL);
103
m_sources.push_back (source);
107
EnergySourceContainer::Add (std::string sourceName)
109
Ptr<EnergySource> source = Names::Find<EnergySource> (sourceName);
110
NS_ASSERT (source != NULL);
111
m_sources.push_back (source);
115
* Private functions start here.
119
EnergySourceContainer::DoDispose (void)
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++)
125
(*i)->DisposeDeviceModels ();
132
EnergySourceContainer::DoStart (void)
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++)
139
(*i)->StartDeviceModels ();