A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
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
* SPDX-License-Identifier: GPL-2.0-only
6
*
7
* Author: Cristiano Tapparello <cristiano.tapparello@rochester.edu>
8
*/
9
10
#include "
energy-harvester-helper.h
"
11
12
#include "ns3/config.h"
13
#include "ns3/names.h"
14
15
namespace
ns3
16
{
17
18
/*
19
* EnergyHarvesterHelper
20
*/
21
EnergyHarvesterHelper::~EnergyHarvesterHelper
()
22
{
23
}
24
25
energy::EnergyHarvesterContainer
26
EnergyHarvesterHelper::Install
(
Ptr<energy::EnergySource>
source)
const
27
{
28
return
Install
(
energy::EnergySourceContainer
(source));
29
}
30
31
energy::EnergyHarvesterContainer
32
EnergyHarvesterHelper::Install
(
energy::EnergySourceContainer
sourceContainer)
const
33
{
34
energy::EnergyHarvesterContainer
container;
35
for
(
auto
i = sourceContainer.
Begin
(); i != sourceContainer.
End
(); ++i)
36
{
37
Ptr<energy::EnergyHarvester>
harvester =
DoInstall
(*i);
38
container.Add(harvester);
39
Ptr<Node>
node = (*i)->GetNode();
40
/*
41
* Check if EnergyHarvesterContainer is already aggregated to target node. If
42
* not, create a new EnergyHarvesterContainer and aggregate it to the node.
43
*/
44
Ptr<energy::EnergyHarvesterContainer>
EnergyHarvesterContainerOnNode =
45
node->GetObject<
energy::EnergyHarvesterContainer
>();
46
if
(!EnergyHarvesterContainerOnNode)
47
{
48
ObjectFactory
fac;
49
fac.
SetTypeId
(
"ns3::energy::EnergyHarvesterContainer"
);
50
EnergyHarvesterContainerOnNode = fac.
Create
<
energy::EnergyHarvesterContainer
>();
51
EnergyHarvesterContainerOnNode->Add(harvester);
52
node->AggregateObject(EnergyHarvesterContainerOnNode);
53
}
54
else
55
{
56
EnergyHarvesterContainerOnNode->Add(harvester);
// append new EnergyHarvester
57
}
58
}
59
return
container;
60
}
61
62
energy::EnergyHarvesterContainer
63
EnergyHarvesterHelper::Install
(std::string sourceName)
const
64
{
65
Ptr<energy::EnergySource>
source =
Names::Find<energy::EnergySource>
(sourceName);
66
return
Install
(source);
67
}
68
69
}
// namespace ns3
ns3::EnergyHarvesterHelper::~EnergyHarvesterHelper
virtual ~EnergyHarvesterHelper()
Definition
energy-harvester-helper.cc:21
ns3::EnergyHarvesterHelper::DoInstall
virtual Ptr< energy::EnergyHarvester > DoInstall(Ptr< energy::EnergySource > source) const =0
ns3::EnergyHarvesterHelper::Install
energy::EnergyHarvesterContainer Install(Ptr< energy::EnergySource > source) const
Definition
energy-harvester-helper.cc:26
ns3::Names::Find
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
Definition
names.h:443
ns3::ObjectFactory
Instantiate subclasses of ns3::Object.
Definition
object-factory.h:37
ns3::ObjectFactory::Create
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
Definition
object-factory.cc:82
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition
object-factory.cc:31
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::energy::EnergyHarvesterContainer
Holds a vector of ns3::EnergyHarvester pointers.
Definition
energy-harvester-container.h:38
ns3::energy::EnergySourceContainer
Holds a vector of ns3::EnergySource pointers.
Definition
energy-source-container.h:37
ns3::energy::EnergySourceContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first EnergySource pointer in the container.
Definition
energy-source-container.cc:62
ns3::energy::EnergySourceContainer::End
Iterator End() const
Get an iterator which refers to the last EnergySource pointer in the container.
Definition
energy-source-container.cc:68
energy-harvester-helper.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
energy
helper
energy-harvester-helper.cc
Generated on Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0