use Ptr<> everywhere Object or NsUnknown are used

This commit is contained in:
Mathieu Lacage committed 2007-05-10 20:19:26 +02:00
1 parent 7102517ca9
commit e70e445975
53 files changed
+379 -518

No files matched your search

+2 -1
View File
@@ -25,6 +25,7 @@
#include <string>
#include <stdint.h>
#include "ns3/object.h"
#include "ns3/ptr.h"
namespace ns3 {
@@ -57,7 +58,7 @@ public:
*
* This method must be implemented by subclasses.
*/
virtual NetDevice *GetDevice (uint32_t i) const = 0;
virtual Ptr<NetDevice> GetDevice (uint32_t i) const = 0;
protected:
virtual ~Channel ();
+1 -1
View File
@@ -116,7 +116,7 @@ public:
* to disable it, you can invoke Ipv4Interface::SetDown which will
* make sure that it is never used during packet forwarding.
*/
virtual uint32_t AddInterface (NetDevice *device) = 0;
virtual uint32_t AddInterface (Ptr<NetDevice> device) = 0;
/**
* \returns the number of interfaces added by the user.
*/
+2 -1
View File
@@ -22,6 +22,7 @@
#define I_UDP_H
#include "ns3/ns-unknown.h"
#include "ns3/ptr.h"
namespace ns3 {
@@ -34,7 +35,7 @@ public:
IUdp ();
virtual Socket *CreateSocket (void) = 0;
virtual Ptr<Socket> CreateSocket (void) = 0;
};
} // namespace ns3
+2 -2
View File
@@ -183,7 +183,7 @@ NetDevice::CreateTraceResolver (TraceContext const &context)
return DoCreateTraceResolver (context);
}
Channel *
Ptr<Channel>
NetDevice::GetChannel (void) const
{
return DoGetChannel ();
@@ -236,7 +236,7 @@ NetDevice::NeedsArp (void) const
}
void
NetDevice::SetReceiveCallback (Callback<bool,NetDevice *,const Packet &,uint16_t> cb)
NetDevice::SetReceiveCallback (Callback<bool,Ptr<NetDevice>,const Packet &,uint16_t> cb)
{
m_receiveCallback = cb;
}
+4 -4
View File
@@ -79,7 +79,7 @@ public:
* returned can be zero if the NetDevice is not yet connected
* to any channel.
*/
Channel *GetChannel (void) const;
Ptr<Channel> GetChannel (void) const;
/**
* \return the current MacAddress of this interface.
@@ -174,7 +174,7 @@ public:
bool NeedsArp (void) const;
void SetReceiveCallback (Callback<bool,NetDevice *,const Packet &,uint16_t> cb);
void SetReceiveCallback (Callback<bool,Ptr<NetDevice>,const Packet &,uint16_t> cb);
protected:
/**
@@ -241,7 +241,7 @@ public:
virtual bool SendTo (Packet& p, const MacAddress& dest) = 0;
virtual bool DoNeedsArp (void) const = 0;
virtual TraceResolver *DoCreateTraceResolver (TraceContext const &context) = 0;
virtual Channel *DoGetChannel (void) const = 0;
virtual Ptr<Channel> DoGetChannel (void) const = 0;
Ptr<Node> m_node;
std::string m_name;
uint16_t m_ifIndex;
@@ -253,7 +253,7 @@ public:
bool m_isMulticast;
bool m_isPointToPoint;
Callback<void> m_linkChangeCallback;
Callback<bool,NetDevice *,const Packet &,uint16_t> m_receiveCallback;
Callback<bool,Ptr<NetDevice>,const Packet &,uint16_t> m_receiveCallback;
};
}; // namespace ns3
+5 -6
View File
@@ -69,16 +69,15 @@ Node::SetSystemId(uint32_t s )
}
uint32_t
Node::AddDevice (NetDevice *device)
Node::AddDevice (Ptr<NetDevice> device)
{
device->Ref ();
uint32_t index = m_devices.size ();
m_devices.push_back (device);
DoAddDevice (device);
device->SetIfIndex(index);
return index;
}
NetDevice *
Ptr<NetDevice>
Node::GetDevice (uint32_t index) const
{
return m_devices[index];
@@ -91,12 +90,12 @@ Node::GetNDevices (void) const
void Node::DoDispose()
{
for (std::vector<NetDevice *>::iterator i = m_devices.begin ();
for (std::vector<Ptr<NetDevice> >::iterator i = m_devices.begin ();
i != m_devices.end (); i++)
{
NetDevice *device = *i;
Ptr<NetDevice> device = *i;
device->Dispose ();
device->Unref ();
*i = 0;
}
m_devices.clear ();
NsUnknown::DoDispose ();
+4 -4
View File
@@ -50,18 +50,18 @@ public:
uint32_t GetSystemId (void) const;
void SetSystemId(uint32_t s);
uint32_t AddDevice (NetDevice *device);
NetDevice *GetDevice (uint32_t index) const;
uint32_t AddDevice (Ptr<NetDevice> device);
Ptr<NetDevice> GetDevice (uint32_t index) const;
uint32_t GetNDevices (void) const;
protected:
virtual void DoDispose (void);
private:
virtual void DoAddDevice (NetDevice *device) const = 0;
virtual void DoAddDevice (Ptr<NetDevice> device) const = 0;
uint32_t m_id; // Node id for this node
uint32_t m_sid; // System id for this node
std::vector<NetDevice *> m_devices;
std::vector<Ptr<NetDevice> > m_devices;
};
} //namespace ns3
+17 -17
View File
@@ -6,7 +6,7 @@ Socket::~Socket ()
{}
void
Socket::Close(Callback<void, Socket*> closeCompleted)
Socket::Close(Callback<void, Ptr<Socket> > closeCompleted)
{
DoClose (closeCompleted);
}
@@ -14,23 +14,23 @@ Socket::Close(Callback<void, Socket*> closeCompleted)
void
Socket::Connect(const Ipv4Address & address,
uint16_t portNumber,
Callback<void, Socket*> connectionSucceeded,
Callback<void, Socket*> connectionFailed,
Callback<void, Socket*> halfClose)
Callback<void, Ptr<Socket> > connectionSucceeded,
Callback<void, Ptr<Socket> > connectionFailed,
Callback<void, Ptr<Socket> > halfClose)
{
DoConnect (address, portNumber, connectionSucceeded, connectionFailed, halfClose);
}
int
Socket::Accept(Callback<bool, Socket*, const Ipv4Address&, uint16_t> connectionRequest,
Callback<void, Socket*, const Ipv4Address&, uint16_t> newConnectionCreated,
Callback<void, Socket*> closeRequested)
Socket::Accept(Callback<bool, Ptr<Socket>, const Ipv4Address&, uint16_t> connectionRequest,
Callback<void, Ptr<Socket>, const Ipv4Address&, uint16_t> newConnectionCreated,
Callback<void, Ptr<Socket> > closeRequested)
{
return DoAccept (connectionRequest, newConnectionCreated, closeRequested);
}
int
Socket::Send (const uint8_t* buffer,
uint32_t size,
Callback<void, Socket*, uint32_t> dataSent)
Callback<void, Ptr<Socket>, uint32_t> dataSent)
{
return DoSend (buffer, size, dataSent);
}
@@ -39,42 +39,42 @@ Socket::SendTo(const Ipv4Address &address,
uint16_t port,
const uint8_t *buffer,
uint32_t size,
Callback<void, Socket*, uint32_t> dataSent)
Callback<void, Ptr<Socket>, uint32_t> dataSent)
{
return DoSendTo (address, port, buffer, size, dataSent);
}
void
Socket::Recv(Callback<void, Socket*, const uint8_t*, uint32_t,const Ipv4Address&, uint16_t> callback)
Socket::Recv(Callback<void, Ptr<Socket>, const uint8_t*, uint32_t,const Ipv4Address&, uint16_t> callback)
{
DoRecv (callback);
}
void
Socket::RecvDummy(Callback<void, Socket*, uint32_t,const Ipv4Address&, uint16_t> callback)
Socket::RecvDummy(Callback<void, Ptr<Socket>, uint32_t,const Ipv4Address&, uint16_t> callback)
{
DoRecvDummy (callback);
}
bool
Socket::RefuseAllConnections (Socket* socket, const Ipv4Address& address, uint16_t port)
Socket::RefuseAllConnections (Ptr<Socket> socket, const Ipv4Address& address, uint16_t port)
{
return false;
}
void
Socket::DummyCallbackVoidSocket (Socket *socket)
Socket::DummyCallbackVoidSocket (Ptr<Socket> socket)
{}
void
Socket::DummyCallbackVoidSocketUi32 (Socket *socket, uint32_t)
Socket::DummyCallbackVoidSocketUi32 (Ptr<Socket> socket, uint32_t)
{}
void
Socket::DummyCallbackVoidSocketUi32Ipv4AddressUi16 (Socket *socket, uint32_t, const Ipv4Address &, uint16_t)
Socket::DummyCallbackVoidSocketUi32Ipv4AddressUi16 (Ptr<Socket> socket, uint32_t, const Ipv4Address &, uint16_t)
{}
void
Socket::DummyCallbackVoidSocketBufferUi32Ipv4AddressUi16 (Socket *socket, const uint8_t *, uint32_t,
Socket::DummyCallbackVoidSocketBufferUi32Ipv4AddressUi16 (Ptr<Socket> socket, const uint8_t *, uint32_t,
const Ipv4Address &, uint16_t)
{}
void
Socket::DummyCallbackVoidSocketIpv4AddressUi16 (Socket *socket, const Ipv4Address &, uint16_t)
Socket::DummyCallbackVoidSocketIpv4AddressUi16 (Ptr<Socket> socket, const Ipv4Address &, uint16_t)
{}
+28 -28
View File
@@ -114,7 +114,7 @@ public:
* After the Close call, the socket is no longer valid, and cannot
* safely be used for subsequent operations.
*/
void Close(Callback<void, Socket*> closeCompleted = MakeCallback (&Socket::DummyCallbackVoidSocket));
void Close(Callback<void, Ptr<Socket> > closeCompleted = MakeCallback (&Socket::DummyCallbackVoidSocket));
/**
* \returns zero on success, -1 on failure.
@@ -147,9 +147,9 @@ public:
*/
void Connect(const Ipv4Address & address,
uint16_t portNumber,
Callback<void, Socket*> connectionSucceeded = MakeCallback(&Socket::DummyCallbackVoidSocket),
Callback<void, Socket*> connectionFailed = MakeCallback(&Socket::DummyCallbackVoidSocket),
Callback<void, Socket*> halfClose = MakeCallback(&Socket::DummyCallbackVoidSocket));
Callback<void, Ptr<Socket> > connectionSucceeded = MakeCallback(&Socket::DummyCallbackVoidSocket),
Callback<void, Ptr<Socket> > connectionFailed = MakeCallback(&Socket::DummyCallbackVoidSocket),
Callback<void, Ptr<Socket> > halfClose = MakeCallback(&Socket::DummyCallbackVoidSocket));
/**
* \brief Accept connection requests from remote hosts
@@ -170,11 +170,11 @@ public:
* \param closeRequested Callback for connection close request from peer.
* XXX: when is this callback invoked ?
*/
int Accept(Callback<bool, Socket*, const Ipv4Address&, uint16_t> connectionRequest =
int Accept(Callback<bool, Ptr<Socket>, const Ipv4Address&, uint16_t> connectionRequest =
MakeCallback(&Socket::RefuseAllConnections),
Callback<void, Socket*, const Ipv4Address&, uint16_t> newConnectionCreated =
Callback<void, Ptr<Socket>, const Ipv4Address&, uint16_t> newConnectionCreated =
MakeCallback (&Socket::DummyCallbackVoidSocketIpv4AddressUi16),
Callback<void, Socket*> closeRequested = MakeCallback (&Socket::DummyCallbackVoidSocket));
Callback<void, Ptr<Socket> > closeRequested = MakeCallback (&Socket::DummyCallbackVoidSocket));
/**
* \brief Send data (or dummy data) to the remote host
@@ -186,7 +186,7 @@ public:
*/
int Send (const uint8_t* buffer,
uint32_t size,
Callback<void, Socket*, uint32_t> dataSent = MakeCallback (&Socket::DummyCallbackVoidSocketUi32));
Callback<void, Ptr<Socket>, uint32_t> dataSent = MakeCallback (&Socket::DummyCallbackVoidSocketUi32));
/**
* \brief Send data to a specified peer.
@@ -202,7 +202,7 @@ public:
uint16_t port,
const uint8_t *buffer,
uint32_t size,
Callback<void, Socket*, uint32_t> dataSent = MakeCallback (&Socket::DummyCallbackVoidSocketUi32));
Callback<void, Ptr<Socket>, uint32_t> dataSent = MakeCallback (&Socket::DummyCallbackVoidSocketUi32));
/**
* \brief Receive data
@@ -213,7 +213,7 @@ public:
* allocation to hold the dummy memory into a buffer which can be passed
* to the user. Instead, consider using the RecvDummy method.
*/
void Recv(Callback<void, Socket*, const uint8_t*, uint32_t,const Ipv4Address&, uint16_t> =
void Recv(Callback<void, Ptr<Socket>, const uint8_t*, uint32_t,const Ipv4Address&, uint16_t> =
MakeCallback (&Socket::DummyCallbackVoidSocketBufferUi32Ipv4AddressUi16));
/**
@@ -223,38 +223,38 @@ public:
* This method is included because it is vastly more efficient than the
* Recv method when you use dummy payload.
*/
void RecvDummy(Callback<void, Socket*, uint32_t,const Ipv4Address&, uint16_t> =
void RecvDummy(Callback<void, Ptr<Socket>, uint32_t,const Ipv4Address&, uint16_t> =
MakeCallback (&Socket::DummyCallbackVoidSocketUi32Ipv4AddressUi16));
private:
virtual void DoClose(Callback<void, Socket*> closeCompleted) = 0;
virtual void DoClose(Callback<void, Ptr<Socket> > closeCompleted) = 0;
virtual void DoConnect(const Ipv4Address & address,
uint16_t portNumber,
Callback<void, Socket*> connectionSucceeded,
Callback<void, Socket*> connectionFailed,
Callback<void, Socket*> halfClose) = 0;
virtual int DoAccept(Callback<bool, Socket*, const Ipv4Address&, uint16_t> connectionRequest,
Callback<void, Socket*, const Ipv4Address&, uint16_t> newConnectionCreated,
Callback<void, Socket*> closeRequested) = 0;
Callback<void, Ptr<Socket> > connectionSucceeded,
Callback<void, Ptr<Socket> > connectionFailed,
Callback<void, Ptr<Socket> > halfClose) = 0;
virtual int DoAccept(Callback<bool, Ptr<Socket>, const Ipv4Address&, uint16_t> connectionRequest,
Callback<void, Ptr<Socket>, const Ipv4Address&, uint16_t> newConnectionCreated,
Callback<void, Ptr<Socket> > closeRequested) = 0;
virtual int DoSend (const uint8_t* buffer,
uint32_t size,
Callback<void, Socket*, uint32_t> dataSent) = 0;
Callback<void, Ptr<Socket>, uint32_t> dataSent) = 0;
virtual int DoSendTo(const Ipv4Address &address,
uint16_t port,
const uint8_t *buffer,
uint32_t size,
Callback<void, Socket*, uint32_t> dataSent) = 0;
virtual void DoRecv(Callback<void, Socket*, const uint8_t*, uint32_t,const Ipv4Address&, uint16_t> receive) = 0;
virtual void DoRecvDummy(Callback<void, Socket*, uint32_t,const Ipv4Address&, uint16_t>) = 0;
Callback<void, Ptr<Socket>, uint32_t> dataSent) = 0;
virtual void DoRecv(Callback<void, Ptr<Socket>, const uint8_t*, uint32_t,const Ipv4Address&, uint16_t> receive) = 0;
virtual void DoRecvDummy(Callback<void, Ptr<Socket>, uint32_t,const Ipv4Address&, uint16_t>) = 0;
static bool RefuseAllConnections (Socket* socket, const Ipv4Address& address, uint16_t port);
static void DummyCallbackVoidSocket (Socket *socket);
static void DummyCallbackVoidSocketUi32 (Socket *socket, uint32_t);
static void DummyCallbackVoidSocketUi32Ipv4AddressUi16 (Socket *socket, uint32_t, const Ipv4Address &, uint16_t);
static void DummyCallbackVoidSocketBufferUi32Ipv4AddressUi16 (Socket *socket, const uint8_t *, uint32_t,
static bool RefuseAllConnections (Ptr<Socket> socket, const Ipv4Address& address, uint16_t port);
static void DummyCallbackVoidSocket (Ptr<Socket> socket);
static void DummyCallbackVoidSocketUi32 (Ptr<Socket> socket, uint32_t);
static void DummyCallbackVoidSocketUi32Ipv4AddressUi16 (Ptr<Socket> socket, uint32_t, const Ipv4Address &, uint16_t);
static void DummyCallbackVoidSocketBufferUi32Ipv4AddressUi16 (Ptr<Socket> socket, const uint8_t *, uint32_t,
const Ipv4Address &, uint16_t);
static void DummyCallbackVoidSocketIpv4AddressUi16 (Socket *socket, const Ipv4Address &, uint16_t);
static void DummyCallbackVoidSocketIpv4AddressUi16 (Ptr<Socket> socket, const Ipv4Address &, uint16_t);
};
} //namespace ns3