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