finish Dispose -> DoDispose rework

Mathieu Lacage 2007-05-03 13:24:43 +02:00
parent e89d1692e5
commit b15d1043d1
10 changed files with 20 additions and 29 deletions

View File

@ -56,8 +56,6 @@ PointToPointNetDevice::~PointToPointNetDevice()
{ {
NS_DEBUG ("PointToPointNetDevice::~PointToPointNetDevice ()"); NS_DEBUG ("PointToPointNetDevice::~PointToPointNetDevice ()");
Dispose ();
delete m_queue; delete m_queue;
m_queue = 0; m_queue = 0;
} }
@ -102,14 +100,14 @@ PointToPointNetDevice::PointToPointNetDevice (const PointToPointNetDevice& nd)
} }
void PointToPointNetDevice::Dispose() void PointToPointNetDevice::DoDispose()
{ {
if (m_channel != 0) if (m_channel != 0)
{ {
m_channel->Unref (); m_channel->Unref ();
m_channel = 0; m_channel = 0;
} }
NetDevice::Dispose (); NetDevice::DoDispose ();
} }
// //

View File

@ -96,10 +96,6 @@ public:
* This is the destructor for the PointToPointNetDevice. * This is the destructor for the PointToPointNetDevice.
*/ */
virtual ~PointToPointNetDevice(); virtual ~PointToPointNetDevice();
/**
*Dispose method for refcounting
*/
virtual void Dispose();
/** /**
* Assignment Operator for a PointToPointNetDevice * Assignment Operator for a PointToPointNetDevice
* *
@ -172,6 +168,7 @@ public:
*/ */
void Receive (Packet& p); void Receive (Packet& p);
protected: protected:
virtual void DoDispose (void);
/** /**
* Get a copy of the attached Queue. * Get a copy of the attached Queue.
* *

View File

@ -34,7 +34,7 @@ ApplicationList::ApplicationList(Node* n)
{} {}
void void
ApplicationList::Dispose (void) ApplicationList::DoDispose (void)
{ {
for (std::vector<Application*>::const_iterator i = m_apps.begin(); for (std::vector<Application*>::const_iterator i = m_apps.begin();
i != m_apps.end(); ++i) i != m_apps.end(); ++i)
@ -44,12 +44,11 @@ ApplicationList::Dispose (void)
app->Unref (); app->Unref ();
} }
m_apps.clear (); m_apps.clear ();
NsUnknown::DoDispose ();
} }
ApplicationList::~ApplicationList() ApplicationList::~ApplicationList()
{ // Destructor, nothing needed as the SmartSet destroys itself {}
Dispose ();
}
ApplicationList* ApplicationList::Copy(Node * n) const ApplicationList* ApplicationList::Copy(Node * n) const
{ // Copy this app list { // Copy this app list

View File

@ -38,7 +38,6 @@ public:
// Copy constructor not needed, default one is correct // Copy constructor not needed, default one is correct
virtual ~ApplicationList(); virtual ~ApplicationList();
// Inherited from Capabilty // Inherited from Capabilty
virtual void Dispose (void);
virtual ApplicationList* Copy(Node*) const; virtual ApplicationList* Copy(Node*) const;
virtual void SetNode(Node *); // Sets the node for all apps virtual void SetNode(Node *); // Sets the node for all apps
virtual void Add(Application*); // Add an already new'ed app virtual void Add(Application*); // Add an already new'ed app
@ -53,6 +52,8 @@ public:
uint32_t Count() const; // Number of applications uint32_t Count() const; // Number of applications
Application* Get(uint32_t i) const; // Get app by index Application* Get(uint32_t i) const; // Get app by index
protected:
virtual void DoDispose (void);
private: private:
std::vector<Application*> m_apps; std::vector<Application*> m_apps;
}; };

View File

@ -58,12 +58,10 @@ Application::Application(const Application& o)
// \brief Application Destructor // \brief Application Destructor
Application::~Application() Application::~Application()
{ {}
Dispose ();
}
void void
Application::Dispose (void) Application::DoDispose (void)
{ {
if (m_node != 0) if (m_node != 0)
{ {

View File

@ -63,8 +63,6 @@ public:
Application(const Application&); // Copy constructor Application(const Application&); // Copy constructor
Application& operator=(const Application&); // Assignment operator Application& operator=(const Application&); // Assignment operator
virtual ~Application(); virtual ~Application();
virtual void Dispose (void);
virtual Application* Copy() const = 0; // All applications must provide virtual Application* Copy() const = 0; // All applications must provide
@ -129,6 +127,7 @@ protected:
// subclasses. // subclasses.
virtual void StopApplication(); virtual void StopApplication();
virtual void DoDispose (void);
private: private:
// Helpers // Helpers
void ScheduleStart(); void ScheduleStart();

View File

@ -235,7 +235,7 @@ NetDevice::SetReceiveCallback (Callback<bool,NetDevice *,const Packet &,uint16_t
} }
void void
NetDevice::Dispose() NetDevice::DoDispose()
{} {}
}; // namespace ns3 }; // namespace ns3

View File

@ -157,8 +157,6 @@ public:
bool NeedsArp (void) const; bool NeedsArp (void) const;
void SetReceiveCallback (Callback<bool,NetDevice *,const Packet &,uint16_t> cb); void SetReceiveCallback (Callback<bool,NetDevice *,const Packet &,uint16_t> cb);
virtual void Dispose();
protected: protected:
/** /**
@ -218,6 +216,8 @@ public:
*/ */
bool ForwardUp (Packet& p); bool ForwardUp (Packet& p);
virtual void DoDispose (void);
private: private:
/** /**
* \param p packet to send * \param p packet to send

View File

@ -87,12 +87,10 @@ OnOffApplication::OnOffApplication(Node * n, const OnOffApplication& c)
} }
OnOffApplication::~OnOffApplication() OnOffApplication::~OnOffApplication()
{ {}
Dispose ();
}
void void
OnOffApplication::Dispose (void) OnOffApplication::DoDispose (void)
{ {
if (m_socket != 0) if (m_socket != 0)
{ {
@ -106,7 +104,7 @@ OnOffApplication::Dispose (void)
m_offTime = 0; m_offTime = 0;
// chain up // chain up
Application::Dispose (); Application::DoDispose ();
} }
#ifdef REMOVE_THIS #ifdef REMOVE_THIS

View File

@ -54,8 +54,6 @@ public:
virtual void StopApplication(); // Called at time specified by Stop virtual void StopApplication(); // Called at time specified by Stop
virtual OnOffApplication* Copy() const;// Make a copy of the application virtual OnOffApplication* Copy() const;// Make a copy of the application
virtual void Dispose (void);
// Event handlers // Event handlers
void StartSending(); void StartSending();
void StopSending(); void StopSending();
@ -63,6 +61,9 @@ public:
virtual void MaxBytes(uint32_t m) { m_maxBytes = m;} virtual void MaxBytes(uint32_t m) { m_maxBytes = m;}
protected:
virtual void DoDispose (void);
public: // Static methods public: // Static methods
static void DefaultRate(uint64_t r) { g_defaultRate = r;} static void DefaultRate(uint64_t r) { g_defaultRate = r;}