Separated Topology into separate module
authorRichard Whitehouse <github@richardwhiuk.com>
Mon, 14 Mar 2011 13:30:27 +0000 (13:30 +0000)
committerRichard Whitehouse <github@richardwhiuk.com>
Mon, 14 Mar 2011 13:30:27 +0000 (13:30 +0000)
code/src/helper/moose-helper.h
code/src/topology/model/topology.cc [new file with mode: 0644]
code/src/topology/model/topology.h [new file with mode: 0644]
code/src/topology/wscript [new file with mode: 0644]
code/src/wscript

index cb520178eb283f230838b8245e328be666976f85..2b26d70fa60d4cd679d1eba6db1a90e4af9cf010 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef MOOSE_HELPER_H
 #define MOOSE_HELPER_H
 
+#include "ns3/topology.h"
 #include "ns3/node.h"
 #include "ns3/moose-bridge-net-device.h"
 #include "ns3/moose-bridge-helper.h"
@@ -52,41 +53,6 @@ public:
        typedef boost::graph_traits< graph_t >::vertex_descriptor vertex_descriptor;
        typedef boost::graph_traits< graph_t >::edge_descriptor edge_descriptor;
        
-       struct Topology {
-       
-       public:
-               long bridges;
-               long hosts;
-               typedef std::map<long,long> HostLinks;
-               typedef std::pair<long,long> BridgeLink;
-
-               struct BridgeLinkCompare {
-                       // we don't care about ordering inside a pair, but we do care about pair order
-
-                       bool operator()( BridgeLink const &lhs, BridgeLink const &rhs) {
-                               if(lhs.first < lhs.first){
-                                       if(rhs.first < rhs.second){
-                                               return (lhs.first < rhs.first) ? true : (lhs.second < rhs.second);
-                                       } else {
-                                               return (lhs.first < rhs.second) ? true : (lhs.second < rhs.first);
-                                       }
-                               } else {
-                                       if(rhs.first < rhs.second){
-                                               return (lhs.second < rhs.first) ? true : (lhs.first < rhs.second);
-                                       } else {
-                                               return (lhs.second < rhs.second) ? true : (lhs.first < rhs.first);
-                                       }
-                               }
-                       }
-               };
-       
-               typedef std::set<BridgeLink, BridgeLinkCompare> BridgeLinks;
-
-               HostLinks hostLinks;
-               BridgeLinks bridgeLinks;
-
-       };
-
        struct Network {
                
                Topology t;
diff --git a/code/src/topology/model/topology.cc b/code/src/topology/model/topology.cc
new file mode 100644 (file)
index 0000000..09941a0
--- /dev/null
@@ -0,0 +1,45 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008,2009 IITP RAS
+ *
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ */
+
+#include "topology.h"
+#include "ns3/log.h"
+
+NS_LOG_COMPONENT_DEFINE ("MooseHelper");
+
+namespace ns3 {
+
+bool Topology::BridgeLinkCompare::operator()( BridgeLink const &lhs, BridgeLink const &rhs) {
+       if(lhs.first < lhs.first){
+               if(rhs.first < rhs.second){
+                       return (lhs.first < rhs.first) ? true : (lhs.second < rhs.second);
+               } else {
+                       return (lhs.first < rhs.second) ? true : (lhs.second < rhs.first);
+               }
+       } else {
+               if(rhs.first < rhs.second){
+                       return (lhs.second < rhs.first) ? true : (lhs.first < rhs.second);
+               } else {
+                       return (lhs.second < rhs.second) ? true : (lhs.first < rhs.first);
+               }
+       }
+}
+
+
+}
diff --git a/code/src/topology/model/topology.h b/code/src/topology/model/topology.h
new file mode 100644 (file)
index 0000000..af65141
--- /dev/null
@@ -0,0 +1,60 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008,2009 IITP RAS
+ *
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ */
+
+#ifndef TOPOLOGY_H
+#define TOPOLOGY_H
+
+#include <map>
+#include <set>
+
+namespace ns3 {
+
+/** 
+ * \ingroup topology
+ * 
+ * \brief Represents a topology
+ */
+
+struct Topology {
+       
+public:
+       long bridges;
+       long hosts;
+       typedef std::map<long,long> HostLinks;
+       typedef std::pair<long,long> BridgeLink;
+
+       struct BridgeLinkCompare {
+               // we don't care about ordering inside a pair, but we do care about pair order
+
+               bool operator()( BridgeLink const &lhs, BridgeLink const &rhs);
+
+       };
+       
+       typedef std::set<BridgeLink, BridgeLinkCompare> BridgeLinks;
+
+       HostLinks hostLinks;
+       BridgeLinks bridgeLinks;
+
+};
+
+}
+
+#endif
+
diff --git a/code/src/topology/wscript b/code/src/topology/wscript
new file mode 100644 (file)
index 0000000..5ebd5a7
--- /dev/null
@@ -0,0 +1,13 @@
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+def build(bld):
+    obj = bld.create_ns3_module('topology', ['node'])
+    obj.source = [
+       'model/topology.cc'
+        ]
+    headers = bld.new_task_gen('ns3header')
+    headers.module = 'topology'
+    headers.source = [
+       'model/topology.h'
+        ]
+
index 0805d82cf680a414c475f3077d1751999ef9e5cc..c5367213c2c2a0720e460c81e05a40eff707583a 100644 (file)
@@ -66,6 +66,7 @@ all_modules = (
     'contrib/topology-read',
     'contrib/energy',
     'tools/visualizer',
+    'topology',
     'simulation'
     )