Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
This commit is contained in:
@@ -159,7 +159,7 @@
|
||||
* \section TraceConnection Connecting Trace Sources to Trace Sinks
|
||||
*
|
||||
* If a trace source is integrated in the ns-3 trace connection facility, a user
|
||||
* should call the ns3::NodeList::Connect method to establish a connection between
|
||||
* should call the ns3::NodeList::ConnectWithoutContext method to establish a connection between
|
||||
* a trace sink and a set of matching trace sources. The second argument to that
|
||||
* method is a callback to the user's trace sink.
|
||||
* That callback is easy to construct: call ns3::MakeCallback and you are done. The
|
||||
@@ -178,7 +178,7 @@
|
||||
* std::cout << "packet: " << packet->Print () << std::endl;
|
||||
* }
|
||||
* // connect the above sink to a matching trace source
|
||||
* NodeList::Connect ("/nodes/* /devices/* /rx", MakeCallback (&DoSomethingTraceSink));
|
||||
* NodeList::ConnectWithoutContext ("/nodes/* /devices/* /rx", MakeCallback (&DoSomethingTraceSink));
|
||||
* \endcode
|
||||
*
|
||||
* The connection path string "/nodes/* /devices/* /rx" matches the "rx" trace source
|
||||
|
||||
@@ -239,7 +239,7 @@ int main (int argc, char *argv[])
|
||||
PcapTrace pcaptrace ("tcp-large-transfer-errors.pcap");
|
||||
pcaptrace.TraceAllIp ();
|
||||
|
||||
Config::Connect ("/NodeList/*/ApplicationList/*/Rx", MakeCallback (&ApplicationTraceSink));
|
||||
Config::ConnectWithoutContext ("/NodeList/*/ApplicationList/*/Rx", MakeCallback (&ApplicationTraceSink));
|
||||
|
||||
Simulator::StopAt (Seconds(10000));
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -224,7 +224,7 @@ int main (int argc, char *argv[])
|
||||
PcapTrace pcaptrace ("tcp-large-transfer.pcap");
|
||||
pcaptrace.TraceAllIp ();
|
||||
|
||||
Config::Connect ("/NodeList/*/ApplicationList/*/Rx",
|
||||
Config::ConnectWithoutContext ("/NodeList/*/ApplicationList/*/Rx",
|
||||
MakeCallback (&ApplicationTraceSink));
|
||||
|
||||
Simulator::StopAt (Seconds(1000));
|
||||
|
||||
@@ -221,7 +221,7 @@ int main (int argc, char *argv[])
|
||||
PcapTrace pcaptrace ("tcp-small-transfer-oneloss.pcap");
|
||||
pcaptrace.TraceAllIp ();
|
||||
|
||||
Config::Connect ("/NodeList/*/ApplicationList/*/Rx", MakeCallback (&ApplicationTraceSink));
|
||||
Config::ConnectWithoutContext ("/NodeList/*/ApplicationList/*/Rx", MakeCallback (&ApplicationTraceSink));
|
||||
|
||||
Simulator::StopAt (Seconds(1000));
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -216,7 +216,7 @@ int main (int argc, char *argv[])
|
||||
PcapTrace pcaptrace ("tcp-small-transfer.pcap");
|
||||
pcaptrace.TraceAllIp ();
|
||||
|
||||
Config::Connect ("/NodeList/*/ApplicationList/*/Rx", MakeCallback (&ApplicationTraceSink));
|
||||
Config::ConnectWithoutContext ("/NodeList/*/ApplicationList/*/Rx", MakeCallback (&ApplicationTraceSink));
|
||||
|
||||
Simulator::StopAt (Seconds(1000));
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -155,8 +155,8 @@ int main (int argc, char *argv[])
|
||||
|
||||
Simulator::StopAt (Seconds (44.0));
|
||||
|
||||
//NodeList::Connect ("/nodes/*/devices/*/*", MakeCallback (&WifiNetDeviceTrace));
|
||||
//NodeList::Connect ("/nodes/*/devices/*/phy/state", MakeCallback (&WifiPhyStateTrace));
|
||||
//NodeList::ConnectWithoutContext ("/nodes/*/devices/*/*", MakeCallback (&WifiNetDeviceTrace));
|
||||
//NodeList::ConnectWithoutContext ("/nodes/*/devices/*/phy/state", MakeCallback (&WifiPhyStateTrace));
|
||||
|
||||
Simulator::Run ();
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ int main (int argc, char *argv[])
|
||||
mobility.SetMobilityModel ("StaticMobilityModel");
|
||||
mobility.Layout (objects.begin (), objects.end ());
|
||||
|
||||
Config::ConnectWithContext ("/NodeList/*/$MobilityModelNotifier/CourseChange",
|
||||
Config::Connect ("/NodeList/*/$MobilityModelNotifier/CourseChange",
|
||||
MakeCallback (&CourseChange));
|
||||
|
||||
Simulator::StopAt (Seconds (100.0));
|
||||
|
||||
@@ -53,7 +53,7 @@ int main (int argc, char *argv[])
|
||||
"Speed", String ("Constant:1.0"),
|
||||
"Bounds", String ("0:200:0:100"));
|
||||
mobility.Layout (NodeList::Begin (), NodeList::End ());
|
||||
Config::ConnectWithContext ("/NodeList/*/$MobilityModelNotifier/CourseChange",
|
||||
Config::Connect ("/NodeList/*/$MobilityModelNotifier/CourseChange",
|
||||
MakeCallback (&CourseChange));
|
||||
|
||||
Simulator::StopAt (Seconds (100.0));
|
||||
|
||||
@@ -459,25 +459,25 @@ AttributeTest::RunTests (void)
|
||||
|
||||
m_got1 = -2;
|
||||
NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", Integer (-1)));
|
||||
NS_TEST_ASSERT (p->TraceConnect ("Source1", MakeCallback (&AttributeTest::NotifySource1, this)));
|
||||
NS_TEST_ASSERT (p->TraceConnectWithoutContext ("Source1", MakeCallback (&AttributeTest::NotifySource1, this)));
|
||||
NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", Integer (0)));
|
||||
NS_TEST_ASSERT_EQUAL (m_got1, 0);
|
||||
NS_TEST_ASSERT (p->TraceDisconnect ("Source1", MakeCallback (&AttributeTest::NotifySource1, this)));
|
||||
NS_TEST_ASSERT (p->TraceDisconnectWithoutContext ("Source1", MakeCallback (&AttributeTest::NotifySource1, this)));
|
||||
NS_TEST_ASSERT (p->SetAttributeFailSafe ("IntegerTraceSource1", Integer (1)));
|
||||
NS_TEST_ASSERT_EQUAL (m_got1, 0);
|
||||
|
||||
m_got2 = 4.3;
|
||||
p->InvokeCb (1.0, -5, 0.0);
|
||||
NS_TEST_ASSERT_EQUAL (m_got2, 4.3);
|
||||
NS_TEST_ASSERT (p->TraceConnect ("Source2", MakeCallback (&AttributeTest::NotifySource2, this)));
|
||||
NS_TEST_ASSERT (p->TraceConnectWithoutContext ("Source2", MakeCallback (&AttributeTest::NotifySource2, this)));
|
||||
NS_TEST_ASSERT_EQUAL (m_got2, 4.3);
|
||||
p->InvokeCb (1.0, -5, 0.0);
|
||||
NS_TEST_ASSERT_EQUAL (m_got2, 1.0);
|
||||
NS_TEST_ASSERT (p->TraceDisconnect ("Source2", MakeCallback (&AttributeTest::NotifySource2, this)));
|
||||
NS_TEST_ASSERT (p->TraceDisconnectWithoutContext ("Source2", MakeCallback (&AttributeTest::NotifySource2, this)));
|
||||
p->InvokeCb (-1.0, -5, 0.0);
|
||||
NS_TEST_ASSERT_EQUAL (m_got2, 1.0);
|
||||
|
||||
NS_TEST_ASSERT (p->TraceConnect ("ValueSource", MakeCallback (&AttributeTest::NotifySourceValue, this)));
|
||||
NS_TEST_ASSERT (p->TraceConnectWithoutContext ("ValueSource", MakeCallback (&AttributeTest::NotifySourceValue, this)));
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -285,10 +285,10 @@ class ConfigImpl
|
||||
{
|
||||
public:
|
||||
void Set (std::string path, Attribute value);
|
||||
void ConnectWithoutContext (std::string path, const CallbackBase &cb);
|
||||
void Connect (std::string path, const CallbackBase &cb);
|
||||
void ConnectWithContext (std::string path, const CallbackBase &cb);
|
||||
void DisconnectWithoutContext (std::string path, const CallbackBase &cb);
|
||||
void Disconnect (std::string path, const CallbackBase &cb);
|
||||
void DisconnectWithContext (std::string path, const CallbackBase &cb);
|
||||
|
||||
void RegisterRootNamespaceObject (Ptr<Object> obj);
|
||||
void UnregisterRootNamespaceObject (Ptr<Object> obj);
|
||||
@@ -319,7 +319,7 @@ ConfigImpl::Set (std::string path, Attribute value)
|
||||
}
|
||||
}
|
||||
void
|
||||
ConfigImpl::Connect (std::string path, const CallbackBase &cb)
|
||||
ConfigImpl::ConnectWithoutContext (std::string path, const CallbackBase &cb)
|
||||
{
|
||||
class ConnectResolver : public Resolver
|
||||
{
|
||||
@@ -329,7 +329,7 @@ ConfigImpl::Connect (std::string path, const CallbackBase &cb)
|
||||
m_cb (cb) {}
|
||||
private:
|
||||
virtual void DoOne (Ptr<Object> object, std::string path, std::string name) {
|
||||
object->TraceConnect (name, m_cb);
|
||||
object->TraceConnectWithoutContext (name, m_cb);
|
||||
}
|
||||
CallbackBase m_cb;
|
||||
} resolver = ConnectResolver (path, cb);
|
||||
@@ -339,7 +339,7 @@ ConfigImpl::Connect (std::string path, const CallbackBase &cb)
|
||||
}
|
||||
}
|
||||
void
|
||||
ConfigImpl::Disconnect (std::string path, const CallbackBase &cb)
|
||||
ConfigImpl::DisconnectWithoutContext (std::string path, const CallbackBase &cb)
|
||||
{
|
||||
class DisconnectResolver : public Resolver
|
||||
{
|
||||
@@ -349,7 +349,7 @@ ConfigImpl::Disconnect (std::string path, const CallbackBase &cb)
|
||||
m_cb (cb) {}
|
||||
private:
|
||||
virtual void DoOne (Ptr<Object> object, std::string path, std::string name) {
|
||||
object->TraceDisconnect (name, m_cb);
|
||||
object->TraceDisconnectWithoutContext (name, m_cb);
|
||||
}
|
||||
CallbackBase m_cb;
|
||||
} resolver = DisconnectResolver (path, cb);
|
||||
@@ -359,7 +359,7 @@ ConfigImpl::Disconnect (std::string path, const CallbackBase &cb)
|
||||
}
|
||||
}
|
||||
void
|
||||
ConfigImpl::ConnectWithContext (std::string path, const CallbackBase &cb)
|
||||
ConfigImpl::Connect (std::string path, const CallbackBase &cb)
|
||||
{
|
||||
class ConnectWithContextResolver : public Resolver
|
||||
{
|
||||
@@ -369,7 +369,7 @@ ConfigImpl::ConnectWithContext (std::string path, const CallbackBase &cb)
|
||||
m_cb (cb) {}
|
||||
private:
|
||||
virtual void DoOne (Ptr<Object> object, std::string path, std::string name) {
|
||||
object->TraceConnectWithContext (name, path, m_cb);
|
||||
object->TraceConnectWithoutContext (name, path, m_cb);
|
||||
}
|
||||
CallbackBase m_cb;
|
||||
} resolver = ConnectWithContextResolver (path, cb);
|
||||
@@ -379,7 +379,7 @@ ConfigImpl::ConnectWithContext (std::string path, const CallbackBase &cb)
|
||||
}
|
||||
}
|
||||
void
|
||||
ConfigImpl::DisconnectWithContext (std::string path, const CallbackBase &cb)
|
||||
ConfigImpl::Disconnect (std::string path, const CallbackBase &cb)
|
||||
{
|
||||
class DisconnectWithContextResolver : public Resolver
|
||||
{
|
||||
@@ -389,7 +389,7 @@ ConfigImpl::DisconnectWithContext (std::string path, const CallbackBase &cb)
|
||||
m_cb (cb) {}
|
||||
private:
|
||||
virtual void DoOne (Ptr<Object> object, std::string path, std::string name) {
|
||||
object->TraceDisconnectWithContext (name, path, m_cb);
|
||||
object->TraceDisconnectWithoutContext (name, path, m_cb);
|
||||
}
|
||||
CallbackBase m_cb;
|
||||
} resolver = DisconnectWithContextResolver (path, cb);
|
||||
@@ -440,24 +440,24 @@ bool SetGlobalFailSafe (std::string name, Attribute value)
|
||||
{
|
||||
return GlobalValue::BindFailSafe (name, value);
|
||||
}
|
||||
void Connect (std::string path, const CallbackBase &cb)
|
||||
void ConnectWithoutContext (std::string path, const CallbackBase &cb)
|
||||
{
|
||||
Singleton<ConfigImpl>::Get ()->ConnectWithoutContext (path, cb);
|
||||
}
|
||||
void DisconnectWithoutContext (std::string path, const CallbackBase &cb)
|
||||
{
|
||||
Singleton<ConfigImpl>::Get ()->DisconnectWithoutContext (path, cb);
|
||||
}
|
||||
void
|
||||
Connect (std::string path, const CallbackBase &cb)
|
||||
{
|
||||
Singleton<ConfigImpl>::Get ()->Connect (path, cb);
|
||||
}
|
||||
void Disconnect (std::string path, const CallbackBase &cb)
|
||||
void
|
||||
Disconnect (std::string path, const CallbackBase &cb)
|
||||
{
|
||||
Singleton<ConfigImpl>::Get ()->Disconnect (path, cb);
|
||||
}
|
||||
void
|
||||
ConnectWithContext (std::string path, const CallbackBase &cb)
|
||||
{
|
||||
Singleton<ConfigImpl>::Get ()->ConnectWithContext (path, cb);
|
||||
}
|
||||
void
|
||||
DisconnectWithContext (std::string path, const CallbackBase &cb)
|
||||
{
|
||||
Singleton<ConfigImpl>::Get ()->DisconnectWithContext (path, cb);
|
||||
}
|
||||
|
||||
void RegisterRootNamespaceObject (Ptr<Object> obj)
|
||||
{
|
||||
@@ -710,7 +710,7 @@ ConfigTest::RunTests (void)
|
||||
NS_TEST_ASSERT_EQUAL (v.Get (), -16);
|
||||
|
||||
|
||||
Config::Connect ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
|
||||
Config::ConnectWithoutContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
|
||||
MakeCallback (&ConfigTest::ChangeNotification, this));
|
||||
m_traceNotification = 0;
|
||||
// this should trigger no notification
|
||||
@@ -720,7 +720,7 @@ ConfigTest::RunTests (void)
|
||||
// this should trigger a notification
|
||||
d1->SetAttribute ("Source", Integer (-3));
|
||||
NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
|
||||
Config::Disconnect ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
|
||||
Config::DisconnectWithoutContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
|
||||
MakeCallback (&ConfigTest::ChangeNotification, this));
|
||||
m_traceNotification = 0;
|
||||
// this should _not_ trigger a notification
|
||||
@@ -728,7 +728,7 @@ ConfigTest::RunTests (void)
|
||||
NS_TEST_ASSERT_EQUAL (m_traceNotification, 0);
|
||||
|
||||
|
||||
Config::ConnectWithContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
|
||||
Config::Connect ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
|
||||
MakeCallback (&ConfigTest::ChangeNotificationWithPath, this));
|
||||
m_traceNotification = 0;
|
||||
// this should trigger no notification
|
||||
@@ -746,7 +746,7 @@ ConfigTest::RunTests (void)
|
||||
d3->SetAttribute ("Source", Integer (-3));
|
||||
NS_TEST_ASSERT_EQUAL (m_traceNotification, -3);
|
||||
NS_TEST_ASSERT_EQUAL (m_tracePath, "/NodeA/NodeB/NodesB/3/Source");
|
||||
Config::DisconnectWithContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
|
||||
Config::Disconnect ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
|
||||
MakeCallback (&ConfigTest::ChangeNotificationWithPath, this));
|
||||
m_traceNotification = 0;
|
||||
// this should _not_ trigger a notification
|
||||
|
||||
@@ -78,14 +78,14 @@ bool SetGlobalFailSafe (std::string name, Attribute value);
|
||||
* match the input path and will then connect the input callback
|
||||
* to them.
|
||||
*/
|
||||
void Connect (std::string path, const CallbackBase &cb);
|
||||
void ConnectWithoutContext (std::string path, const CallbackBase &cb);
|
||||
/**
|
||||
* \param path a path to match trace sources.
|
||||
* \param cb the callback to disconnect to the matching trace sources.
|
||||
*
|
||||
* This function undoes the work of Config::Connect.
|
||||
*/
|
||||
void Disconnect (std::string path, const CallbackBase &cb);
|
||||
void DisconnectWithoutContext (std::string path, const CallbackBase &cb);
|
||||
/**
|
||||
* \param path a path to match trace sources.
|
||||
* \param cb the callback to connect to the matching trace sources.
|
||||
@@ -95,14 +95,14 @@ void Disconnect (std::string path, const CallbackBase &cb);
|
||||
* to them in such a way that the callback will receive an extra
|
||||
* context string upon trace event notification.
|
||||
*/
|
||||
void ConnectWithContext (std::string path, const CallbackBase &cb);
|
||||
void Connect (std::string path, const CallbackBase &cb);
|
||||
/**
|
||||
* \param path a path to match trace sources.
|
||||
* \param cb the callback to connect to the matching trace sources.
|
||||
*
|
||||
* This function undoes the work of Config::ConnectWithContext.
|
||||
*/
|
||||
void DisconnectWithContext (std::string path, const CallbackBase &cb);
|
||||
void Disconnect (std::string path, const CallbackBase &cb);
|
||||
|
||||
/**
|
||||
* \param obj a new root object
|
||||
|
||||
@@ -1127,47 +1127,47 @@ Object::GetAttribute (std::string name) const
|
||||
}
|
||||
|
||||
bool
|
||||
Object::TraceConnect (std::string name, const CallbackBase &cb)
|
||||
Object::TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
|
||||
{
|
||||
Ptr<const TraceSourceAccessor> accessor = m_tid.LookupTraceSourceByName (name);
|
||||
if (accessor == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool ok = accessor->Connect (this, cb);
|
||||
bool ok = accessor->ConnectWithoutContext (this, cb);
|
||||
return ok;
|
||||
}
|
||||
bool
|
||||
Object::TraceConnectWithContext (std::string name, std::string context, const CallbackBase &cb)
|
||||
Object::TraceConnectWithoutContext (std::string name, std::string context, const CallbackBase &cb)
|
||||
{
|
||||
Ptr<const TraceSourceAccessor> accessor = m_tid.LookupTraceSourceByName (name);
|
||||
if (accessor == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool ok = accessor->ConnectWithContext (this, context, cb);
|
||||
bool ok = accessor->Connect (this, context, cb);
|
||||
return ok;
|
||||
}
|
||||
bool
|
||||
Object::TraceDisconnect (std::string name, const CallbackBase &cb)
|
||||
Object::TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
|
||||
{
|
||||
Ptr<const TraceSourceAccessor> accessor = m_tid.LookupTraceSourceByName (name);
|
||||
if (accessor == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool ok = accessor->Disconnect (this, cb);
|
||||
bool ok = accessor->DisconnectWithoutContext (this, cb);
|
||||
return ok;
|
||||
}
|
||||
bool
|
||||
Object::TraceDisconnectWithContext (std::string name, std::string context, const CallbackBase &cb)
|
||||
Object::TraceDisconnectWithoutContext (std::string name, std::string context, const CallbackBase &cb)
|
||||
{
|
||||
Ptr<const TraceSourceAccessor> accessor = m_tid.LookupTraceSourceByName (name);
|
||||
if (accessor == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool ok = accessor->DisconnectWithContext (this, context, cb);
|
||||
bool ok = accessor->Disconnect (this, context, cb);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
@@ -445,10 +445,10 @@ public:
|
||||
*/
|
||||
Attribute GetAttribute (std::string name) const;
|
||||
|
||||
bool TraceConnect (std::string name, const CallbackBase &cb);
|
||||
bool TraceConnectWithContext (std::string name, std::string context, const CallbackBase &cb);
|
||||
bool TraceDisconnect (std::string name, const CallbackBase &cb);
|
||||
bool TraceDisconnectWithContext (std::string name, std::string context, const CallbackBase &cb);
|
||||
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb);
|
||||
bool TraceConnectWithoutContext (std::string name, std::string context, const CallbackBase &cb);
|
||||
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb);
|
||||
bool TraceDisconnectWithoutContext (std::string name, std::string context, const CallbackBase &cb);
|
||||
|
||||
TypeId GetRealTypeId (void) const;
|
||||
|
||||
|
||||
@@ -44,24 +44,24 @@ public:
|
||||
* \param obj the object instance which contains the target trace source.
|
||||
* \param cb the callback to connect to the target trace source.
|
||||
*/
|
||||
virtual bool Connect (ObjectBase *obj, const CallbackBase &cb) const = 0;
|
||||
virtual bool ConnectWithoutContext (ObjectBase *obj, const CallbackBase &cb) const = 0;
|
||||
/**
|
||||
* \param obj the object instance which contains the target trace source.
|
||||
* \param context the context to bind to the user callback.
|
||||
* \param cb the callback to connect to the target trace source.
|
||||
*/
|
||||
virtual bool ConnectWithContext (ObjectBase *obj, std::string context, const CallbackBase &cb) const = 0;
|
||||
virtual bool Connect (ObjectBase *obj, std::string context, const CallbackBase &cb) const = 0;
|
||||
/**
|
||||
* \param obj the object instance which contains the target trace source.
|
||||
* \param cb the callback to disconnect from the target trace source.
|
||||
*/
|
||||
virtual bool Disconnect (ObjectBase *obj, const CallbackBase &cb) const = 0;
|
||||
virtual bool DisconnectWithoutContext (ObjectBase *obj, const CallbackBase &cb) const = 0;
|
||||
/**
|
||||
* \param obj the object instance which contains the target trace source.
|
||||
* \param context the context which was bound to the user callback.
|
||||
* \param cb the callback to disconnect from the target trace source.
|
||||
*/
|
||||
virtual bool DisconnectWithContext (ObjectBase *obj, std::string context, const CallbackBase &cb) const = 0;
|
||||
virtual bool Disconnect (ObjectBase *obj, std::string context, const CallbackBase &cb) const = 0;
|
||||
private:
|
||||
mutable uint32_t m_count;
|
||||
};
|
||||
@@ -85,40 +85,40 @@ DoMakeTraceSourceAccessor (SOURCE T::*a)
|
||||
{
|
||||
struct Accessor : public TraceSourceAccessor
|
||||
{
|
||||
virtual bool Connect (ObjectBase *obj, const CallbackBase &cb) const {
|
||||
virtual bool ConnectWithoutContext (ObjectBase *obj, const CallbackBase &cb) const {
|
||||
T *p = dynamic_cast<T*> (obj);
|
||||
if (p == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
(p->*m_source).Connect (cb);
|
||||
(p->*m_source).ConnectWithoutContext (cb);
|
||||
return true;
|
||||
}
|
||||
virtual bool ConnectWithContext (ObjectBase *obj, std::string context, const CallbackBase &cb) const {
|
||||
virtual bool Connect (ObjectBase *obj, std::string context, const CallbackBase &cb) const {
|
||||
T *p = dynamic_cast<T*> (obj);
|
||||
if (p == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
(p->*m_source).ConnectWithContext (cb, context);
|
||||
(p->*m_source).Connect (cb, context);
|
||||
return true;
|
||||
}
|
||||
virtual bool Disconnect (ObjectBase *obj, const CallbackBase &cb) const {
|
||||
virtual bool DisconnectWithoutContext (ObjectBase *obj, const CallbackBase &cb) const {
|
||||
T *p = dynamic_cast<T*> (obj);
|
||||
if (p == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
(p->*m_source).Disconnect (cb);
|
||||
(p->*m_source).DisconnectWithoutContext (cb);
|
||||
return true;
|
||||
}
|
||||
virtual bool DisconnectWithContext (ObjectBase *obj, std::string context, const CallbackBase &cb) const {
|
||||
virtual bool Disconnect (ObjectBase *obj, std::string context, const CallbackBase &cb) const {
|
||||
T *p = dynamic_cast<T*> (obj);
|
||||
if (p == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
(p->*m_source).DisconnectWithContext (cb, context);
|
||||
(p->*m_source).Disconnect (cb, context);
|
||||
return true;
|
||||
}
|
||||
SOURCE T::*m_source;
|
||||
|
||||
@@ -61,29 +61,29 @@ TracedCallbackTest::RunTests (void)
|
||||
bool result = true;
|
||||
|
||||
TracedCallback<uint8_t,double> trace;
|
||||
trace.Connect (MakeCallback (&TracedCallbackTest::CbOne, this));
|
||||
trace.Connect (MakeCallback (&TracedCallbackTest::CbTwo, this));
|
||||
trace.ConnectWithoutContext (MakeCallback (&TracedCallbackTest::CbOne, this));
|
||||
trace.ConnectWithoutContext (MakeCallback (&TracedCallbackTest::CbTwo, this));
|
||||
m_one = false;
|
||||
m_two = false;
|
||||
trace (1, 2);
|
||||
NS_TEST_ASSERT (m_one);
|
||||
NS_TEST_ASSERT (m_two);
|
||||
|
||||
trace.Disconnect (MakeCallback (&TracedCallbackTest::CbOne, this));
|
||||
trace.DisconnectWithoutContext (MakeCallback (&TracedCallbackTest::CbOne, this));
|
||||
m_one = false;
|
||||
m_two = false;
|
||||
trace (1, 2);
|
||||
NS_TEST_ASSERT (!m_one);
|
||||
NS_TEST_ASSERT (m_two);
|
||||
trace.Disconnect (MakeCallback (&TracedCallbackTest::CbTwo, this));
|
||||
trace.DisconnectWithoutContext (MakeCallback (&TracedCallbackTest::CbTwo, this));
|
||||
m_one = false;
|
||||
m_two = false;
|
||||
trace (1, 2);
|
||||
NS_TEST_ASSERT (!m_one);
|
||||
NS_TEST_ASSERT (!m_two);
|
||||
|
||||
trace.Connect (MakeCallback (&TracedCallbackTest::CbOne, this));
|
||||
trace.Connect (MakeCallback (&TracedCallbackTest::CbTwo, this));
|
||||
trace.ConnectWithoutContext (MakeCallback (&TracedCallbackTest::CbOne, this));
|
||||
trace.ConnectWithoutContext (MakeCallback (&TracedCallbackTest::CbTwo, this));
|
||||
m_one = false;
|
||||
m_two = false;
|
||||
trace (1, 2);
|
||||
|
||||
@@ -40,10 +40,10 @@ class TracedCallback
|
||||
{
|
||||
public:
|
||||
TracedCallback ();
|
||||
void Connect (const CallbackBase & callback);
|
||||
void ConnectWithContext (const CallbackBase & callback, std::string path);
|
||||
void Disconnect (const CallbackBase & callback);
|
||||
void DisconnectWithContext (const CallbackBase & callback, std::string path);
|
||||
void ConnectWithoutContext (const CallbackBase & callback);
|
||||
void Connect (const CallbackBase & callback, std::string path);
|
||||
void DisconnectWithoutContext (const CallbackBase & callback);
|
||||
void Disconnect (const CallbackBase & callback, std::string path);
|
||||
void operator() (void) const;
|
||||
void operator() (T1 a1) const;
|
||||
void operator() (T1 a1, T2 a2) const;
|
||||
@@ -69,7 +69,7 @@ TracedCallback<T1,T2,T3,T4>::TracedCallback ()
|
||||
template<typename T1, typename T2,
|
||||
typename T3, typename T4>
|
||||
void
|
||||
TracedCallback<T1,T2,T3,T4>::Connect (const CallbackBase & callback)
|
||||
TracedCallback<T1,T2,T3,T4>::ConnectWithoutContext (const CallbackBase & callback)
|
||||
{
|
||||
Callback<void,T1,T2,T3,T4> cb;
|
||||
cb.Assign (callback);
|
||||
@@ -78,7 +78,7 @@ TracedCallback<T1,T2,T3,T4>::Connect (const CallbackBase & callback)
|
||||
template<typename T1, typename T2,
|
||||
typename T3, typename T4>
|
||||
void
|
||||
TracedCallback<T1,T2,T3,T4>::ConnectWithContext (const CallbackBase & callback, std::string path)
|
||||
TracedCallback<T1,T2,T3,T4>::Connect (const CallbackBase & callback, std::string path)
|
||||
{
|
||||
Callback<void,std::string,T1,T2,T3,T4> cb;
|
||||
cb.Assign (callback);
|
||||
@@ -88,7 +88,7 @@ TracedCallback<T1,T2,T3,T4>::ConnectWithContext (const CallbackBase & callback,
|
||||
template<typename T1, typename T2,
|
||||
typename T3, typename T4>
|
||||
void
|
||||
TracedCallback<T1,T2,T3,T4>::Disconnect (const CallbackBase & callback)
|
||||
TracedCallback<T1,T2,T3,T4>::DisconnectWithoutContext (const CallbackBase & callback)
|
||||
{
|
||||
for (typename CallbackList::iterator i = m_callbackList.begin ();
|
||||
i != m_callbackList.end (); /* empty */)
|
||||
@@ -106,12 +106,12 @@ TracedCallback<T1,T2,T3,T4>::Disconnect (const CallbackBase & callback)
|
||||
template<typename T1, typename T2,
|
||||
typename T3, typename T4>
|
||||
void
|
||||
TracedCallback<T1,T2,T3,T4>::DisconnectWithContext (const CallbackBase & callback, std::string path)
|
||||
TracedCallback<T1,T2,T3,T4>::Disconnect (const CallbackBase & callback, std::string path)
|
||||
{
|
||||
Callback<void,std::string,T1,T2,T3,T4> cb;
|
||||
cb.Assign (callback);
|
||||
Callback<void,T1,T2,T3,T4> realCb = cb.Bind (path);
|
||||
Disconnect (realCb);
|
||||
DisconnectWithoutContext (realCb);
|
||||
}
|
||||
template<typename T1, typename T2,
|
||||
typename T3, typename T4>
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace ns3 {
|
||||
* support operator !=), you can wrap them in an instance of
|
||||
* this template: this instance will behave just like
|
||||
* the original class (if it did not export any special method),
|
||||
* and will define Connect/Disconnect methods to work
|
||||
* and will define Connect/DisconnectWithoutContext methods to work
|
||||
* with an ns3::TraceSourceAccessor.
|
||||
*/
|
||||
template <typename T>
|
||||
@@ -61,17 +61,17 @@ public:
|
||||
operator Enum () const {
|
||||
return Enum (m_v);
|
||||
}
|
||||
void Connect (const CallbackBase &cb) {
|
||||
m_cb.Connect (cb);
|
||||
void ConnectWithoutContext (const CallbackBase &cb) {
|
||||
m_cb.ConnectWithoutContext (cb);
|
||||
}
|
||||
void ConnectWithContext (const CallbackBase &cb, std::string path) {
|
||||
m_cb.ConnectWithContext (cb, path);
|
||||
void Connect (const CallbackBase &cb, std::string path) {
|
||||
m_cb.Connect (cb, path);
|
||||
}
|
||||
void Disconnect (const CallbackBase &cb) {
|
||||
m_cb.Disconnect (cb);
|
||||
void DisconnectWithoutContext (const CallbackBase &cb) {
|
||||
m_cb.DisconnectWithoutContext (cb);
|
||||
}
|
||||
void DisconnectWithContext (const CallbackBase &cb, std::string path) {
|
||||
m_cb.DisconnectWithContext (cb, path);
|
||||
void Disconnect (const CallbackBase &cb, std::string path) {
|
||||
m_cb.Disconnect (cb, path);
|
||||
}
|
||||
void Set (const T &v) {
|
||||
if (m_v != v)
|
||||
|
||||
@@ -47,7 +47,7 @@ void
|
||||
WifiTrace::TraceAllNetDeviceRx (void)
|
||||
{
|
||||
Packet::EnableMetadata ();
|
||||
NodeList::Connect ("/nodes/*/devices/*/rx",
|
||||
NodeList::ConnectWithoutContext ("/nodes/*/devices/*/rx",
|
||||
MakeCallback (&WifiTrace::LogDevRx, this));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ void
|
||||
WifiTrace::TraceAllNetDeviceTx (void)
|
||||
{
|
||||
Packet::EnableMetadata ();
|
||||
NodeList::Connect ("/nodes/*/devices/*/tx",
|
||||
NodeList::ConnectWithoutContext ("/nodes/*/devices/*/tx",
|
||||
MakeCallback (&WifiTrace::LogDevTx, this));
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ void
|
||||
WifiTrace::TraceAllPhy (void)
|
||||
{
|
||||
Packet::EnableMetadata ();
|
||||
NodeList::Connect ("/nodes/*/devices/*/*/state",
|
||||
NodeList::ConnectWithoutContext ("/nodes/*/devices/*/*/state",
|
||||
MakeCallback (&WifiTrace::LogPhy, this));
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ void
|
||||
WifiTrace::TraceAllErrors (void)
|
||||
{
|
||||
Packet::EnableMetadata ();
|
||||
NodeList::Connect ("/nodes/*/devices/*/*/error",
|
||||
NodeList::ConnectWithoutContext ("/nodes/*/devices/*/*/error",
|
||||
MakeCallback (&WifiTrace::LogErrors, this));
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ void
|
||||
WifiTrace::TraceAckTimeouts (void)
|
||||
{
|
||||
Packet::EnableMetadata ();
|
||||
NodeList::Connect ("/nodes/*/devices/*/*/ackTimeout",
|
||||
NodeList::ConnectWithoutContext ("/nodes/*/devices/*/*/ackTimeout",
|
||||
MakeCallback (&WifiTrace::LogAckTimeout, this));
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ void
|
||||
WifiTrace::TraceCtsTimeouts (void)
|
||||
{
|
||||
Packet::EnableMetadata ();
|
||||
NodeList::Connect ("/nodes/*/devices/*/*/ctsTimeout",
|
||||
NodeList::ConnectWithoutContext ("/nodes/*/devices/*/*/ctsTimeout",
|
||||
MakeCallback (&WifiTrace::LogCtsTimeout, this));
|
||||
}
|
||||
|
||||
|
||||
@@ -40,18 +40,18 @@ void
|
||||
AsciiTrace::TraceAllQueues (void)
|
||||
{
|
||||
Packet::EnableMetadata ();
|
||||
Config::ConnectWithContext ("/NodeList/*/DeviceList/*/TxQueue/Enqueue",
|
||||
Config::Connect ("/NodeList/*/DeviceList/*/TxQueue/Enqueue",
|
||||
MakeCallback (&AsciiTrace::LogDevQueueEnqueue, this));
|
||||
Config::ConnectWithContext ("/NodeList/*/DeviceList/*/TxQueue/Dequeue",
|
||||
Config::Connect ("/NodeList/*/DeviceList/*/TxQueue/Dequeue",
|
||||
MakeCallback (&AsciiTrace::LogDevQueueDequeue, this));
|
||||
Config::ConnectWithContext ("/NodeList/*/DeviceList/*/TxQueue/Drop",
|
||||
Config::Connect ("/NodeList/*/DeviceList/*/TxQueue/Drop",
|
||||
MakeCallback (&AsciiTrace::LogDevQueueDrop, this));
|
||||
}
|
||||
void
|
||||
AsciiTrace::TraceAllNetDeviceRx (void)
|
||||
{
|
||||
Packet::EnableMetadata ();
|
||||
Config::ConnectWithContext ("/NodeList/*/DeviceList/*/Rx",
|
||||
Config::Connect ("/NodeList/*/DeviceList/*/Rx",
|
||||
MakeCallback (&AsciiTrace::LogDevRx, this));
|
||||
}
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@ PcapTrace::~PcapTrace ()
|
||||
void
|
||||
PcapTrace::TraceAllIp (void)
|
||||
{
|
||||
Config::ConnectWithContext ("/NodeList/*/$Ipv4L3Protocol/Tx",
|
||||
Config::Connect ("/NodeList/*/$Ipv4L3Protocol/Tx",
|
||||
MakeCallback (&PcapTrace::LogTxIp, this));
|
||||
Config::ConnectWithContext ("/NodeList/*/$Ipv4L3Protocol/Rx",
|
||||
Config::Connect ("/NodeList/*/$Ipv4L3Protocol/Rx",
|
||||
MakeCallback (&PcapTrace::LogRxIp, this));
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ HierarchicalMobilityModel::SetChild (Ptr<MobilityModel> model)
|
||||
notifier = CreateObject<MobilityModelNotifier> ();
|
||||
m_child->AggregateObject (notifier);
|
||||
}
|
||||
notifier->TraceConnect ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ChildChanged, this));
|
||||
notifier->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ChildChanged, this));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -72,7 +72,7 @@ HierarchicalMobilityModel::SetParent (Ptr<MobilityModel> model)
|
||||
notifier = CreateObject<MobilityModelNotifier> ();
|
||||
m_parent->AggregateObject (notifier);
|
||||
}
|
||||
notifier->TraceConnect ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ParentChanged, this));
|
||||
notifier->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ParentChanged, this));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user