A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-radio-energy-model-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle.
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
7 */
8
9#ifndef WIFI_RADIO_ENERGY_MODEL_HELPER_H
10#define WIFI_RADIO_ENERGY_MODEL_HELPER_H
11
12#include "ns3/energy-model-helper.h"
13#include "ns3/wifi-export.h"
14#include "ns3/wifi-radio-energy-model.h"
15
16namespace ns3
17{
18
19/**
20 * @ingroup energy
21 * @brief Assign WifiRadioEnergyModel to wifi devices.
22 *
23 * This installer installs WifiRadioEnergyModel for only WifiNetDevice objects.
24 *
25 */
27{
28 public:
29 /**
30 * Construct a helper which is used to add a radio energy model to a node
31 */
33
34 /**
35 * Destroy a RadioEnergy Helper
36 */
38
39 /**
40 * @param name the name of the attribute to set
41 * @param v the value of the attribute
42 *
43 * Sets an attribute of the underlying PHY object.
44 */
45 void Set(std::string name, const AttributeValue& v) override;
46
47 /**
48 * @param callback Callback function for energy depletion handling.
49 *
50 * Sets the callback to be invoked when energy is depleted.
51 */
53
54 /**
55 * @param callback Callback function for energy recharged handling.
56 *
57 * Sets the callback to be invoked when energy is recharged.
58 */
60
61 /**
62 * @tparam Ts \deduced Argument types
63 * @param name the name of the model to set
64 * @param [in] args Name and AttributeValue pairs to set.
65 *
66 * Configure a Transmission Current model for this EnergySource.
67 */
68 template <typename... Ts>
69 void SetTxCurrentModel(std::string name, Ts&&... args);
70
71 private:
72 /**
73 * @param device Pointer to the NetDevice to install DeviceEnergyModel.
74 * @param source Pointer to EnergySource to install.
75 * @returns Ptr<DeviceEnergyModel>
76 *
77 * Implements DeviceEnergyModel::Install.
78 */
80 Ptr<energy::EnergySource> source) const override;
81
82 private:
83 ObjectFactory m_radioEnergy; ///< radio energy
85 m_depletionCallback; ///< radio energy depletion callback
87 m_rechargedCallback; ///< radio energy recharged callback
88 ObjectFactory m_txCurrentModel; ///< transmit current model
89};
90
91/***************************************************************
92 * Implementation of the templates declared above.
93 ***************************************************************/
94
95template <typename... Ts>
96void
97WifiRadioEnergyModelHelper::SetTxCurrentModel(std::string name, Ts&&... args)
98{
99 m_txCurrentModel = ObjectFactory(name, std::forward<Ts>(args)...);
100}
101
102} // namespace ns3
103
104#endif /* WIFI_RADIO_ENERGY_MODEL_HELPER_H */
Hold a value for an Attribute.
Definition attribute.h:59
Creates DeviceEnergyModel objects.
Instantiate subclasses of ns3::Object.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
void SetRechargedCallback(WifiRadioEnergyModel::WifiRadioEnergyRechargedCallback callback)
void SetDepletionCallback(WifiRadioEnergyModel::WifiRadioEnergyDepletionCallback callback)
Ptr< energy::DeviceEnergyModel > DoInstall(Ptr< NetDevice > device, Ptr< energy::EnergySource > source) const override
WifiRadioEnergyModel::WifiRadioEnergyRechargedCallback m_rechargedCallback
radio energy recharged callback
WifiRadioEnergyModelHelper()
Construct a helper which is used to add a radio energy model to a node.
WifiRadioEnergyModel::WifiRadioEnergyDepletionCallback m_depletionCallback
radio energy depletion callback
void Set(std::string name, const AttributeValue &v) override
ObjectFactory m_txCurrentModel
transmit current model
void SetTxCurrentModel(std::string name, Ts &&... args)
Callback< void > WifiRadioEnergyRechargedCallback
Callback type for energy recharged handling.
Callback< void > WifiRadioEnergyDepletionCallback
Callback type for energy depletion handling.
Every class exported by the ns3 library is enclosed in the ns3 namespace.