author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Thu, 30 Aug 2007 13:58:15 +0200 | |
changeset 1399 | 5945e92014e2 |
parent 1356 | 5b10d248d66a |
child 1419 | ac2a81821ab5 |
permissions | -rw-r--r-- |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
2 |
/* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
3 |
* Copyright (c) 2006 INRIA |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
4 |
* All rights reserved. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
5 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or modify |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
7 |
* it under the terms of the GNU General Public License version 2 as |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
9 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
14 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
18 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
19 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
20 |
*/ |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
21 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
22 |
#ifndef F_VARIABLE_TRACER_H |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
23 |
#define F_VARIABLE_TRACER_H |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
24 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
25 |
#include "callback-trace-source.h" |
1353
0dd2acd3418f
replace CallbackTraceSourceBase with TraceSource base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1334
diff
changeset
|
26 |
#include "trace-source.h" |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
27 |
#include <stdint.h> |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
28 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
29 |
namespace ns3 { |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
30 |
|
1353
0dd2acd3418f
replace CallbackTraceSourceBase with TraceSource base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1334
diff
changeset
|
31 |
class FVTraceSourceBase : public TraceSource { |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
32 |
public: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
33 |
typedef CallbackTraceSource<double, double> ChangeNotifyCallback; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
34 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
35 |
FVTraceSourceBase () {} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
36 |
FVTraceSourceBase (FVTraceSourceBase const &o) {} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
37 |
FVTraceSourceBase &operator = (FVTraceSourceBase const &o) { |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
38 |
return *this; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
39 |
} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
40 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
41 |
~FVTraceSourceBase () {} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
42 |
|
1356
5b10d248d66a
add forgotten virtual keyword
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1353
diff
changeset
|
43 |
virtual void AddCallback (CallbackBase const & callback, TraceContext const & context) { |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
44 |
m_callback.AddCallback (callback, context); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
45 |
} |
1356
5b10d248d66a
add forgotten virtual keyword
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1353
diff
changeset
|
46 |
virtual void RemoveCallback (CallbackBase const & callback) { |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
47 |
m_callback.RemoveCallback (callback); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
48 |
} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
49 |
protected: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
50 |
void notify (double oldVal, double newVal) { |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
51 |
if (oldVal != newVal) |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
52 |
{ |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
53 |
m_callback (oldVal, newVal); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
54 |
} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
55 |
} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
56 |
private: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
57 |
ChangeNotifyCallback m_callback; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
58 |
}; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
59 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
60 |
template <typename T> |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
61 |
class FVTraceSource : public FVTraceSourceBase |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
62 |
{ |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
63 |
public: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
64 |
}; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
65 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
66 |
}; // namespace ns3 |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
67 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
68 |
#endif /* F_VARIABLE_TRACER_H */ |