add MacStations to build
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 03 Oct 2007 13:10:44 +0200
changeset 1893 d72388b06b22
parent 1892 7833628614bf
child 1894 d83a91e03101
add MacStations to build
src/devices/wifi/mac-stations.cc
src/devices/wifi/mac-stations.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/mac-stations.cc	Wed Oct 03 13:10:44 2007 +0200
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/mac-stations.h	Wed Oct 03 13:10:44 2007 +0200
@@ -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 */