Add a simpler olsr::EnableAllNodes API as suggested by Mathieu.
--- a/examples/simple-p2p-olsr.cc Mon Jul 30 17:15:35 2007 +0100
+++ b/examples/simple-p2p-olsr.cc Mon Jul 30 17:33:12 2007 +0100
@@ -65,7 +65,7 @@
#include "ns3/onoff-application.h"
#include "ns3/debug.h"
-#include "ns3/olsr-agent.h"
+#include "ns3/olsr.h"
using namespace ns3;
@@ -138,20 +138,9 @@
// Run OLSR in each node.
- ComponentManager::Create<OlsrAgent, Ptr<Node> >
- (OlsrAgent::cid, OlsrAgent::iid, n0)->Start ();
-
- ComponentManager::Create<OlsrAgent, Ptr<Node> >
- (OlsrAgent::cid, OlsrAgent::iid, n1)->Start ();
-
- ComponentManager::Create<OlsrAgent, Ptr<Node> >
- (OlsrAgent::cid, OlsrAgent::iid, n2)->Start ();
-
- ComponentManager::Create<OlsrAgent, Ptr<Node> >
- (OlsrAgent::cid, OlsrAgent::iid, n3)->Start ();
+ olsr::EnableAllNodes ();
-#if 1
// Create the OnOff application to send UDP datagrams of size
// 210 bytes at a rate of 448 Kb/s
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
@@ -176,7 +165,6 @@
// Start the application
ooff->Start(Seconds(1.1));
ooff->Stop (Seconds(10.0));
-#endif
// Configure tracing of all enqueue, dequeue, and NetDevice receive events
// Trace output will be sent to the simple-p2p.tr file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/routing/olsr/olsr.cc Mon Jul 30 17:33:12 2007 +0100
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INESC Porto
+ * 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: Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
+ */
+
+#include "olsr-agent.h"
+#include "olsr.h"
+
+namespace ns3 { namespace olsr {
+
+
+void
+EnableAllNodes (void)
+{
+ EnableNodes (NodeList::Begin (), NodeList::End ());
+}
+
+void
+EnableNodes (NodeList::Iterator begin, NodeList::Iterator end)
+{
+ for (NodeList::Iterator i = begin; i != end; i++)
+ {
+ EnableNode (*i);
+ }
+}
+
+void
+EnableNode (Ptr<Node> node)
+{
+ ComponentManager::Create<OlsrAgent, Ptr<Node> >
+ (OlsrAgent::cid, OlsrAgent::iid, node)->Start ();
+}
+
+
+}} // namespace ns3, olsr
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/routing/olsr/olsr.h Mon Jul 30 17:33:12 2007 +0100
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INESC Porto
+ * 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: Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
+ */
+
+#ifndef OLSR_H
+#define OLSR_H
+
+#include "ns3/node-list.h"
+
+namespace ns3
+{
+ namespace olsr
+ {
+ void EnableAllNodes (void);
+ void EnableNodes (NodeList::Iterator begin, NodeList::Iterator end);
+ void EnableNode (Ptr<Node> node);
+ }
+}
+
+#endif /* OLSR_H */
--- a/src/routing/olsr/wscript Mon Jul 30 17:15:35 2007 +0100
+++ b/src/routing/olsr/wscript Mon Jul 30 17:33:12 2007 +0100
@@ -12,9 +12,11 @@
'routing-table.cc',
'olsr-agent.cc',
'olsr-agent-impl.cc',
+ 'olsr.cc',
]
headers = bld.create_obj('ns3header')
headers.source = [
'olsr-agent.h',
+ 'olsr.h',
]