author | Tommaso Pecorella <tommaso.pecorella@unifi.it> |
Fri, 11 Sep 2015 10:52:44 +0200 | |
changeset 11666 | e8634b0101f7 |
parent 11538 | 397bd6465dd9 |
permissions | -rw-r--r-- |
2587 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2008 INRIA |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License version 2 as |
|
7 |
* published by the Free Software Foundation; |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
18 |
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
19 |
*/ |
|
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
#ifndef TRACE_SOURCE_ACCESSOR_H |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#define TRACE_SOURCE_ACCESSOR_H |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
|
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
#include <stdint.h> |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include "callback.h" |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
#include "ptr.h" |
5505
c0ac392289c3
replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3190
diff
changeset
|
26 |
#include "simple-ref-count.h" |
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
|
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
28 |
/** |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
29 |
* \file |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
30 |
* \ingroup tracing |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
31 |
* ns3::TraceSourceAccessor and ns3::MakeTraceSourceAccessor declarations. |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
32 |
*/ |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
33 |
|
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
namespace ns3 { |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
|
2634
44a92f1d3728
introduce ObjectBase::GetInstanceTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2594
diff
changeset
|
36 |
class ObjectBase; |
44a92f1d3728
introduce ObjectBase::GetInstanceTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2594
diff
changeset
|
37 |
|
2587 | 38 |
/** |
3182 | 39 |
* \ingroup tracing |
40 |
* |
|
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
41 |
* \brief Control access to objects' trace sources. |
2587 | 42 |
* |
2648
736213ce179d
improve doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
43 |
* This class abstracts the kind of trace source to which we want to connect |
736213ce179d
improve doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2634
diff
changeset
|
44 |
* and provides services to Connect and Disconnect a sink to a trace source. |
2587 | 45 |
*/ |
5505
c0ac392289c3
replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3190
diff
changeset
|
46 |
class TraceSourceAccessor : public SimpleRefCount<TraceSourceAccessor> |
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
47 |
{ |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
48 |
public: |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
49 |
/** Constructor. */ |
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
50 |
TraceSourceAccessor (); |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
51 |
/** Destructor. */ |
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
52 |
virtual ~TraceSourceAccessor (); |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
53 |
|
2587 | 54 |
/** |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
55 |
* Connect a Callback to a TraceSource (without context.) |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
56 |
* |
11538
397bd6465dd9
[Doxygen] Label arguments as in,out. Sentence capitalization.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11533
diff
changeset
|
57 |
* \param [in] obj The object instance which contains the target trace source. |
397bd6465dd9
[Doxygen] Label arguments as in,out. Sentence capitalization.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11533
diff
changeset
|
58 |
* \param [in] cb The callback to connect to the target trace source. |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
59 |
* \return \c true unless the connection could not be made, typically because |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
60 |
* the \c obj couldn't be cast to the correct type. |
2587 | 61 |
*/ |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2587
diff
changeset
|
62 |
virtual bool ConnectWithoutContext (ObjectBase *obj, const CallbackBase &cb) const = 0; |
2587 | 63 |
/** |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
64 |
* Connect a Callback to a TraceSource with a context string. |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
65 |
* |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
66 |
* The context string will be provided as the first argument to the |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
67 |
* Callback function. |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
68 |
* |
11538
397bd6465dd9
[Doxygen] Label arguments as in,out. Sentence capitalization.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11533
diff
changeset
|
69 |
* \param [in] obj The object instance which contains the target trace source. |
397bd6465dd9
[Doxygen] Label arguments as in,out. Sentence capitalization.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11533
diff
changeset
|
70 |
* \param [in] context The context to bind to the user callback. |
397bd6465dd9
[Doxygen] Label arguments as in,out. Sentence capitalization.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11533
diff
changeset
|
71 |
* \param [in] cb The callback to connect to the target trace source. |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
72 |
* \return \c true unless the connection could not be made, typically because |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
73 |
* the \c obj couldn't be cast to the correct type. |
2587 | 74 |
*/ |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2587
diff
changeset
|
75 |
virtual bool Connect (ObjectBase *obj, std::string context, const CallbackBase &cb) const = 0; |
2587 | 76 |
/** |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
77 |
* Disconnect a Callback from a TraceSource (without context). |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
78 |
* |
11538
397bd6465dd9
[Doxygen] Label arguments as in,out. Sentence capitalization.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11533
diff
changeset
|
79 |
* \param [in] obj The object instance which contains the target trace source. |
397bd6465dd9
[Doxygen] Label arguments as in,out. Sentence capitalization.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11533
diff
changeset
|
80 |
* \param [in] cb The callback to disconnect from the target trace source. |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
81 |
* \return \c true unless the connection could not be made, typically because |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
82 |
* the \c obj couldn't be cast to the correct type. |
2587 | 83 |
*/ |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2587
diff
changeset
|
84 |
virtual bool DisconnectWithoutContext (ObjectBase *obj, const CallbackBase &cb) const = 0; |
2587 | 85 |
/** |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
86 |
* Disconnect a Callback from a TraceSource with a context string. |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
87 |
* |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
88 |
* The context string will be provided as the first argument to the |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
89 |
* Callback function. |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
90 |
* |
11538
397bd6465dd9
[Doxygen] Label arguments as in,out. Sentence capitalization.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11533
diff
changeset
|
91 |
* \param [in] obj the object instance which contains the target trace source. |
397bd6465dd9
[Doxygen] Label arguments as in,out. Sentence capitalization.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11533
diff
changeset
|
92 |
* \param [in] context the context which was bound to the user callback. |
397bd6465dd9
[Doxygen] Label arguments as in,out. Sentence capitalization.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11533
diff
changeset
|
93 |
* \param [in] cb the callback to disconnect from the target trace source. |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
94 |
* \return \c true unless the connection could not be made, typically because |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
95 |
* the \c obj couldn't be cast to the correct type. |
2587 | 96 |
*/ |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2587
diff
changeset
|
97 |
virtual bool Disconnect (ObjectBase *obj, std::string context, const CallbackBase &cb) const = 0; |
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
98 |
}; |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
99 |
|
2587 | 100 |
/** |
10977
f35701d8a0a0
Implementation for documenting TracedValue and TracedCallback signatures.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
7169
diff
changeset
|
101 |
* \ingroup tracing |
2587 | 102 |
* |
103 |
* Create a TraceSourceAccessor which will control access to the underlying |
|
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
104 |
* trace source. |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
105 |
* |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
106 |
* This helper template method assumes that the underlying |
3190
51fe9001a679
add some doxygen, remove a couple of XXX
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3182
diff
changeset
|
107 |
* type implements a statically-polymorphic set of Connect and Disconnect |
51fe9001a679
add some doxygen, remove a couple of XXX
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3182
diff
changeset
|
108 |
* methods and creates a dynamic-polymorphic class to wrap the underlying |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
109 |
* static-polymorphic class. This functionality is typically provided |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
110 |
* by wrapping an object data member in a TracedCallback. |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
111 |
* |
11538
397bd6465dd9
[Doxygen] Label arguments as in,out. Sentence capitalization.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11533
diff
changeset
|
112 |
* \param [in] a The trace source |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
113 |
* \returns The TraceSourceAccessor |
2587 | 114 |
*/ |
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
115 |
template <typename T> |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
116 |
Ptr<const TraceSourceAccessor> MakeTraceSourceAccessor (T a); |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
117 |
|
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
118 |
} // namespace ns3 |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
119 |
|
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
120 |
|
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
121 |
/******************************************************************** |
11131
6a448ac28669
[Doxygen] Various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11129
diff
changeset
|
122 |
* Implementation of the templates declared above. |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
123 |
********************************************************************/ |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
124 |
|
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
125 |
namespace ns3 { |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
126 |
|
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
127 |
/** |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
128 |
* \ingroup tracing |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
129 |
* MakeTraceSourceAccessor() implementation. |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
130 |
* |
11533
6769680336c8
[Doxygen] Template parameter deduction.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11131
diff
changeset
|
131 |
* \tparam T \deduced Class type of the TracedCallback |
6769680336c8
[Doxygen] Template parameter deduction.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11131
diff
changeset
|
132 |
* \tparam SOURCE \deduced Type of the underlying value. |
11538
397bd6465dd9
[Doxygen] Label arguments as in,out. Sentence capitalization.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11533
diff
changeset
|
133 |
* \param [in] a The underlying data value. |
11129
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
134 |
* \returns The TraceSourceAccessor |
8522545f2943
[Doxygen] Tracing.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10977
diff
changeset
|
135 |
*/ |
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
136 |
template <typename T, typename SOURCE> |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
137 |
Ptr<const TraceSourceAccessor> |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
138 |
DoMakeTraceSourceAccessor (SOURCE T::*a) |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
139 |
{ |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
140 |
struct Accessor : public TraceSourceAccessor |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
141 |
{ |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2587
diff
changeset
|
142 |
virtual bool ConnectWithoutContext (ObjectBase *obj, const CallbackBase &cb) const { |
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
143 |
T *p = dynamic_cast<T*> (obj); |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
144 |
if (p == 0) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
145 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
146 |
return false; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
147 |
} |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2587
diff
changeset
|
148 |
(p->*m_source).ConnectWithoutContext (cb); |
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
149 |
return true; |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
150 |
} |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2587
diff
changeset
|
151 |
virtual bool Connect (ObjectBase *obj, std::string context, const CallbackBase &cb) const { |
2531
b451b5fc8b57
implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2463
diff
changeset
|
152 |
T *p = dynamic_cast<T*> (obj); |
b451b5fc8b57
implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2463
diff
changeset
|
153 |
if (p == 0) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
154 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
155 |
return false; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
156 |
} |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2587
diff
changeset
|
157 |
(p->*m_source).Connect (cb, context); |
2531
b451b5fc8b57
implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2463
diff
changeset
|
158 |
return true; |
b451b5fc8b57
implement context-based trace connection
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2463
diff
changeset
|
159 |
} |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2587
diff
changeset
|
160 |
virtual bool DisconnectWithoutContext (ObjectBase *obj, const CallbackBase &cb) const { |
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
161 |
T *p = dynamic_cast<T*> (obj); |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
162 |
if (p == 0) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
163 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
164 |
return false; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
165 |
} |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2587
diff
changeset
|
166 |
(p->*m_source).DisconnectWithoutContext (cb); |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
167 |
return true; |
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
168 |
} |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2587
diff
changeset
|
169 |
virtual bool Disconnect (ObjectBase *obj, std::string context, const CallbackBase &cb) const { |
2569
d5cff2968984
make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2531
diff
changeset
|
170 |
T *p = dynamic_cast<T*> (obj); |
d5cff2968984
make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2531
diff
changeset
|
171 |
if (p == 0) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
172 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
173 |
return false; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
174 |
} |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2587
diff
changeset
|
175 |
(p->*m_source).Disconnect (cb, context); |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
176 |
return true; |
2569
d5cff2968984
make Disconnect work with trace contexts.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2531
diff
changeset
|
177 |
} |
2463
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
178 |
SOURCE T::*m_source; |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
179 |
} *accessor = new Accessor (); |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
180 |
accessor->m_source = a; |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
181 |
return Ptr<const TraceSourceAccessor> (accessor, false); |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
182 |
} |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
183 |
|
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
184 |
template <typename T> |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
185 |
Ptr<const TraceSourceAccessor> MakeTraceSourceAccessor (T a) |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
186 |
{ |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
187 |
return DoMakeTraceSourceAccessor (a); |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
188 |
} |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
189 |
|
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
190 |
} // namespace ns3 |
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
191 |
|
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
192 |
|
c77e43117673
actually allow connection and disconnection to trace sources registered in TypeIds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
193 |
#endif /* TRACE_SOURCE_ACCESSOR_H */ |