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