Move API for socket factory to a Socket::CreateSocket () factory method

This commit is contained in:
Tom Henderson
2008-05-12 06:39:00 -07:00
parent 3ebec1046c
commit a042d0bbef
11 changed files with 38 additions and 27 deletions

View File

@@ -22,7 +22,9 @@
#include "ns3/log.h"
#include "ns3/packet.h"
#include "node.h"
#include "socket.h"
#include "socket-factory.h"
NS_LOG_COMPONENT_DEFINE ("Socket");
@@ -83,6 +85,16 @@ Socket::~Socket ()
NS_LOG_FUNCTION_NOARGS ();
}
Ptr<Socket>
Socket::CreateSocket (Ptr<Node> node, TypeId tid)
{
Ptr<Socket> s;
Ptr<SocketFactory> socketFactory = node->GetObject<SocketFactory> (tid);
s = socketFactory->CreateSocket ();
NS_ASSERT (s != 0);
return s;
}
void
Socket::SetCloseCallback (Callback<void,Ptr<Socket> > closeCompleted)
{

View File

@@ -98,6 +98,17 @@ public:
SOCKET_ERRNO_LAST
};
/**
* This method wraps the creation of sockets that is performed
* by a socket factory on a given node based on a TypeId.
*
* \return A smart pointer to a newly created socket.
*
* \param node The node on which to create the socket
* \param tid The TypeId of the socket to create
*/
static Ptr<Socket> CreateSocket (Ptr<Node> node, TypeId tid);
/**
* \return the errno associated to the last call which failed in this
* socket. Each socket's errno is initialized to zero