Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TCPSocketMap Class Reference

#include <TCPSocketMap.h>

List of all members.


Detailed Description

Small utility class for managing a large number of TCPSocket objects.


Public Member Functions

 TCPSocketMap ()
 ~TCPSocketMap ()
TCPSocketfindSocketFor (cMessage *msg)
void addSocket (TCPSocket *socket)
TCPSocketremoveSocket (TCPSocket *socket)
unsigned int size ()
void deleteSockets ()

Protected Types

typedef std::map< int, TCPSocket * > SocketMap

Protected Attributes

SocketMap socketMap


Member Typedef Documentation

typedef std::map<int,TCPSocket*> TCPSocketMap::SocketMap [protected]
 


Constructor & Destructor Documentation

TCPSocketMap::TCPSocketMap  )  [inline]
 

Constructor.

00042 {}

TCPSocketMap::~TCPSocketMap  )  [inline]
 

Destructor. Does NOT delete the TCPSocket objects.

00047 {}


Member Function Documentation

void TCPSocketMap::addSocket TCPSocket socket  ) 
 

Registers the given socket. Should not be called multiple times for one socket object.

00035 {
00036     ASSERT(socketMap.find(socket->connectionId())==socketMap.end());
00037     socketMap[socket->connectionId()] = socket;
00038 }

void TCPSocketMap::deleteSockets  ) 
 

Deletes the socket objects.

00049 {
00050     for (SocketMap::iterator i=socketMap.begin(); i!=socketMap.end(); ++i)
00051        delete i->second;
00052 }

TCPSocket * TCPSocketMap::findSocketFor cMessage *  msg  ) 
 

Finds the socket (by connId) for the given message. The message must have arrived from TCP, and must contain a TCPCommand control info object. The method returns NULL if the socket was not found, and throws an error if the message doesn't contain a TCPCommand.

00024 {
00025     TCPCommand *ind = dynamic_cast<TCPCommand *>(msg->controlInfo());
00026     if (!ind)
00027         opp_error("TCPSocketMap: findSocketFor(): no TCPCommand control info in message (not from TCP?)");
00028     int connId = ind->connId();
00029     SocketMap::iterator i = socketMap.find(connId);
00030     ASSERT(i==socketMap.end() || i->first==i->second->connectionId());
00031     return (i==socketMap.end()) ? NULL : i->second;
00032 }

TCPSocket * TCPSocketMap::removeSocket TCPSocket socket  ) 
 

Removes the given socket from the data structure.

00041 {
00042     SocketMap::iterator i = socketMap.find(socket->connectionId());
00043     if (i!=socketMap.end())
00044         socketMap.erase(i);
00045     return socket;
00046 }

unsigned int TCPSocketMap::size  )  [inline]
 

Returns the number of sockets stored.

00072 {return socketMap.size();}


Member Data Documentation

SocketMap TCPSocketMap::socketMap [protected]
 


The documentation for this class was generated from the following files:
Generated on Sat Apr 1 20:52:25 2006 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.1