INET Framework for OMNeT++/OMNEST
inet::power::EnergySinkBase Class Reference

#include <EnergySinkBase.h>

Inheritance diagram for inet::power::EnergySinkBase:
inet::power::IEnergySink inet::power::CcEnergySinkBase inet::power::EnergyStorageBase inet::power::EpEnergySinkBase inet::power::CcEnergyStorageBase inet::power::EpEnergyStorageBase inet::power::SimpleCcBattery inet::power::IdealEpEnergyStorage inet::power::SimpleEpEnergyStorage

Public Member Functions

virtual int getNumEnergyGenerators () const override
 Returns the number of energy generators in the range [0, +infinity). More...
 
virtual const IEnergyGeneratorgetEnergyGenerator (int index) const override
 Returns the energy generator for the provided index. More...
 
virtual void addEnergyGenerator (const IEnergyGenerator *energyGenerator) override
 Adds a new energy generator to the energy sink. More...
 
virtual void removeEnergyGenerator (const IEnergyGenerator *energyGenerator) override
 Removes a previously added energy generator from this energy sink. More...
 
- Public Member Functions inherited from inet::power::IEnergySink
virtual ~IEnergySink ()
 

Protected Attributes

std::vector< const IEnergyGenerator * > energyGenerators
 

Member Function Documentation

void inet::power::EnergySinkBase::addEnergyGenerator ( const IEnergyGenerator energyGenerator)
overridevirtual

Adds a new energy generator to the energy sink.

The energyGenerator parameter must not be nullptr.

Implements inet::power::IEnergySink.

Reimplemented in inet::power::CcEnergySinkBase, inet::power::CcEnergyStorageBase, inet::power::EpEnergySinkBase, and inet::power::EpEnergyStorageBase.

Referenced by inet::power::CcEnergySinkBase::addEnergyGenerator(), and inet::power::EpEnergySinkBase::addEnergyGenerator().

31 {
32  energyGenerators.push_back(energyGenerator);
33 }
std::vector< const IEnergyGenerator * > energyGenerators
Definition: EnergySinkBase.h:30
const IEnergyGenerator * inet::power::EnergySinkBase::getEnergyGenerator ( int  index) const
overridevirtual

Returns the energy generator for the provided index.

This functions throws an exception if the index is out of range, and it never returns nullptr.

Implements inet::power::IEnergySink.

26 {
27  return energyGenerators[index];
28 }
std::vector< const IEnergyGenerator * > energyGenerators
Definition: EnergySinkBase.h:30
virtual int inet::power::EnergySinkBase::getNumEnergyGenerators ( ) const
inlineoverridevirtual

Returns the number of energy generators in the range [0, +infinity).

Implements inet::power::IEnergySink.

33 { return energyGenerators.size(); }
std::vector< const IEnergyGenerator * > energyGenerators
Definition: EnergySinkBase.h:30
void inet::power::EnergySinkBase::removeEnergyGenerator ( const IEnergyGenerator energyGenerator)
overridevirtual

Removes a previously added energy generator from this energy sink.

This functions throws an exception if the generator is not found.

Implements inet::power::IEnergySink.

Reimplemented in inet::power::CcEnergySinkBase, inet::power::CcEnergyStorageBase, inet::power::EpEnergySinkBase, and inet::power::EpEnergyStorageBase.

Referenced by inet::power::CcEnergySinkBase::removeEnergyGenerator(), and inet::power::EpEnergySinkBase::removeEnergyGenerator().

36 {
37  auto it = std::find(energyGenerators.begin(), energyGenerators.end(), energyGenerator);
38  if (it == energyGenerators.end())
39  throw cRuntimeError("Energy generator not found");
40  else
41  energyGenerators.erase(it);
42 }
std::vector< const IEnergyGenerator * > energyGenerators
Definition: EnergySinkBase.h:30
std::vector< T >::iterator find(std::vector< T > &v, const T &a)
Definition: stlutils.h:48

Member Data Documentation


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