--- a/SConstruct Mon Sep 04 14:06:00 2006 +0200
+++ b/SConstruct Mon Sep 04 14:10:34 2006 +0200
@@ -537,7 +537,7 @@
'pcap-writer.cc',
'trace-container.cc',
'traced-variable-test.cc',
- 'trace-stream-test.cc',
+ 'stream-tracer-test.cc',
])
common.add_inst_headers ([
'buffer.h',
@@ -549,9 +549,9 @@
'si-traced-variable.tcc',
'f-traced-variable.tcc',
'callback-tracer.h',
+ 'stream-tracer.h',
'trace-container.h',
'chunk-constant-data.h',
- 'trace-stream.h',
'pcap-writer.h',
])
common.add_headers ([
--- a/samples/main-trace.cc Mon Sep 04 14:06:00 2006 +0200
+++ b/samples/main-trace.cc Mon Sep 04 14:10:34 2006 +0200
@@ -2,7 +2,7 @@
#include "ns3/trace-container.h"
#include "ns3/ui-traced-variable.tcc"
#include "ns3/callback-tracer.h"
-#include "ns3/trace-stream.h"
+#include "ns3/stream-tracer.h"
#include "ns3/pcap-writer.h"
#include "ns3/packet.h"
#include <iostream>
@@ -11,7 +11,7 @@
CallbackTracer<Packet> a;
UiTracedVariable<unsigned short> b;
-TraceStream c;
+StreamTracer c;
CallbackTracer<double, int> d;
void
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/common/stream-tracer-test.cc Mon Sep 04 14:10:34 2006 +0200
@@ -0,0 +1,68 @@
+/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+/*
+ * Copyright (c) 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 "stream-tracer.h"
+#include "ns3/test.h"
+#include <iostream>
+
+#ifdef RUN_SELF_TESTS
+
+namespace {
+
+class TestStreamTracer : public ns3::Test {
+public:
+ TestStreamTracer ();
+ virtual bool run_tests (void);
+};
+
+static TestStreamTracer g_test_stream;
+
+TestStreamTracer::TestStreamTracer ()
+ : Test ("StreamTracer")
+{}
+
+bool
+TestStreamTracer::run_tests (void)
+{
+ bool ok = true;
+ ns3::StreamTracer trace;
+ //trace.set_stream (&std::cout);
+ trace << 1;
+ trace << " X ";
+ trace << 1.0;
+ trace << std::endl;
+ trace << "test ";
+ trace << 1 << " test";
+ trace << "test "
+ << 1.0 << " "
+ << 0xdeadbead
+ << std::endl;
+ trace << "0x" << std::hex
+ << 0xdeadbeaf
+ << std::dec << " "
+ << 0xdeadbeaf
+ << std::endl;
+ return ok;
+}
+
+
+}; // namespace ns3
+
+#endif /* RUN_SELF_TESTS */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/common/stream-tracer.h Mon Sep 04 14:10:34 2006 +0200
@@ -0,0 +1,73 @@
+/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+/*
+ * Copyright (c) 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 STREAM_TRACER_H
+#define STREAM_TRACER_H
+
+#include <ostream>
+
+namespace ns3 {
+
+/**
+ * \brief log arbitrary data to std::ostreams
+ *
+ * Whenever operator << is invoked on this class,
+ * it is forwarded to the stored std::ostream output
+ * stream (if there is one).
+ */
+class StreamTracer {
+public:
+ StreamTracer ()
+ : m_os (0) {}
+ template <typename T>
+ StreamTracer &operator << (T const&v) {
+ if (m_os != 0) {
+ (*m_os) << v;
+ }
+ return *this;
+ }
+ template <typename T>
+ StreamTracer &operator << (T &v) {
+ if (m_os != 0) {
+ (*m_os) << v;
+ }
+ return *this;
+ }
+ StreamTracer &operator << (std::ostream &(*v) (std::ostream &)) {
+ if (m_os != 0) {
+ (*m_os) << v;
+ }
+ return *this;
+ }
+
+ /**
+ * \param os the output stream to store
+ */
+ void set_stream (std::ostream * os) {
+ m_os = os;
+ }
+private:
+ std::ostream *m_os;
+};
+
+}; // namespace ns3
+
+
+#endif /* TRACER_STREAM_H */
--- a/src/common/trace-container.cc Mon Sep 04 14:06:00 2006 +0200
+++ b/src/common/trace-container.cc Mon Sep 04 14:10:34 2006 +0200
@@ -20,7 +20,7 @@
*/
#include "trace-container.h"
-#include "trace-stream.h"
+#include "stream-tracer.h"
#include <utility>
#include <cassert>
@@ -65,7 +65,7 @@
void
TraceContainer::set_stream (char const *name, std::ostream *os)
{
- for (TraceStreamListI i = m_trace_stream_list.begin (); i != m_trace_stream_list.end (); i++) {
+ for (StreamTracerListI i = m_trace_stream_list.begin (); i != m_trace_stream_list.end (); i++) {
if ((*i).second == name) {
(*i).first->set_stream (os);
return;
@@ -105,10 +105,10 @@
}
void
-TraceContainer::register_stream (char const *name, TraceStream *stream)
+TraceContainer::register_stream (char const *name, StreamTracer *stream)
{
// ensure unicity
- for (TraceStreamListI i = m_trace_stream_list.begin (); i != m_trace_stream_list.end (); i++) {
+ for (StreamTracerListI i = m_trace_stream_list.begin (); i != m_trace_stream_list.end (); i++) {
if (i->second == name) {
m_trace_stream_list.erase (i);
break;
--- a/src/common/trace-container.h Mon Sep 04 14:06:00 2006 +0200
+++ b/src/common/trace-container.h Mon Sep 04 14:10:34 2006 +0200
@@ -32,7 +32,7 @@
namespace ns3 {
-class TraceStream;
+class StreamTracer;
/**
* \brief register every source of trace events
@@ -43,7 +43,7 @@
* model trace event sources.
*
* TraceContainer can be used to register the following event sources:
- * - ns3::TraceStream : can be connected to any std::ostream
+ * - ns3::StreamTracer : can be connected to any std::ostream
* - ns3::CallbackTracer: can be connected to any ns3::Callback
* - ns3::UiTracedVariable
* - ns3::SiTracedVariable
@@ -89,7 +89,7 @@
* \param name the name of the target event source
* \param os the output stream being connected to the source trace stream
*
- * This method targets only event sources which are of type TraceStream.
+ * This method targets only event sources which are of type StreamTracer.
*/
void set_stream (char const *name, std::ostream *os);
@@ -159,9 +159,9 @@
* \param name the name of the registered event source
* \param stream the event source being registered
*
- * This method registers only event sources of type TraceStream.
+ * This method registers only event sources of type StreamTracer.
*/
- void register_stream (char const *name, TraceStream *stream);
+ void register_stream (char const *name, StreamTracer *stream);
/**
* \param name the name of the registeref event source
@@ -182,15 +182,15 @@
typedef std::list<std::pair<SiTracedVariableBase *, std::string> >::iterator SiListI;
typedef std::list<std::pair<FTracedVariableBase *, std::string> > FList;
typedef std::list<std::pair<FTracedVariableBase *, std::string> >::iterator FListI;
- typedef std::list<std::pair<TraceStream *, std::string> > TraceStreamList;
- typedef std::list<std::pair<TraceStream *, std::string> >::iterator TraceStreamListI;
+ typedef std::list<std::pair<StreamTracer *, std::string> > StreamTracerList;
+ typedef std::list<std::pair<StreamTracer *, std::string> >::iterator StreamTracerListI;
typedef std::list<std::pair<CallbackTracerBase *, std::string> > CallbackList;
typedef std::list<std::pair<CallbackTracerBase *, std::string> >::iterator CallbackListI;
UiList m_ui_list;
SiList m_si_list;
FList m_f_list;
- TraceStreamList m_trace_stream_list;
+ StreamTracerList m_trace_stream_list;
CallbackList m_callback_list;
};
--- a/src/common/trace-stream-test.cc Mon Sep 04 14:06:00 2006 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
-/*
- * Copyright (c) 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 "trace-stream.h"
-#include "ns3/test.h"
-#include <iostream>
-
-#ifdef RUN_SELF_TESTS
-
-namespace {
-
-class TestTraceStream : public ns3::Test {
-public:
- TestTraceStream ();
- virtual bool run_tests (void);
-};
-
-static TestTraceStream g_test_stream;
-
-TestTraceStream::TestTraceStream ()
- : Test ("TraceStream")
-{}
-
-bool
-TestTraceStream::run_tests (void)
-{
- bool ok = true;
- ns3::TraceStream trace;
- //trace.set_stream (&std::cout);
- trace << 1;
- trace << " X ";
- trace << 1.0;
- trace << std::endl;
- trace << "test ";
- trace << 1 << " test";
- trace << "test "
- << 1.0 << " "
- << 0xdeadbead
- << std::endl;
- trace << "0x" << std::hex
- << 0xdeadbeaf
- << std::dec << " "
- << 0xdeadbeaf
- << std::endl;
- return ok;
-}
-
-
-}; // namespace ns3
-
-#endif /* RUN_SELF_TESTS */
--- a/src/common/trace-stream.h Mon Sep 04 14:06:00 2006 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
-/*
- * Copyright (c) 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 TRACE_STREAM_H
-#define TRACE_STREAM_H
-
-#include <ostream>
-
-namespace ns3 {
-
-/**
- * \brief log arbitrary data to std::ostreams
- *
- * Whenever operator << is invoked on this class,
- * it is forwarded to the stored std::ostream output
- * stream (if there is one).
- */
-class TraceStream {
-public:
- TraceStream ()
- : m_os (0) {}
- template <typename T>
- TraceStream &operator << (T const&v) {
- if (m_os != 0) {
- (*m_os) << v;
- }
- return *this;
- }
- template <typename T>
- TraceStream &operator << (T &v) {
- if (m_os != 0) {
- (*m_os) << v;
- }
- return *this;
- }
- TraceStream &operator << (std::ostream &(*v) (std::ostream &)) {
- if (m_os != 0) {
- (*m_os) << v;
- }
- return *this;
- }
-
- /**
- * \param os the output stream to store
- */
- void set_stream (std::ostream * os) {
- m_os = os;
- }
-private:
- std::ostream *m_os;
-};
-
-}; // namespace ns3
-
-
-#endif /* TRACE_STREAM_H */