Files
unison/src/node/application-list.cc

85 lines
2.1 KiB
C++
Raw Normal View History

2007-03-27 21:48:22 -07:00
// -*- Mode:NS3 -*-
//
// Copyright (c) 2006 Georgia Tech Research Corporation
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation;
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Author: George F. Riley<riley@ece.gatech.edu>
//
// Implement the application list capability for NS3 nodes
// George F. Riley, Georgia Tech, Spring 2007
#include "application.h"
#include "application-list.h"
namespace ns3{
ApplicationList::ApplicationList(Node* n)
{}
void
ApplicationList::Dispose (void)
2007-03-27 21:48:22 -07:00
{
for (std::vector<Application*>::const_iterator i = m_apps.begin();
i != m_apps.end(); ++i)
{
Application *app = *i;
app->Dispose ();
app->Unref ();
}
m_apps.clear ();
2007-03-27 21:48:22 -07:00
}
ApplicationList::~ApplicationList()
{ // Destructor, nothing needed as the SmartSet destroys itself
Dispose ();
2007-03-27 21:48:22 -07:00
}
2007-05-02 15:07:33 +02:00
ApplicationList* ApplicationList::Copy(Node * n) const
2007-03-27 21:48:22 -07:00
{ // Copy this app list
2007-05-02 15:14:27 +02:00
ApplicationList* r = new ApplicationList(n);
2007-03-27 21:48:22 -07:00
return r;
}
void
ApplicationList::Add(Application* a)
{
m_apps.push_back(a);
}
2007-05-02 15:07:33 +02:00
void ApplicationList::SetNode(Node * n)
2007-03-27 21:48:22 -07:00
{
// Set the node pointer in each application
for (std::vector<Application *>::const_iterator i = m_apps.begin();
i != m_apps.end(); ++i)
2007-03-27 21:48:22 -07:00
{ // Set correct node pointer in each app
(*i)->SetNode(n);
}
}
uint32_t ApplicationList::Count() const
2007-03-27 21:48:22 -07:00
{
return m_apps.size();
2007-03-27 21:48:22 -07:00
}
Application* ApplicationList::Get(uint32_t i) const
2007-03-27 21:48:22 -07:00
{ // Get the i'th application. Note, this is linear time in N
if (m_apps.empty()) return 0; // List is empty
return m_apps[i];
2007-03-27 21:48:22 -07:00
}
}//namespace ns3