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

#include <Ieee8021qSocketTable.h>

Inheritance diagram for inet::Ieee8021qSocketTable:

Classes

struct  Socket
 

Public Member Functions

virtual ~Ieee8021qSocketTable ()
 
virtual void addSocket (int socketId, const Protocol *protocol, int vlanId, bool steal)
 
virtual void removeSocket (int socketId)
 
virtual std::vector< Socket * > findSockets (const Protocol *protocol, int vlanId) const
 

Protected Member Functions

virtual void initialize (int stage) override
 

Protected Attributes

std::map< int, Socket * > socketIdToSocketMap
 

Constructor & Destructor Documentation

◆ ~Ieee8021qSocketTable()

inet::Ieee8021qSocketTable::~Ieee8021qSocketTable ( )
virtual
29 {
30  for (auto it : socketIdToSocketMap)
31  delete it.second;
32 }

Member Function Documentation

◆ addSocket()

void inet::Ieee8021qSocketTable::addSocket ( int  socketId,
const Protocol protocol,
int  vlanId,
bool  steal 
)
virtual
35 {
36  if (containsKey(socketIdToSocketMap, socketId))
37  throw cRuntimeError("Socket already added");
38  Socket *socket = new Socket(socketId);
39  socket->protocol = protocol;
40  socket->vlanId = vlanId;
41  socket->steal = steal;
42  socketIdToSocketMap[socketId] = socket;
43 }

◆ findSockets()

std::vector< Ieee8021qSocketTable::Socket * > inet::Ieee8021qSocketTable::findSockets ( const Protocol protocol,
int  vlanId 
) const
virtual
57 {
58  std::vector<Ieee8021qSocketTable::Socket *> result;
59  for (auto& it : socketIdToSocketMap) {
60  auto socket = it.second;
61  if (socket->protocol != nullptr && protocol != socket->protocol)
62  continue;
63  if (socket->vlanId != -1 && vlanId != socket->vlanId)
64  continue;
65  result.push_back(socket);
66  }
67  return result;
68 }

◆ initialize()

void inet::Ieee8021qSocketTable::initialize ( int  stage)
overrideprotectedvirtual
23 {
24  if (stage == INITSTAGE_LOCAL)
25  WATCH_PTRMAP(socketIdToSocketMap);
26 }

◆ removeSocket()

void inet::Ieee8021qSocketTable::removeSocket ( int  socketId)
virtual
46 {
47  auto it = socketIdToSocketMap.find(socketId);
48  if (it != socketIdToSocketMap.end()) {
49  delete it->second;
50  socketIdToSocketMap.erase(it);
51  }
52  else
53  throw cRuntimeError("Socket not found");
54 }

Member Data Documentation

◆ socketIdToSocketMap

std::map<int, Socket *> inet::Ieee8021qSocketTable::socketIdToSocketMap
protected

The documentation for this class was generated from the following files:
protocol
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::Ieee8021qSocketTable::socketIdToSocketMap
std::map< int, Socket * > socketIdToSocketMap
Definition: Ieee8021qSocketTable.h:30
inet::containsKey
bool containsKey(const std::map< K, V, _C > &m, const Tk &a)
Definition: stlutils.h:80