A Discrete-Event Network Simulator
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
11
12#include "ns3/config.h"
13#include "ns3/names.h"
14
15namespace ns3
16{
17
18/*
19 * EnergyHarvesterHelper
20 */
24
30
33{
35 for (auto i = sourceContainer.Begin(); i != sourceContainer.End(); ++i)
36 {
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
63EnergyHarvesterHelper::Install(std::string sourceName) const
64{
66 return Install(source);
67}
68
69} // namespace ns3
virtual Ptr< energy::EnergyHarvester > DoInstall(Ptr< energy::EnergySource > source) const =0
energy::EnergyHarvesterContainer Install(Ptr< energy::EnergySource > source) const
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
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Smart pointer class similar to boost::intrusive_ptr.
Holds a vector of ns3::EnergyHarvester pointers.
Holds a vector of ns3::EnergySource pointers.
Iterator Begin() const
Get an iterator which refers to the first EnergySource pointer in the container.
Iterator End() const
Get an iterator which refers to the last EnergySource pointer in the container.
Every class exported by the ns3 library is enclosed in the ns3 namespace.