author | Tom Henderson <tomh@tomh.org> |
Sun, 18 Mar 2007 14:06:51 -0700 | |
changeset 345 | 47b41507a45a |
child 393 | 18ed386bee75 |
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) 2007 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 |
#ifndef TRACE_ROOT_H |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
22 |
#define TRACE_ROOT_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 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
24 |
#include <string> |
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 "ns3/callback.h" |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
26 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
27 |
/** |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
28 |
* \defgroup tracing Tracing |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
29 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
30 |
* The low-level tracing framework is built around a few very simple |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
31 |
* concepts: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
32 |
* - There can be any number of trace source objects. Each trace source |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
33 |
* object can generate any number of trace events. The current |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
34 |
* trace source objects are: ns3::CallbackTraceSourceSource, ns3::UVTraceSource, |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
35 |
* ns3::SVTraceSource, and, ns3::FVTraceSource. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
36 |
* - Each trace source can be connected to any number of trace sinks. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
37 |
* A trace sink is a ns3::Callback with a very special signature. Its |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
38 |
* first argument is always a ns3::TraceContext. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
39 |
* - Every trace source is uniquely identified by a ns3::TraceContext. Every |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
40 |
* trace sink can query a ns3::TraceContext for information. This allows |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
41 |
* a trace sink which is connected to multiple trace sources to identify |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
42 |
* from which source each event is coming from. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
43 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
44 |
* To allow the user to connect his own trace sinks to each trace source |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
45 |
* defined by any of the models he is using, the tracing framework defines |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
46 |
* a hierarchical namespace. The root of this namespace is accessed through |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
47 |
* the ns3::TraceRoot class. The namespace is represented as a string made |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
48 |
* of multiple elements, each of which is separated from the other elements |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
49 |
* by the '/' character. A namespace string always starts with a '/'. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
50 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
51 |
* By default, the simulation models provide a '/nodes' tracing root. This |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
52 |
* '/nodes' namespace is structured as follows: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
53 |
* \code |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
54 |
* /nodes/n/udp |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
55 |
* /nodes/n/ipv4 |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
56 |
* /tx |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
57 |
* /rx |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
58 |
* /drop |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
59 |
* /interfaces/n/netdevice |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
60 |
* (NetDevice only) /queue/ |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
61 |
* /enque |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
62 |
* /deque |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
63 |
* /drop |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
64 |
* /nodes/n/arp |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
65 |
* \endcode |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
66 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
67 |
* The 'n' element which follows the /nodes and /interfaces namespace elements |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
68 |
* identify a specific node and interface through their index within the |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
69 |
* ns3::NodeList and ns3::Ipv4 objects respectively. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
70 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
71 |
* To connect a trace sink to a trace source identified by a namespace string, |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
72 |
* a user can call the ns3::TraceRoot::Connect method (the ns3::TraceRoot::Disconnect |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
73 |
* method does the symmetric operation). This connection method can accept |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
74 |
* fully-detailed namespace strings but it can also perform pattern matching |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
75 |
* on the user-provided namespace strings to connect multiple trace sources |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
76 |
* to a single trace sink in a single connection operation. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
77 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
78 |
* The syntax of the pattern matching rules are loosely based on regular |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
79 |
* expressions: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
80 |
* - the '*' character matches every element |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
81 |
* - the (a|b) construct matches element 'a' or 'b' |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
82 |
* - the [ss-ee] construct matches all numerical values which belong |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
83 |
* to the interval which includes ss and ee |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
84 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
85 |
* For example, the user could use the following to connect a single sink |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
86 |
* to the ipv4 tx, rx, and drop trace events: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
87 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
88 |
* \code |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
89 |
* void MyTraceSink (TraceContext const &context, Packet &packet); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
90 |
* TraceRoot::Connect ("/nodes/ * /ipv4/ *", MakeCallback (&MyTraceSink)); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
91 |
* \endcode |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
92 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
93 |
* Of course, this code would work only if the signature of the trace sink |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
94 |
* is exactly equal to the signature of all the trace sources which match |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
95 |
* the namespace string (if one of the matching trace source does not match |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
96 |
* exactly, a fatal error will be triggered at runtime during the connection |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
97 |
* process). The ns3::TraceContext extra argument contains |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
98 |
* information on where the trace source is located in the namespace tree. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
99 |
* In that example, if there are multiple nodes in this scenario, each |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
100 |
* call to the MyTraceSink function would receive a different TraceContext, |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
101 |
* each of which would contain a different NodeList::Index object. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
102 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
103 |
* It is important to understand exactly what an ns3::TraceContext |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
104 |
* is. It is a container for a number of type instances. Each instance of |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
105 |
* a ns3::TraceContext contains one and only one instance of a given type. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
106 |
* ns3::TraceContext::Add can be called to add a type instance into a |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
107 |
* TraceContext instance and ns3::TraceContext::Get can be called to get |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
108 |
* a copy of a type instance stored into the ns3::TraceContext. If ::Get |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
109 |
* cannot retrieve the requested type, a fatal error is triggered at |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
110 |
* runtime. The values stored into an ns3::TraceContext attached to a |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
111 |
* trace source are automatically determined during the namespace |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
112 |
* resolution process. To retrieve a value from a ns3::TraceContext, the |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
113 |
* code can be as simple as this: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
114 |
* \code |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
115 |
* void MyTraceSink (TraceContext const &context, Packet &packet) |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
116 |
* { |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
117 |
* NodeList::Index index; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
118 |
* context.Get (index); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
119 |
* std::cout << "node id=" << NodeList::GetNode (index)->GetId () << std::endl; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
120 |
* } |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
121 |
* \endcode |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
122 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
123 |
* To define new trace sources, a model author needs to instante one trace source |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
124 |
* object for each kind of tracing event he wants to export. The trace source objects |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
125 |
* currently defined are: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
126 |
* - ns3::CallbackTraceSourceSource: this trace source can be used to convey any kind of |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
127 |
* trace event to the user. It is a functor, that is, it is a variable |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
128 |
* which behaves like a function which will forward every event to every |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
129 |
* connected trace sink (i.e., ns3::Callback). This trace source takes |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
130 |
* up to four arguments and forwards these 4 arguments together with the |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
131 |
* ns3::TraceContext which identifies this trace source to the connected |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
132 |
* trace sinks. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
133 |
* - ns3::UVTraceSource: this trace source is used to convey key state variable |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
134 |
* changes to the user. It behaves like a normal integer unsigned variable: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
135 |
* you can apply every normal arithmetic operator to it. It will forward |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
136 |
* every change in the value of the variable back to every connected trace |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
137 |
* sink by providing a TraceContext, the old value and the new value. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
138 |
* - ns3::SVTraceSource: this is the signed integer equivalent of |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
139 |
* ns3::UVTraceSource. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
140 |
* - ns3::FVTraceSource: this is the floating point equivalent of |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
141 |
* ns3::UVTraceSource and ns3::SVTraceSource. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
142 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
143 |
* Once the model author has instantiated these objects and has wired them |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
144 |
* in his simulation code (that is, he calls them wherever he wants to |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
145 |
* trigger a trace event), he needs to hook these trace sources into the |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
146 |
* global tracing namespace. The first step to do this is to define a method |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
147 |
* which returns a pointer to a ns3::TraceResolver object and which takes |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
148 |
* as argument a reference to a const ns3::TraceContext. The name of this method |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
149 |
* depends on how you will hook into the global tracing namespace. Before |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
150 |
* we get there, you need to implement this method. To do this, you could |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
151 |
* attempt to do everything by hand: define a subclass of the |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
152 |
* ns3::TraceResolver base class and implement its DoConnect, DoDisconnect |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
153 |
* and DoLookup methods. Because doing this can be a bit tedious, our |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
154 |
* tracing framework provides a number of helper template classes which |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
155 |
* should save you from having to implement your own in most cases: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
156 |
* - ns3::CompositeTraceResolver: this subclass of ns3::TraceResolver |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
157 |
* can be used to aggregate together multiple trace sources and |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
158 |
* multiple other ns3::TraceResolver instances. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
159 |
* - ns3::ArrayTraceResolver: this subclass of ns3::TraceResolver |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
160 |
* can be used to match any number of elements within an array |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
161 |
* where every element is identified by its index. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
162 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
163 |
* Once you can instantiate your own ns3::TraceResolver object instance, |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
164 |
* you have to hook it up into the global namespace. There are two ways |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
165 |
* to do this: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
166 |
* - you can hook your ns3::TraceResolver creation method as a new trace |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
167 |
* root by using the ns3::TraceRoot::Register method |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
168 |
* - you can hook your new ns3::TraceResolver creation method into |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
169 |
* the container of your model. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
170 |
* For example, if you wrote a new l3 protocol, all you have to do |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
171 |
* to hook into your container L3Demux class is to implement |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
172 |
* the pure virtual method inherited from the L3Protocol class |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
173 |
* whose name is ns3::L3protocol::CreateTraceResolver. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
174 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
175 |
* If you really want to have fun and implement your own ns3::TraceResolver |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
176 |
* subclass, you need to understand the basic Connection and Disconnection |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
177 |
* algorithm. The code of that algorithm is wholy contained in the |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
178 |
* ns3::TraceResolver::Connect and ns3::TraceResolver::Disconnect methods. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
179 |
* The idea is that we recursively parse the input namespace string by removing |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
180 |
* the first namespace element. This element is 'resolved' is calling |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
181 |
* the ns3::TraceResolver::DoLookup method which returns a list of |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
182 |
* TraceResolver instances. Each of the returned TraceResolver instance is |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
183 |
* then given what is left of the namespace by calling ns3::TraceResolver::Connect |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
184 |
* until the last namespace element is processed. At this point, we invoke |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
185 |
* the ns3::TraceResolver::DoConnect or ns3::TraceResolver::DoDisconnect |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
186 |
* methods to break the recursion. A good way to understand this algorithm |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
187 |
* is to trace its behavior. Let's say that you want to connect to |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
188 |
* '/nodes/ * /ipv4/interfaces/ * /netdevice/queue/ *'. It would generate |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
189 |
* the following call traces: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
190 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
191 |
* \code |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
192 |
* TraceRoot::Connect (/nodes/ * /ipv4/interfaces/ * /netdevice/queue/ *); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
193 |
* resolver = NodeList::CreateTraceResolver (); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
194 |
* resolver->Connect (/nodes/ * /ipv4/interfaces/ * /netdevice/queue/ *); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
195 |
* list = CompositeTraceResolver::DoLookup ('nodes'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
196 |
* resolver->Connect (/ * /ipv4/interfaces/ * /netdevice/queue/ *); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
197 |
* list = ArrayTraceResolver::DoLookup ('*'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
198 |
* resolver->Connect ('/ipv4/interfaces/ * /netdevice/queue/ *'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
199 |
* list = CompositeTraceResolver::DoLookup ('ipv4'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
200 |
* resolver->Connect ('/interfaces/ * /netdevice/queue/ *'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
201 |
* list = CompositeTraceResolver::DoLookup ('interfaces'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
202 |
* resolver->Connect ('/ * /netdevice/queue/ *'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
203 |
* list = ArrayTraceResolver::DoLookup ('*'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
204 |
* resolver->Connect ('/netdevice/queue/ *'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
205 |
* list = CompositeTraceResolver::DoLookup ('netdevice'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
206 |
* resolver->Connect ('/queue/ *'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
207 |
* list = CompositeTraceResolver::DoLookup ('queue'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
208 |
* resolver->Connect ('/ *'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
209 |
* list = CompositeTraceResolver::DoLookup ('*'); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
210 |
* resolver->DoConnect (); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
211 |
* \endcode |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
212 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
213 |
* This namespace resolution algorithm makes sure that each subpart of the |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
214 |
* namespace is resolved separately by each component. It allows you to |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
215 |
* never have to know the entire namespace structure to resolve a namespace |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
216 |
* string. All namespace knowledge is local which makes it very easy to plug |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
217 |
* in new components and have them extend the global tracing namespace. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
218 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
219 |
* What is central to this namespace parsing and resolution algorithm is the |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
220 |
* construction of an ns3::TraceContext for each trace source during the |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
221 |
* connection process. The root trace context is intialized to be empty and |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
222 |
* TraceResolver::DoLookup method is responsible for incrementally constructing |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
223 |
* the TraceContext assigned to each terminal TraceSource object. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
224 |
*/ |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
225 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
226 |
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
|
227 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
228 |
class CompositeTraceResolver; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
229 |
class TraceResolver; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
230 |
class TraceContext; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
231 |
class CallbackBase; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
232 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
233 |
/** |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
234 |
* \brief The main class used to access tracing functionality for |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
235 |
* a user. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
236 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
237 |
* \ingroup tracing |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
238 |
*/ |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
239 |
class TraceRoot |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
240 |
{ |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
241 |
public: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
242 |
static void Connect (std::string path, CallbackBase const &cb); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
243 |
static void Disconnect (std::string path, CallbackBase const &cb); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
244 |
static void Register (std::string name, |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
245 |
Callback<TraceResolver *,TraceContext const &> createResolver); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
246 |
private: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
247 |
static CompositeTraceResolver *GetComposite (void); |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
248 |
enum TraceType { |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
249 |
NOTHING, |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
250 |
}; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
251 |
}; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
252 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
253 |
}// 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
|
254 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
255 |
#endif /* TRACE_ROOT_H */ |