INET Framework for OMNeT++/OMNEST
inet::PositionTable Class Reference

This class provides a mapping between node addresses and their positions. More...

#include <PositionTable.h>

Public Member Functions

 PositionTable ()
 
std::vector< L3AddressgetAddresses () const
 
bool hasPosition (const L3Address &address) const
 
Coord getPosition (const L3Address &address) const
 
void setPosition (const L3Address &address, const Coord &coord)
 
void removePosition (const L3Address &address)
 
void removeOldPositions (simtime_t timestamp)
 
void clear ()
 
simtime_t getOldestPosition () const
 

Private Types

typedef std::pair< simtime_t, CoordAddressToPositionMapValue
 
typedef std::map< L3Address, AddressToPositionMapValueAddressToPositionMap
 

Private Attributes

AddressToPositionMap addressToPositionMap
 

Friends

std::ostream & operator<< (std::ostream &o, const PositionTable &t)
 

Detailed Description

This class provides a mapping between node addresses and their positions.

Member Typedef Documentation

typedef std::pair<simtime_t, Coord> inet::PositionTable::AddressToPositionMapValue
private

Constructor & Destructor Documentation

inet::PositionTable::PositionTable ( )
inline
42 {}

Member Function Documentation

void inet::PositionTable::clear ( )

Referenced by inet::GPSR::handleOperationStage(), and inet::GPSR::initialize().

70 {
71  addressToPositionMap.clear();
72 }
AddressToPositionMap addressToPositionMap
Definition: PositionTable.h:39
std::vector< L3Address > inet::PositionTable::getAddresses ( ) const

Referenced by inet::GPSR::findGreedyRoutingNextHop(), and inet::GPSR::getPlanarNeighbors().

25 {
26  std::vector<L3Address> addresses;
27  for (const auto & elem : addressToPositionMap)
28  addresses.push_back(elem.first);
29  return addresses;
30 }
AddressToPositionMap addressToPositionMap
Definition: PositionTable.h:39
simtime_t inet::PositionTable::getOldestPosition ( ) const

Referenced by inet::GPSR::getNextNeighborExpiration().

75 {
76  simtime_t oldestPosition = SimTime::getMaxTime();
77  for (const auto & elem : addressToPositionMap) {
78  const simtime_t& time = elem.second.first;
79  if (time < oldestPosition)
80  oldestPosition = time;
81  }
82  return oldestPosition;
83 }
AddressToPositionMap addressToPositionMap
Definition: PositionTable.h:39
Coord inet::PositionTable::getPosition ( const L3Address address) const

Referenced by inet::GPSR::findGreedyRoutingNextHop(), inet::GPSR::getDestinationPosition(), inet::GPSR::getNeighborPosition(), and inet::GPSR::getPlanarNeighbors().

39 {
40  AddressToPositionMap::const_iterator it = addressToPositionMap.find(address);
41  if (it == addressToPositionMap.end())
42  return Coord(NaN, NaN, NaN);
43  else
44  return it->second.second;
45 }
AddressToPositionMap addressToPositionMap
Definition: PositionTable.h:39
#define NaN
Definition: INETMath.h:103
bool inet::PositionTable::hasPosition ( const L3Address address) const
33 {
34  AddressToPositionMap::const_iterator it = addressToPositionMap.find(address);
35  return it != addressToPositionMap.end();
36 }
AddressToPositionMap addressToPositionMap
Definition: PositionTable.h:39
void inet::PositionTable::removeOldPositions ( simtime_t  timestamp)

Referenced by inet::GPSR::purgeNeighbors().

60 {
61  for (auto it = addressToPositionMap.begin(); it != addressToPositionMap.end(); )
62  if (it->second.first <= timestamp)
63  addressToPositionMap.erase(it++);
64  else
65  it++;
66 
67 }
AddressToPositionMap addressToPositionMap
Definition: PositionTable.h:39
void inet::PositionTable::removePosition ( const L3Address address)
54 {
55  auto it = addressToPositionMap.find(address);
56  addressToPositionMap.erase(it);
57 }
AddressToPositionMap addressToPositionMap
Definition: PositionTable.h:39
void inet::PositionTable::setPosition ( const L3Address address,
const Coord coord 
)

Referenced by inet::GPSR::processBeacon(), and inet::GPSR::processBeaconTimer().

48 {
49  ASSERT(!address.isUnspecified());
50  addressToPositionMap[address] = AddressToPositionMapValue(simTime(), coord);
51 }
std::pair< simtime_t, Coord > AddressToPositionMapValue
Definition: PositionTable.h:37
AddressToPositionMap addressToPositionMap
Definition: PositionTable.h:39

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const PositionTable t 
)
friend
86 {
87  o << "{ ";
88  for(auto elem : t.addressToPositionMap) {
89  o << elem.first << ":(" << elem.second.first << ";" << elem.second.second << ") ";
90  }
91  o << "}";
92  return o;
93 }

Member Data Documentation


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