add MacStations to build

This commit is contained in:
Mathieu Lacage
2007-10-03 13:10:44 +02:00
parent 9e055bd52f
commit 855ccbf300
2 changed files with 102 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2005,2006 INRIA
* 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "mac-stations.h"
#include "mac-station.h"
namespace ns3 {
MacStations::MacStations ()
{}
MacStations::~MacStations ()
{
for (StationsI i = m_stations.begin (); i != m_stations.end (); i++)
{
delete (*i).second;
}
m_stations.erase (m_stations.begin (), m_stations.end ());
}
MacStation *
MacStations::Lookup (Mac48Address address)
{
for (StationsI i = m_stations.begin (); i != m_stations.end (); i++)
{
if ((*i).first == address)
{
return (*i).second;
}
}
MacStation *station = CreateStation ();
m_stations.push_back (std::make_pair (address, station));
return station;
}
}; // namespace ns3

View File

@@ -0,0 +1,48 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2005,2006 INRIA
* 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#ifndef MAC_STATIONS_H
#define MAC_STATIONS_H
#include <list>
#include <utility>
#include "ns3/mac48-address.h"
namespace ns3 {
class MacStation;
class MacStations {
public:
MacStations ();
virtual ~MacStations ();
MacStation *Lookup (Mac48Address address);
private:
typedef std::list <std::pair<Mac48Address, MacStation *> > Stations;
typedef std::list <std::pair<Mac48Address, MacStation *> >::iterator StationsI;
virtual class MacStation *CreateStation (void) = 0;
Stations m_stations;
};
}; // namespace ns3
#endif /* MAC_STATIONS_H */