A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::DeviceEnergyModelContainer Class Reference

Holds a vector of ns3::DeviceEnergyModel pointers. More...

#include "device-energy-model-container.h"

+ Collaboration diagram for ns3::DeviceEnergyModelContainer:

Public Types

typedef std::vector< Ptr< DeviceEnergyModel > >::const_iterator Iterator
 Const iterator of DeviceEnergyModel container.
 

Public Member Functions

 DeviceEnergyModelContainer ()
 Creates an empty DeviceEnergyModelContainer.
 
 DeviceEnergyModelContainer (const DeviceEnergyModelContainer &a, const DeviceEnergyModelContainer &b)
 
 DeviceEnergyModelContainer (Ptr< DeviceEnergyModel > model)
 
 DeviceEnergyModelContainer (std::string modelName)
 
void Add (DeviceEnergyModelContainer container)
 
void Add (Ptr< DeviceEnergyModel > model)
 Append a single Ptr<DeviceEnergyModel> to the end of this container.
 
void Add (std::string modelName)
 Append a single Ptr<DeviceEnergyModel> referred to by its object name to the end of this container.
 
Iterator Begin () const
 Get an iterator which refers to the first DeviceEnergyModel pointer in the container.
 
void Clear ()
 Removes all elements in the container.
 
Iterator End () const
 Get an iterator which refers to the last DeviceEnergyModel pointer in the container.
 
Ptr< DeviceEnergyModelGet (uint32_t i) const
 Get the i-th Ptr<DeviceEnergyModel> stored in this container.
 
uint32_t GetN () const
 Get the number of Ptr<DeviceEnergyModel> stored in this container.
 

Private Attributes

std::vector< Ptr< DeviceEnergyModel > > m_models
 Container of Energy models.
 

Detailed Description

Holds a vector of ns3::DeviceEnergyModel pointers.

DeviceEnergyModelContainer returns a list of DeviceEnergyModel pointers installed on a node. Users can use this list to access DeviceEnergyModel objects to obtain total device energy consumption on a node easily.

See also
NetDeviceContainer

Definition at line 44 of file device-energy-model-container.h.

Member Typedef Documentation

◆ Iterator

typedef std::vector<Ptr<DeviceEnergyModel>>::const_iterator ns3::DeviceEnergyModelContainer::Iterator

Const iterator of DeviceEnergyModel container.

Definition at line 48 of file device-energy-model-container.h.

Constructor & Destructor Documentation

◆ DeviceEnergyModelContainer() [1/4]

ns3::DeviceEnergyModelContainer::DeviceEnergyModelContainer ( )

Creates an empty DeviceEnergyModelContainer.

Definition at line 32 of file device-energy-model-container.cc.

References NS_LOG_FUNCTION.

◆ DeviceEnergyModelContainer() [2/4]

ns3::DeviceEnergyModelContainer::DeviceEnergyModelContainer ( Ptr< DeviceEnergyModel model)
Parameters
modelPointer to a DeviceEnergyModel.

Creates a DeviceEnergyModelContainer with exactly one DeviceEnergyModel previously instantiated.

Definition at line 37 of file device-energy-model-container.cc.

References m_models, NS_ASSERT, and NS_LOG_FUNCTION.

◆ DeviceEnergyModelContainer() [3/4]

ns3::DeviceEnergyModelContainer::DeviceEnergyModelContainer ( std::string  modelName)
Parameters
modelNameName of DeviceEnergyModel.

Creates an DeviceEnergyModelContainer with exactly one DeviceEnergyModel previously instantiated and assigned a name using the Object name service. This DeviceEnergyModel is specified by its assigned name.

Definition at line 44 of file device-energy-model-container.cc.

References m_models, NS_ASSERT, and NS_LOG_FUNCTION.

◆ DeviceEnergyModelContainer() [4/4]

ns3::DeviceEnergyModelContainer::DeviceEnergyModelContainer ( const DeviceEnergyModelContainer a,
const DeviceEnergyModelContainer b 
)
Parameters
aA DeviceEnergyModelContainer.
bAnother DeviceEnergyModelContainer.

Creates a DeviceEnergyModelContainer by concatenating DeviceEnergyModelContainer b to DeviceEnergyModelContainer a.

Note
Can be used to concatenate 2 Ptr<DeviceEnergyModel> directly. C++ will be calling DeviceEnergyModelContainer constructor with Ptr<DeviceEnergyModel> first.

Definition at line 52 of file device-energy-model-container.cc.

References Add(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

Member Function Documentation

◆ Add() [1/3]

void ns3::DeviceEnergyModelContainer::Add ( DeviceEnergyModelContainer  container)
Parameters
containerAnother DeviceEnergyModelContainer.

Appends the contents of another DeviceEnergyModelContainer to the end of this DeviceEnergyModelContainer.

Definition at line 89 of file device-energy-model-container.cc.

References m_models, and NS_LOG_FUNCTION.

Referenced by DeviceEnergyModelContainer(), and ns3::EnergySource::AppendDeviceEnergyModel().

+ Here is the caller graph for this function:

◆ Add() [2/3]

void ns3::DeviceEnergyModelContainer::Add ( Ptr< DeviceEnergyModel model)

Append a single Ptr<DeviceEnergyModel> to the end of this container.

Parameters
modelPointer to an DeviceEnergyModel.

Definition at line 99 of file device-energy-model-container.cc.

References m_models, NS_ASSERT, and NS_LOG_FUNCTION.

◆ Add() [3/3]

void ns3::DeviceEnergyModelContainer::Add ( std::string  modelName)

Append a single Ptr<DeviceEnergyModel> referred to by its object name to the end of this container.

Parameters
modelNameName of DeviceEnergyModel object.

Definition at line 107 of file device-energy-model-container.cc.

References m_models, NS_ASSERT, and NS_LOG_FUNCTION.

◆ Begin()

DeviceEnergyModelContainer::Iterator ns3::DeviceEnergyModelContainer::Begin ( ) const

Get an iterator which refers to the first DeviceEnergyModel pointer in the container.

Returns
An iterator which refers to the first DeviceEnergyModel in container.

DeviceEnergyModels can be retrieved from the container in two ways. First, directly by an index into the container, and second, using an iterator. This method is used in the iterator method and is typically used in a for-loop to run through the DeviceEnergyModels.

for (i = container.Begin (); i != container.End (); ++i)
{
(*i)->method (); // some DeviceEnergyModel method
}
std::vector< Ptr< DeviceEnergyModel > >::const_iterator Iterator
Const iterator of DeviceEnergyModel container.

Definition at line 61 of file device-energy-model-container.cc.

References m_models, and NS_LOG_FUNCTION.

Referenced by ns3::EnergySource::CalculateTotalCurrent(), ns3::EnergySource::DisposeDeviceModels(), ns3::EnergySource::FindDeviceEnergyModels(), ns3::EnergySource::InitializeDeviceModels(), ns3::EnergySource::NotifyEnergyChanged(), ns3::EnergySource::NotifyEnergyDrained(), and ns3::EnergySource::NotifyEnergyRecharged().

+ Here is the caller graph for this function:

◆ Clear()

void ns3::DeviceEnergyModelContainer::Clear ( )

Removes all elements in the container.

Definition at line 116 of file device-energy-model-container.cc.

References m_models, and NS_LOG_FUNCTION.

Referenced by ns3::EnergySource::BreakDeviceEnergyModelRefCycle().

+ Here is the caller graph for this function:

◆ End()

DeviceEnergyModelContainer::Iterator ns3::DeviceEnergyModelContainer::End ( ) const

Get an iterator which refers to the last DeviceEnergyModel pointer in the container.

Returns
An iterator which refers to the last DeviceEnergyModel in container.

DeviceEnergyModels can be retrieved from the container in two ways. First, directly by an index into the container, and second, using an iterator. This method is used in the iterator method and is typically used in a for-loop to run through the DeviceEnergyModels.

for (i = container.Begin (); i != container.End (); ++i)
{
(*i)->method (); // some DeviceEnergyModel method
}

Definition at line 68 of file device-energy-model-container.cc.

References m_models, and NS_LOG_FUNCTION.

Referenced by ns3::EnergySource::CalculateTotalCurrent(), ns3::EnergySource::DisposeDeviceModels(), ns3::EnergySource::FindDeviceEnergyModels(), ns3::EnergySource::InitializeDeviceModels(), ns3::EnergySource::NotifyEnergyChanged(), ns3::EnergySource::NotifyEnergyDrained(), and ns3::EnergySource::NotifyEnergyRecharged().

+ Here is the caller graph for this function:

◆ Get()

Ptr< DeviceEnergyModel > ns3::DeviceEnergyModelContainer::Get ( uint32_t  i) const

Get the i-th Ptr<DeviceEnergyModel> stored in this container.

Parameters
iIndex of the requested Ptr<DeviceEnergyModel>.
Returns
The requested Ptr<DeviceEnergyModel>.

Definition at line 82 of file device-energy-model-container.cc.

References m_models, and NS_LOG_FUNCTION.

Referenced by AcousticModemEnergyTestCase::DoRun(), BasicEnergyUpdateTest::StateSwitchTest(), and BatteryLifetimeTest::VariableLoadTest().

+ Here is the caller graph for this function:

◆ GetN()

uint32_t ns3::DeviceEnergyModelContainer::GetN ( ) const

Get the number of Ptr<DeviceEnergyModel> stored in this container.

Returns
The number of Ptr<DeviceEnergyModel> stored in this container.

Definition at line 75 of file device-energy-model-container.cc.

References m_models, and NS_LOG_FUNCTION.

Referenced by BasicEnergyUpdateTest::StateSwitchTest().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_models

std::vector<Ptr<DeviceEnergyModel> > ns3::DeviceEnergyModelContainer::m_models
private

Container of Energy models.

Definition at line 173 of file device-energy-model-container.h.

Referenced by DeviceEnergyModelContainer(), Add(), Begin(), Clear(), End(), Get(), and GetN().


The documentation for this class was generated from the following files: