replace CallbackTraceSourceBase with TraceSource base class
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sun, 12 Aug 2007 22:23:08 +0200
changeset 1353 0dd2acd3418f
parent 1352 34176d861b6e
child 1354 256446080d34
replace CallbackTraceSourceBase with TraceSource base class
src/core/callback-trace-source.h
src/core/composite-trace-resolver.cc
src/core/composite-trace-resolver.h
src/core/fv-trace-source.h
src/core/sv-trace-source.h
src/core/trace-source.h
src/core/uv-trace-source.h
src/core/wscript
--- a/src/core/callback-trace-source.h	Sun Aug 12 21:23:55 2007 +0200
+++ b/src/core/callback-trace-source.h	Sun Aug 12 22:23:08 2007 +0200
@@ -26,18 +26,10 @@
 #include "callback.h"
 #include "fatal-error.h"
 #include "trace-context.h"
+#include "trace-source.h"
 
 namespace ns3 {
 
-class CallbackTraceSourceBase 
-{
-public:
-  virtual ~CallbackTraceSourceBase () {}
-  virtual void AddCallback (CallbackBase const & callback, TraceContext const & context) = 0;
-  virtual void RemoveCallback (CallbackBase const & callback) = 0;
-};
-
-
 /**
  * \brief log arbitrary number of parameters to a matching ns3::Callback
  * \ingroup lowleveltracing
@@ -47,7 +39,7 @@
  */
 template<typename T1 = empty, typename T2 = empty, 
          typename T3 = empty, typename T4 = empty>
-class CallbackTraceSource : public CallbackTraceSourceBase {
+class CallbackTraceSource : public TraceSource {
 public:
   CallbackTraceSource ();
   virtual void AddCallback (CallbackBase const & callback, TraceContext const & context);
--- a/src/core/composite-trace-resolver.cc	Sun Aug 12 21:23:55 2007 +0200
+++ b/src/core/composite-trace-resolver.cc	Sun Aug 12 22:23:08 2007 +0200
@@ -65,6 +65,14 @@
 
 void 
 CompositeTraceResolver::Add (std::string name,
+                             TraceSource &trace)
+{
+  DoAddSource (name, trace, TraceContext ());
+}
+
+
+void 
+CompositeTraceResolver::Add (std::string name,
                              FVTraceSourceBase &trace)
 {
   DoAddFV (name, trace, TraceContext ());
@@ -149,11 +157,11 @@
 }
 
 void 
-CompositeTraceResolver::DoAddCallback (std::string name,
-                                       CallbackTraceSourceBase &trace, 
-                                       const TraceContext &context)
+CompositeTraceResolver::DoAddSource (std::string name,
+                                     TraceSource &trace, 
+                                     const TraceContext &context)
 {
-  class CallbackCompositeItem : public CompositeItem
+  class SourceCompositeItem : public CompositeItem
   {
   public:
     virtual void Connect (std::string subpath, const CallbackBase &cb, const TraceContext &context)
@@ -161,8 +169,8 @@
     virtual void Disconnect (std::string subpath, const CallbackBase &cb)
     {if (subpath == "") {trace->RemoveCallback (cb);}}
 
-    CallbackTraceSourceBase *trace;
-  } *item = new CallbackCompositeItem ();
+    TraceSource *trace;
+  } *item = new SourceCompositeItem ();
   item->name = name;
   item->context = context;
   item->trace = &trace;
--- a/src/core/composite-trace-resolver.h	Sun Aug 12 21:23:55 2007 +0200
+++ b/src/core/composite-trace-resolver.h	Sun Aug 12 22:23:08 2007 +0200
@@ -54,7 +54,7 @@
    */
   template <typename T>
   void Add (std::string name,
-            CallbackTraceSourceBase &trace, T const &context);
+            TraceSource &trace, T const &context);
   /**
    * \param name name of trace source
    * \param trace a signed variable trace source
@@ -102,10 +102,8 @@
    * source will match the name specified during namespace 
    * resolution.
    */
-  template <typename T1, typename T2,
-            typename T3, typename T4>
   void Add (std::string name,
-            CallbackTraceSource<T1,T2,T3,T4> &trace);
+            TraceSource &trace);
   /**
    * \param name name of trace source
    * \param trace a signed variable trace source
@@ -195,9 +193,9 @@
                                       const TraceContext &context, 
                                       enum Operation op);
   void DoAddChild (std::string name, Ptr<Object> child, const TraceContext &context);
-  void DoAddCallback (std::string name,
-                      CallbackTraceSourceBase &trace,
-                      const TraceContext &context);
+  void DoAddSource (std::string name,
+                    TraceSource &trace,
+                    const TraceContext &context);
   void DoAddSV (std::string name,
                 SVTraceSourceBase &trace, 
                 const TraceContext &context);
@@ -222,20 +220,12 @@
 template <typename T>
 void 
 CompositeTraceResolver::Add (std::string name,
-                             CallbackTraceSourceBase &trace, 
+                             TraceSource &trace, 
                              T const &context)
 {
   TraceContext ctx;
   ctx.Add (context);
-  DoAddCallback (name, trace, ctx);  
-}
-template <typename T1, typename T2,
-          typename T3, typename T4>
-void 
-CompositeTraceResolver::Add (std::string name,
-                             CallbackTraceSource<T1,T2,T3,T4> &trace)
-{
-  DoAddCallback (name, trace, TraceContext ());
+  DoAddSource (name, trace, ctx);  
 }
 
 template <typename T>
--- a/src/core/fv-trace-source.h	Sun Aug 12 21:23:55 2007 +0200
+++ b/src/core/fv-trace-source.h	Sun Aug 12 22:23:08 2007 +0200
@@ -23,11 +23,12 @@
 #define F_VARIABLE_TRACER_H
 
 #include "callback-trace-source.h"
+#include "trace-source.h"
 #include <stdint.h>
 
 namespace ns3 {
 
-class FVTraceSourceBase {
+class FVTraceSourceBase : public TraceSource {
 public:
   typedef CallbackTraceSource<double, double> ChangeNotifyCallback;
 
--- a/src/core/sv-trace-source.h	Sun Aug 12 21:23:55 2007 +0200
+++ b/src/core/sv-trace-source.h	Sun Aug 12 22:23:08 2007 +0200
@@ -23,11 +23,12 @@
 #define SV_TRACE_SOURCE_H
 
 #include "callback-trace-source.h"
+#include "trace-source.h"
 #include <stdint.h>
 
 namespace ns3 {
 
-class SVTraceSourceBase {
+class SVTraceSourceBase : public TraceSource {
 public:
   typedef CallbackTraceSource<int64_t, int64_t> ChangeNotifyCallback;
 
@@ -37,7 +38,7 @@
       return *this;
   }
 
-  ~SVTraceSourceBase () {}
+  virtual ~SVTraceSourceBase () {}
 
   void AddCallback (CallbackBase const & callback, TraceContext const & context) {
     m_callback.AddCallback (callback, context);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/trace-source.h	Sun Aug 12 22:23:08 2007 +0200
@@ -0,0 +1,36 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 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_SOURCE_H
+#define TRACE_SOURCE_H
+
+namespace ns3 {
+
+class TraceSource
+{
+public:
+  virtual ~TraceSource () {}
+  virtual void AddCallback (CallbackBase const & callback, TraceContext const & context) = 0;
+  virtual void RemoveCallback (CallbackBase const & callback) = 0;
+};
+
+} // namespace ns3
+
+#endif /* TRACE_SOURCE_H */
--- a/src/core/uv-trace-source.h	Sun Aug 12 21:23:55 2007 +0200
+++ b/src/core/uv-trace-source.h	Sun Aug 12 22:23:08 2007 +0200
@@ -23,11 +23,12 @@
 #define UV_TRACE_SOURCE_H
 
 #include "callback-trace-source.h"
+#include "trace-source.h"
 #include <stdint.h>
 
 namespace ns3 {
 
-class UVTraceSourceBase {
+class UVTraceSourceBase : public TraceSource {
 public:
   typedef CallbackTraceSource<uint64_t, uint64_t> ChangeNotifyCallback;
 
--- a/src/core/wscript	Sun Aug 12 21:23:55 2007 +0200
+++ b/src/core/wscript	Sun Aug 12 22:23:08 2007 +0200
@@ -81,6 +81,7 @@
         'component-manager.h',
         'type-traits.h',
         'random-variable-default-value.h',
+        'trace-source.h',
         'uv-trace-source.h',
         'sv-trace-source.h',
         'fv-trace-source.h',