INET Framework for OMNeT++/OMNEST
inet::physicallayer::VectorCommunicationCache Class Reference

#include <VectorCommunicationCache.h>

Inheritance diagram for inet::physicallayer::VectorCommunicationCache:
inet::physicallayer::CommunicationCacheBase inet::physicallayer::ICommunicationCache inet::physicallayer::IPrintableObject

Public Member Functions

 VectorCommunicationCache ()
 
virtual ~VectorCommunicationCache ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level) const override
 Prints this object to the provided output stream. More...
 
Medium state change notifications
virtual void addRadio (const IRadio *radio) override
 
virtual void removeRadio (const IRadio *radio) override
 
virtual void addTransmission (const ITransmission *transmission) override
 
virtual void removeTransmission (const ITransmission *transmission) override
 
Interference cache
virtual void removeNonInterferingTransmissions () override
 
- Public Member Functions inherited from inet::physicallayer::CommunicationCacheBase
 CommunicationCacheBase ()
 
virtual ~CommunicationCacheBase ()
 
virtual std::vector< const ITransmission * > * computeInterferingTransmissions (const IRadio *radio, const simtime_t startTime, const simtime_t endTime) override
 
virtual const simtime_t getCachedInterferenceEndTime (const ITransmission *transmission) override
 
virtual void setCachedInterferenceEndTime (const ITransmission *transmission, const simtime_t interferenceEndTime) override
 
virtual void removeCachedInterferenceEndTime (const ITransmission *transmission) override
 
virtual const IRadioFramegetCachedFrame (const ITransmission *transmission) override
 
virtual void setCachedFrame (const ITransmission *transmission, const IRadioFrame *frame) override
 
virtual void removeCachedFrame (const ITransmission *transmission) override
 
virtual const IArrivalgetCachedArrival (const IRadio *receiver, const ITransmission *transmission) override
 
virtual void setCachedArrival (const IRadio *receiver, const ITransmission *transmission, const IArrival *arrival) override
 
virtual void removeCachedArrival (const IRadio *receiver, const ITransmission *transmission) override
 
virtual const IntervalgetCachedInterval (const IRadio *receiver, const ITransmission *transmission) override
 
virtual void setCachedInterval (const IRadio *receiver, const ITransmission *transmission, const Interval *interval) override
 
virtual void removeCachedInterval (const IRadio *receiver, const ITransmission *transmission) override
 
virtual const IListeninggetCachedListening (const IRadio *receiver, const ITransmission *transmission) override
 
virtual void setCachedListening (const IRadio *receiver, const ITransmission *transmission, const IListening *listening) override
 
virtual void removeCachedListening (const IRadio *receiver, const ITransmission *transmission) override
 
virtual const IReceptiongetCachedReception (const IRadio *receiver, const ITransmission *transmission) override
 
virtual void setCachedReception (const IRadio *receiver, const ITransmission *transmission, const IReception *reception) override
 
virtual void removeCachedReception (const IRadio *receiver, const ITransmission *transmission) override
 
virtual const IInterferencegetCachedInterference (const IRadio *receiver, const ITransmission *transmission) override
 
virtual void setCachedInterference (const IRadio *receiver, const ITransmission *transmission, const IInterference *interference) override
 
virtual void removeCachedInterference (const IRadio *receiver, const ITransmission *transmission) override
 
virtual const INoisegetCachedNoise (const IRadio *receiver, const ITransmission *transmission) override
 
virtual void setCachedNoise (const IRadio *receiver, const ITransmission *transmission, const INoise *noise) override
 
virtual void removeCachedNoise (const IRadio *receiver, const ITransmission *transmission) override
 
virtual const ISNIRgetCachedSNIR (const IRadio *receiver, const ITransmission *transmission) override
 
virtual void setCachedSNIR (const IRadio *receiver, const ITransmission *transmission, const ISNIR *snir) override
 
virtual void removeCachedSNIR (const IRadio *receiver, const ITransmission *transmission) override
 
virtual const IReceptionDecisiongetCachedReceptionDecision (const IRadio *receiver, const ITransmission *transmission, IRadioSignal::SignalPart part) override
 
virtual void setCachedReceptionDecision (const IRadio *receiver, const ITransmission *transmission, IRadioSignal::SignalPart part, const IReceptionDecision *receptionDecision) override
 
virtual void removeCachedReceptionDecision (const IRadio *receiver, const ITransmission *transmission, IRadioSignal::SignalPart part) override
 
virtual const IReceptionResultgetCachedReceptionResult (const IRadio *receiver, const ITransmission *transmission) override
 
virtual void setCachedReceptionResult (const IRadio *receiver, const ITransmission *transmission, const IReceptionResult *receptionResult) override
 
virtual void removeCachedReceptionResult (const IRadio *receiver, const ITransmission *transmission) override
 
virtual const IRadioFramegetCachedFrame (const IRadio *receiver, const ITransmission *transmission) override
 
virtual void setCachedFrame (const IRadio *receiver, const ITransmission *transmission, const IRadioFrame *frame) override
 
virtual void removeCachedFrame (const IRadio *receiver, const ITransmission *transmission) override
 
Medium state change notifications
Interference cache
Transmission cache
Reception Cache
- Public Member Functions inherited from inet::physicallayer::IPrintableObject
virtual ~IPrintableObject ()
 
virtual std::string getInfoStringRepresentation () const
 
virtual std::string getDetailStringRepresentation () const
 
virtual std::string getDebugStringRepresentation () const
 
virtual std::string getTraceStringRepresentation () const
 
virtual std::string getCompleteStringRepresentation () const
 

Protected Member Functions

Cache data structures
virtual RadioCacheEntrygetRadioCacheEntry (const IRadio *radio) override
 
virtual TransmissionCacheEntrygetTransmissionCacheEntry (const ITransmission *transmission) override
 
virtual ReceptionCacheEntrygetReceptionCacheEntry (const IRadio *radio, const ITransmission *transmission) override
 
Cache data structures

Protected Attributes

Cache
int baseRadioId
 The smallest radio id of all radios on the medium. More...
 
int baseTransmissionId
 The smallest transmission id of all ongoing transmissions on the medium. More...
 
std::vector< TransmissionCacheEntrytransmissionCache
 Caches intermediate computation results for transmissions. More...
 
std::vector< RadioCacheEntryradioCache
 Caches intermediate computation results for radios. More...
 

Additional Inherited Members

- Public Types inherited from inet::physicallayer::IPrintableObject
enum  PrintLevel {
  PRINT_LEVEL_TRACE, PRINT_LEVEL_DEBUG, PRINT_LEVEL_DETAIL, PRINT_LEVEL_INFO,
  PRINT_LEVEL_COMPLETE = INT_MIN
}
 

Constructor & Destructor Documentation

inet::physicallayer::VectorCommunicationCache::VectorCommunicationCache ( )
27  :
28  baseRadioId(0),
30 {
31 }
int baseTransmissionId
The smallest transmission id of all ongoing transmissions on the medium.
Definition: VectorCommunicationCache.h:39
int baseRadioId
The smallest radio id of all radios on the medium.
Definition: VectorCommunicationCache.h:35
inet::physicallayer::VectorCommunicationCache::~VectorCommunicationCache ( )
virtual
34 {
35  for (auto &transmissionCacheEntry : transmissionCache)
36  delete static_cast<std::vector<ReceptionCacheEntry> *>(transmissionCacheEntry.receptionCacheEntries);
37 }
std::vector< TransmissionCacheEntry > transmissionCache
Caches intermediate computation results for transmissions.
Definition: VectorCommunicationCache.h:47

Member Function Documentation

void inet::physicallayer::VectorCommunicationCache::addRadio ( const IRadio radio)
overridevirtual

Implements inet::physicallayer::ICommunicationCache.

85 {
86  if (radioCache.size() == 0)
87  baseRadioId = radio->getId();
88  getRadioCacheEntry(radio);
89 }
virtual RadioCacheEntry * getRadioCacheEntry(const IRadio *radio) override
Definition: VectorCommunicationCache.cc:39
std::vector< RadioCacheEntry > radioCache
Caches intermediate computation results for radios.
Definition: VectorCommunicationCache.h:52
int baseRadioId
The smallest radio id of all radios on the medium.
Definition: VectorCommunicationCache.h:35
void inet::physicallayer::VectorCommunicationCache::addTransmission ( const ITransmission transmission)
overridevirtual

Implements inet::physicallayer::ICommunicationCache.

109 {
110  if (transmissionCache.size() == 0)
111  baseTransmissionId = transmission->getId();
112  getTransmissionCacheEntry(transmission);
113 }
int baseTransmissionId
The smallest transmission id of all ongoing transmissions on the medium.
Definition: VectorCommunicationCache.h:39
virtual TransmissionCacheEntry * getTransmissionCacheEntry(const ITransmission *transmission) override
Definition: VectorCommunicationCache.cc:51
std::vector< TransmissionCacheEntry > transmissionCache
Caches intermediate computation results for transmissions.
Definition: VectorCommunicationCache.h:47
VectorCommunicationCache::RadioCacheEntry * inet::physicallayer::VectorCommunicationCache::getRadioCacheEntry ( const IRadio radio)
overrideprotectedvirtual

Implements inet::physicallayer::CommunicationCacheBase.

Referenced by addRadio(), and removeRadio().

40 {
41  int radioIndex = radio->getId() - baseRadioId;
42  if (radioIndex < 0)
43  return nullptr;
44  else {
45  if (radioIndex >= (int)radioCache.size())
46  radioCache.resize(radioIndex + 1);
47  return &radioCache[radioIndex];
48  }
49 }
std::vector< RadioCacheEntry > radioCache
Caches intermediate computation results for radios.
Definition: VectorCommunicationCache.h:52
int baseRadioId
The smallest radio id of all radios on the medium.
Definition: VectorCommunicationCache.h:35
VectorCommunicationCache::ReceptionCacheEntry * inet::physicallayer::VectorCommunicationCache::getReceptionCacheEntry ( const IRadio radio,
const ITransmission transmission 
)
overrideprotectedvirtual

Implements inet::physicallayer::CommunicationCacheBase.

67 {
68  TransmissionCacheEntry *transmissionCacheEntry = getTransmissionCacheEntry(transmission);
69  if (transmissionCacheEntry == nullptr)
70  return nullptr;
71  else {
72  std::vector<ReceptionCacheEntry> *receptionCacheEntries = static_cast<std::vector<ReceptionCacheEntry> *>(transmissionCacheEntry->receptionCacheEntries);
73  int radioIndex = radio->getId() - baseRadioId;
74  if (radioIndex < 0)
75  return nullptr;
76  else {
77  if (radioIndex >= (int)receptionCacheEntries->size())
78  receptionCacheEntries->resize(radioIndex + 1);
79  return &(*receptionCacheEntries)[radioIndex];
80  }
81  }
82 }
virtual TransmissionCacheEntry * getTransmissionCacheEntry(const ITransmission *transmission) override
Definition: VectorCommunicationCache.cc:51
int baseRadioId
The smallest radio id of all radios on the medium.
Definition: VectorCommunicationCache.h:35
VectorCommunicationCache::TransmissionCacheEntry * inet::physicallayer::VectorCommunicationCache::getTransmissionCacheEntry ( const ITransmission transmission)
overrideprotectedvirtual

Implements inet::physicallayer::CommunicationCacheBase.

Referenced by addTransmission(), and getReceptionCacheEntry().

52 {
53  int transmissionIndex = transmission->getId() - baseTransmissionId;
54  if (transmissionIndex < 0)
55  return nullptr;
56  else {
57  if (transmissionIndex >= (int)transmissionCache.size())
58  transmissionCache.resize(transmissionIndex + 1);
59  TransmissionCacheEntry &transmissionCacheEntry = transmissionCache[transmissionIndex];
60  if (transmissionCacheEntry.receptionCacheEntries == nullptr)
61  transmissionCacheEntry.receptionCacheEntries = new std::vector<ReceptionCacheEntry>(radioCache.size());
62  return &transmissionCacheEntry;
63  }
64 }
int baseTransmissionId
The smallest transmission id of all ongoing transmissions on the medium.
Definition: VectorCommunicationCache.h:39
std::vector< RadioCacheEntry > radioCache
Caches intermediate computation results for radios.
Definition: VectorCommunicationCache.h:52
std::vector< TransmissionCacheEntry > transmissionCache
Caches intermediate computation results for transmissions.
Definition: VectorCommunicationCache.h:47
virtual std::ostream& inet::physicallayer::VectorCommunicationCache::printToStream ( std::ostream &  stream,
int  level 
) const
inlineoverridevirtual

Prints this object to the provided output stream.

Function calls to operator<< with pointers or references either const or not are all forwarded to this function.

Reimplemented from inet::physicallayer::IPrintableObject.

67 { return stream << "VectorCommunicationCache"; }
void inet::physicallayer::VectorCommunicationCache::removeNonInterferingTransmissions ( )
overridevirtual

Implements inet::physicallayer::ICommunicationCache.

120 {
121  const simtime_t now = simTime();
122  size_t transmissionIndex = 0;
123  while (transmissionIndex < transmissionCache.size() && transmissionCache[transmissionIndex].interferenceEndTime <= now)
124  transmissionIndex++;
125  for (auto it = transmissionCache.cbegin(); it != transmissionCache.cbegin() + transmissionIndex; it++) {
126  const TransmissionCacheEntry &transmissionCacheEntry = *it;
127  if (transmissionCacheEntry.receptionCacheEntries != nullptr) {
128  std::vector<ReceptionCacheEntry> *receptionCacheEntries = static_cast<std::vector<ReceptionCacheEntry> *>(transmissionCacheEntry.receptionCacheEntries);
129  auto radioIt = radioCache.cbegin();
130  auto receptionIt = receptionCacheEntries->cbegin();
131  while (radioIt != radioCache.cend() && receptionIt != receptionCacheEntries->cend()) {
132  const RadioCacheEntry &radioCacheEntry = *radioIt;
133  const ReceptionCacheEntry &recpeionCacheEntry = *receptionIt;
134  const Interval *interval = recpeionCacheEntry.interval;
135  if (interval != nullptr)
136  radioCacheEntry.receptionIntervals->deleteNode(interval);
137  radioIt++;
138  receptionIt++;
139  }
140  }
141  }
142  baseTransmissionId += transmissionIndex;
143  for (auto it = transmissionCache.cbegin(); it != transmissionCache.cbegin() + transmissionIndex; it++) {
144  const TransmissionCacheEntry &transmissionCacheEntry = *it;
145  delete static_cast<std::vector<ReceptionCacheEntry> *>(transmissionCacheEntry.receptionCacheEntries);
146  }
147  transmissionCache.erase(transmissionCache.begin(), transmissionCache.begin() + transmissionIndex);
148 }
int baseTransmissionId
The smallest transmission id of all ongoing transmissions on the medium.
Definition: VectorCommunicationCache.h:39
std::vector< RadioCacheEntry > radioCache
Caches intermediate computation results for radios.
Definition: VectorCommunicationCache.h:52
std::vector< TransmissionCacheEntry > transmissionCache
Caches intermediate computation results for transmissions.
Definition: VectorCommunicationCache.h:47
void inet::physicallayer::VectorCommunicationCache::removeRadio ( const IRadio radio)
overridevirtual

Implements inet::physicallayer::ICommunicationCache.

92 {
93  getRadioCacheEntry(radio)->stale = true;
94  int radioCount = 0;
95  while (radioCount < (int)radioCache.size() && radioCache[radioCount].stale)
96  radioCount++;
97  if (radioCount != 0) {
98  baseRadioId += radioCount;
99  radioCache.erase(radioCache.begin(), radioCache.begin() + radioCount);
100  for (auto &transmissionCacheEntry : transmissionCache) {
101  std::vector<ReceptionCacheEntry> *receptionCacheEntries = static_cast<std::vector<ReceptionCacheEntry> *>(transmissionCacheEntry.receptionCacheEntries);
102  if (receptionCacheEntries != nullptr)
103  receptionCacheEntries->erase(receptionCacheEntries->begin(), receptionCacheEntries->begin() + radioCount);
104  }
105  }
106 }
virtual RadioCacheEntry * getRadioCacheEntry(const IRadio *radio) override
Definition: VectorCommunicationCache.cc:39
std::vector< RadioCacheEntry > radioCache
Caches intermediate computation results for radios.
Definition: VectorCommunicationCache.h:52
bool stale
True means the cache entry is invalid.
Definition: CommunicationCacheBase.h:42
std::vector< TransmissionCacheEntry > transmissionCache
Caches intermediate computation results for transmissions.
Definition: VectorCommunicationCache.h:47
int baseRadioId
The smallest radio id of all radios on the medium.
Definition: VectorCommunicationCache.h:35
void inet::physicallayer::VectorCommunicationCache::removeTransmission ( const ITransmission transmission)
overridevirtual

Implements inet::physicallayer::ICommunicationCache.

116 {
117 }

Member Data Documentation

int inet::physicallayer::VectorCommunicationCache::baseRadioId
protected

The smallest radio id of all radios on the medium.

Referenced by addRadio(), getRadioCacheEntry(), getReceptionCacheEntry(), and removeRadio().

int inet::physicallayer::VectorCommunicationCache::baseTransmissionId
protected

The smallest transmission id of all ongoing transmissions on the medium.

Referenced by addTransmission(), getTransmissionCacheEntry(), and removeNonInterferingTransmissions().

std::vector<RadioCacheEntry> inet::physicallayer::VectorCommunicationCache::radioCache
protected

Caches intermediate computation results for radios.

The vector is indexed by radio id (offset with base transmission id).

Referenced by addRadio(), getRadioCacheEntry(), getTransmissionCacheEntry(), removeNonInterferingTransmissions(), and removeRadio().

std::vector<TransmissionCacheEntry> inet::physicallayer::VectorCommunicationCache::transmissionCache
protected

Caches intermediate computation results for transmissions.

The outer vector is indexed by transmission id (offset with base transmission id) and the inner vector is indexed by radio id. Values that are no longer needed are removed from the beginning only. May contain nullptr values for not yet computed information.

Referenced by addTransmission(), getTransmissionCacheEntry(), removeNonInterferingTransmissions(), removeRadio(), and ~VectorCommunicationCache().


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