A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
energy-harvester-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2014 Wireless Communications and Networking Group (WCNG),
3
* University of Rochester, Rochester, NY, USA.
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
* Author: Cristiano Tapparello <cristiano.tapparello@rochester.edu>
19
*/
20
21
#include "
energy-harvester-helper.h
"
22
23
#include "ns3/config.h"
24
#include "ns3/names.h"
25
26
namespace
ns3
27
{
28
29
/*
30
* EnergyHarvesterHelper
31
*/
32
EnergyHarvesterHelper::~EnergyHarvesterHelper
()
33
{
34
}
35
36
EnergyHarvesterContainer
37
EnergyHarvesterHelper::Install
(
Ptr<EnergySource>
source)
const
38
{
39
return
Install
(
EnergySourceContainer
(source));
40
}
41
42
EnergyHarvesterContainer
43
EnergyHarvesterHelper::Install
(
EnergySourceContainer
sourceContainer)
const
44
{
45
EnergyHarvesterContainer
container
;
46
for
(
auto
i = sourceContainer.
Begin
(); i != sourceContainer.
End
(); ++i)
47
{
48
Ptr<EnergyHarvester>
harvester =
DoInstall
(*i);
49
container
.Add(harvester);
50
Ptr<Node>
node = (*i)->GetNode();
51
/*
52
* Check if EnergyHarvesterContainer is already aggregated to target node. If
53
* not, create a new EnergyHarvesterContainer and aggregate it to the node.
54
*/
55
Ptr<EnergyHarvesterContainer>
EnergyHarvesterContainerOnNode =
56
node->
GetObject
<
EnergyHarvesterContainer
>();
57
if
(!EnergyHarvesterContainerOnNode)
58
{
59
ObjectFactory
fac;
60
fac.
SetTypeId
(
"ns3::EnergyHarvesterContainer"
);
61
EnergyHarvesterContainerOnNode = fac.
Create
<
EnergyHarvesterContainer
>();
62
EnergyHarvesterContainerOnNode->Add(harvester);
63
node->
AggregateObject
(EnergyHarvesterContainerOnNode);
64
}
65
else
66
{
67
EnergyHarvesterContainerOnNode->Add(harvester);
// append new EnergyHarvester
68
}
69
}
70
return
container
;
71
}
72
73
EnergyHarvesterContainer
74
EnergyHarvesterHelper::Install
(std::string sourceName)
const
75
{
76
Ptr<EnergySource>
source = Names::Find<EnergySource>(sourceName);
77
return
Install
(source);
78
}
79
80
}
// namespace ns3
ns3::EnergyHarvesterContainer
Holds a vector of ns3::EnergyHarvester pointers.
Definition:
energy-harvester-container.h:47
ns3::EnergyHarvesterHelper::~EnergyHarvesterHelper
virtual ~EnergyHarvesterHelper()
Definition:
energy-harvester-helper.cc:32
ns3::EnergyHarvesterHelper::DoInstall
virtual Ptr< EnergyHarvester > DoInstall(Ptr< EnergySource > source) const =0
ns3::EnergyHarvesterHelper::Install
EnergyHarvesterContainer Install(Ptr< EnergySource > source) const
Definition:
energy-harvester-helper.cc:37
ns3::EnergySourceContainer
Holds a vector of ns3::EnergySource pointers.
Definition:
energy-source-container.h:46
ns3::EnergySourceContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first EnergySource pointer in the container.
Definition:
energy-source-container.cc:70
ns3::EnergySourceContainer::End
Iterator End() const
Get an iterator which refers to the last EnergySource pointer in the container.
Definition:
energy-source-container.cc:76
ns3::ObjectFactory
Instantiate subclasses of ns3::Object.
Definition:
object-factory.h:48
ns3::ObjectFactory::Create
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
Definition:
object-factory.cc:93
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition:
object-factory.cc:42
ns3::Object::GetObject
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition:
object.h:471
ns3::Object::AggregateObject
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition:
object.cc:259
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
energy-harvester-helper.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
openflow-switch.container
container
Definition:
openflow-switch.py:46
src
energy
helper
energy-harvester-helper.cc
Generated on Sun Mar 3 2024 17:10:57 for ns-3 by
1.9.1