A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
energy-harvester.h
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#ifndef ENERGY_HARVESTER_H
22#define ENERGY_HARVESTER_H
23
24#include <iostream>
25
26// include from ns-3
27#include "ns3/energy-source-container.h"
28#include "ns3/node.h"
29#include "ns3/object.h"
30#include "ns3/ptr.h"
31#include "ns3/type-id.h"
32
33namespace ns3
34{
35
36class EnergySource;
37
38/**
39 * \ingroup energy
40 *
41 * \brief Energy harvester base class.
42 */
43
44class EnergyHarvester : public Object
45{
46 public:
47 /**
48 * \brief Get the type ID.
49 * \return The object TypeId.
50 */
51 static TypeId GetTypeId();
52
54
55 ~EnergyHarvester() override;
56
57 /**
58 * \brief Sets pointer to node containing this EnergyHarvester.
59 *
60 * \param node Pointer to node containing this EnergyHarvester.
61 */
62 void SetNode(Ptr<Node> node);
63
64 /**
65 * \returns Pointer to node containing this EnergyHarvester.
66 *
67 * When a subclass needs to get access to the underlying node base class to
68 * print the nodeId for example, it can invoke this method.
69 */
70 Ptr<Node> GetNode() const;
71
72 /**
73 * \param source Pointer to energy source to which this EnergyHarvester is
74 * installed.
75 *
76 * This function sets the pointer to the energy source connected to the energy
77 * harvester.
78 */
80
81 /**
82 * \returns Pointer to energy source connected to the harvester.
83 *
84 * When a subclass needs to get access to the connected energy source,
85 * it can invoke this method.
86 */
88
89 /**
90 * \returns Amount of power currently provided by the harvester.
91 *
92 * This method is called by the energy source connected to the harvester in order
93 * to determine the amount of energy that the harvester provided since last update.
94 */
95 double GetPower() const;
96
97 private:
98 /**
99 *
100 * Defined in ns3::Object
101 */
102 void DoDispose() override;
103
104 /**
105 * This method is called by the GetPower method and it needs to be implemented by the
106 * subclasses of the energy harvester. It returns the actual amount of power that is
107 * currently provided by the energy harvester.
108 *
109 * This method should be used to connect the logic behind the particular implementation
110 * of the energy harvester with the energy source.
111 *
112 * \returns Amount of power currently provided by the harvester.
113 */
114 virtual double DoGetPower() const;
115
116 private:
117 /**
118 * Pointer to node containing this EnergyHarvester. Used by helper class to make
119 * sure energy harvesters are installed onto the corresponding node.
120 */
122
123 /**
124 * Pointer to the Energy Source to which this EnergyHarvester is connected. Used
125 * by helper class to make sure energy harvesters are installed onto the
126 * corresponding energy source.
127 */
129
130 protected:
131};
132
133} // namespace ns3
134
135#endif /* defined(ENERGY_HARVESTER_H) */
Energy harvester base class.
Ptr< EnergySource > GetEnergySource() const
Ptr< Node > GetNode() const
Ptr< EnergySource > m_energySource
Pointer to the Energy Source to which this EnergyHarvester is connected.
double GetPower() const
static TypeId GetTypeId()
Get the type ID.
virtual double DoGetPower() const
This method is called by the GetPower method and it needs to be implemented by the subclasses of the ...
Ptr< Node > m_node
Pointer to node containing this EnergyHarvester.
void DoDispose() override
Defined in ns3::Object.
void SetNode(Ptr< Node > node)
Sets pointer to node containing this EnergyHarvester.
void SetEnergySource(Ptr< EnergySource > source)
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.