Refactor TracedValue callback function signatures.
Move from template class TracedValue to namespace TracedValueCallback.
Rename from [type]Callback to just [type]:
TracedValue<double>::DoubleCallback -> TracedValueCallback::Double
--- a/doc/tutorial/source/tracing.rst Thu Aug 13 12:10:01 2015 -0700
+++ b/doc/tutorial/source/tracing.rst Wed Jul 29 13:56:55 2015 -0700
@@ -255,7 +255,7 @@
<http://www.parashift.com/c++-faq/pointers-to-members.html>`_ before
writing code like this!) What you get from this is a variable named
simply ``pfi`` that is initialized to the value 0. If you want to
-initialize this pointer to something meaningful, you have to have a
+initialize this pointer to something meaningful, you need to have a
function with a matching signature. In this case, you could provide a
function that looks like::
@@ -370,7 +370,7 @@
.AddTraceSource ("MyInteger",
"An integer value to trace.",
MakeTraceSourceAccessor (&MyObject::m_myInt),
- "ns3::Traced::Value::Int32Callback")
+ "ns3::TracedValueCallback::Int32")
;
return tid;
}
@@ -399,11 +399,11 @@
drives the callback process. Any time the underlying value is changed
the TracedValue mechanism will provide both the old and the new value
of that variable, in this case an ``int32_t`` value. The trace
-sink function for this TracedValue will need the signature
+sink function ``traceSink`` for this TracedValue will need the signature
::
- void (* TracedValueCallback)(const int32_t oldValue, const int32_t newValue);
+ void (* traceSink)(int32_t oldValue, int32_t newValue);
All trace sinks hooking this trace source must have this signature.
We'll discuss below how you can determine the required callback
@@ -866,7 +866,7 @@
The callback signature is given as a link to the relevant ``typedef``,
where we find
- ``typedef void (* CourseChangeCallback)(const std::string context, Ptr<const MobilityModel> * model);``
+ ``typedef void (* CourseChangeCallback)(std::string context, Ptr<const MobilityModel> * model);``
**TracedCallback** signature for course change notifications.
@@ -932,7 +932,7 @@
arguments::
void
- CourseChange (const std::string context, Ptr<const MobilityModel> model)
+ CourseChange (std::string context, Ptr<const MobilityModel> model)
{
...
}
@@ -942,7 +942,7 @@
come up with::
static void
- CourseChange (const std::string path, Ptr<const MobilityModel> model)
+ CourseChange (std::string path, Ptr<const MobilityModel> model)
{
...
}
@@ -1204,11 +1204,12 @@
``TracedValue`` it will provide both the old and the new value of that
variable, in this case an ``int32_t`` value. By inspection of the
``TracedValue`` declaration, we know the trace sink function will have
-arguments ``(const int32_t oldValue, const int32_t newValue)``. The
+arguments ``(int32_t oldValue, int32_t newValue)``. The
return type for a ``TracedValue`` callback function is always
-``void``, so the expected callback signature will be::
-
- void (* TracedValueCallback)(const int32_t oldValue, const int32_t newValue);
+``void``, so the expected callback signature for the sink function
+``traceSink`` will be::
+
+ void (* traceSink)(int32_t oldValue, int32_t newValue);
The ``.AddTraceSource`` in the ``GetTypeId`` method provides the
"hooks" used for connecting the trace source to the outside world
@@ -1217,7 +1218,7 @@
system, a help string, and the address of the TracedValue class data
member.
-The final string argument, "ns3::Traced::Value::Int32" in the example,
+The final string argument, "ns3::TracedValueCallback::Int32" in the example,
is the name of a ``typedef`` for the callback function signature. We
require these signatures to be defined, and give the fully qualified
type name to ``AddTraceSource``, so the API documentation can link a
@@ -1271,12 +1272,12 @@
* **CongestionWindow**: The TCP connnection's congestion window
- Callback signature: **ns3::Traced::Value::Uint322Callback**
+ Callback signature: **ns3::TracedValueCallback::Uint32**
Clicking on the callback ``typedef`` link we see the signature
you now know to expect::
- typedef void(* ns3::Traced::Value::Int32Callback)(const int32_t oldValue, const int32_t newValue)
+ typedef void(* ns3::TracedValueCallback::Int32)(int32_t oldValue, int32_t newValue)
You should now understand this code completely. If we have a pointer
to the ``TcpNewReno``, we can ``TraceConnect`` to the
--- a/examples/tutorial/fourth.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/examples/tutorial/fourth.cc Wed Jul 29 13:56:55 2015 -0700
@@ -39,7 +39,7 @@
.AddTraceSource ("MyInteger",
"An integer value to trace.",
MakeTraceSourceAccessor (&MyObject::m_myInt),
- "ns3::TracedValue::Int32Callback")
+ "ns3::TracedValueCallback::Int32")
;
return tid;
}
--- a/src/core/model/nstime.h Thu Aug 13 12:10:01 2015 -0700
+++ b/src/core/model/nstime.h Wed Jul 29 13:56:55 2015 -0700
@@ -531,15 +531,6 @@
*/
TimeWithUnit As (const enum Unit unit) const;
- /**
- * TracedValue callback signature for Time
- *
- * \param [in] oldValue Original value of the traced variable
- * \param [in] newValue New value of the traced variable
- */
- typedef void (* TracedValueCallback)(const Time oldValue,
- const Time newValue);
-
private:
/** How to convert between other units and the current unit. */
struct Information
@@ -717,6 +708,17 @@
}; // class Time
+namespace TracedValueCallback {
+
+ /**
+ * TracedValue callback signature for Time
+ *
+ * \param [in] oldValue Original value of the traced variable
+ * \param [in] newValue New value of the traced variable
+ */
+ typedef void (* Time)(Time oldValue, Time newValue);
+
+} // namespace TracedValueCallback
/// Force static initialization of Time
static bool NS_UNUSED_GLOBAL (g_TimeStaticInit) = Time::StaticInit ();
--- a/src/core/model/traced-value.h Thu Aug 13 12:10:01 2015 -0700
+++ b/src/core/model/traced-value.h Wed Jul 29 13:56:55 2015 -0700
@@ -63,6 +63,32 @@
/**
* \ingroup tracing
*
+ * \brief TracedValue Callback function types.
+ */
+namespace TracedValueCallback {
+
+ /**
+ * TracedValue Callback signature for POD.
+ *
+ * \param [in] oldValue original value of the traced variable
+ * \param [in] newValue new value of the traced variable
+ * @{
+ */
+ typedef void (* Bool) (bool oldValue, bool newValue);
+ typedef void (* Int8) (int8_t oldValue, int8_t newValue);
+ typedef void (* Uint8) (uint8_t oldValue, uint8_t newValue);
+ typedef void (* Int16) (int16_t oldValue, int16_t newValue);
+ typedef void (* Uint16)(uint16_t oldValue, uint16_t newValue);
+ typedef void (* Int32) (int32_t oldValue, int32_t newValue);
+ typedef void (* Uint32)(uint32_t oldValue, uint32_t newValue);
+ typedef void (* Double)(double oldValue, double newValue);
+ /**@}*/
+} // namespace TracedValueCallback
+
+
+/**
+ * \ingroup tracing
+ *
* \brief Trace classes with value semantics
*
* If you want to trace the change of value of a class or
@@ -225,23 +251,6 @@
}
/**@}*/
- /**
- * TracedValue Callback signature for POD.
- *
- * \param [in] oldValue original value of the traced variable
- * \param [in] newValue new value of the traced variable
- * @{
- */
- typedef void (* BoolCallback) (const bool oldValue, const bool newValue);
- typedef void (* Int8Callback) (const int8_t oldValue, const int8_t newValue);
- typedef void (* Uint8Callback) (const uint8_t oldValue, const uint8_t newValue);
- typedef void (* Int16Callback) (const int16_t oldValue, const int16_t newValue);
- typedef void (* Uint16Callback)(const uint16_t oldValue, const uint16_t newValue);
- typedef void (* Int32Callback) (const int32_t oldValue, const int32_t newValue);
- typedef void (* Uint32Callback)(const uint32_t oldValue, const uint32_t newValue);
- typedef void (* DoubleCallback)(const double oldValue, const double newValue);
- /**@}*/
-
private:
/** The underlying value. */
T m_v;
--- a/src/core/test/attribute-test-suite.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/core/test/attribute-test-suite.cc Wed Jul 29 13:56:55 2015 -0700
@@ -195,7 +195,7 @@
MakeValueClassTestChecker ())
.AddTraceSource ("Source1", "help test",
MakeTraceSourceAccessor (&AttributeObjectTest::m_intSrc1),
- "ns3::TracedValue::Int8Callback")
+ "ns3::TracedValueCallback::Int8")
.AddTraceSource ("Source2", "help text",
MakeTraceSourceAccessor (&AttributeObjectTest::m_cb),
"ns3::AttributeObjectTest::NumericTracedCallback")
--- a/src/core/test/config-test-suite.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/core/test/config-test-suite.cc Wed Jul 29 13:56:55 2015 -0700
@@ -98,7 +98,7 @@
MakeIntegerChecker<int16_t> ())
.AddTraceSource ("Source", "XX",
MakeTraceSourceAccessor (&ConfigTestObject::m_trace),
- "ns3::TracedValue::Int16Callback")
+ "ns3::TracedValueCallback::Int16")
;
return tid;
}
--- a/src/energy/model/basic-energy-harvester.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/energy/model/basic-energy-harvester.cc Wed Jul 29 13:56:55 2015 -0700
@@ -55,11 +55,11 @@
.AddTraceSource ("HarvestedPower",
"Harvested power by the BasicEnergyHarvester.",
MakeTraceSourceAccessor (&BasicEnergyHarvester::m_harvestedPower),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
.AddTraceSource ("TotalEnergyHarvested",
"Total energy harvested by the harvester.",
MakeTraceSourceAccessor (&BasicEnergyHarvester::m_totalEnergyHarvestedJ),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
;
return tid;
}
--- a/src/energy/model/basic-energy-source.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/energy/model/basic-energy-source.cc Wed Jul 29 13:56:55 2015 -0700
@@ -69,7 +69,7 @@
.AddTraceSource ("RemainingEnergy",
"Remaining energy at BasicEnergySource.",
MakeTraceSourceAccessor (&BasicEnergySource::m_remainingEnergyJ),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
;
return tid;
}
--- a/src/energy/model/li-ion-energy-source.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/energy/model/li-ion-energy-source.cc Wed Jul 29 13:56:55 2015 -0700
@@ -106,7 +106,7 @@
.AddTraceSource ("RemainingEnergy",
"Remaining energy at BasicEnergySource.",
MakeTraceSourceAccessor (&LiIonEnergySource::m_remainingEnergyJ),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
;
return tid;
}
--- a/src/energy/model/rv-battery-model.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/energy/model/rv-battery-model.cc Wed Jul 29 13:56:55 2015 -0700
@@ -83,7 +83,7 @@
.AddTraceSource ("RvBatteryModelBatteryLevel",
"RV battery model battery level.",
MakeTraceSourceAccessor (&RvBatteryModel::m_batteryLevel),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
.AddTraceSource ("RvBatteryModelBatteryLifetime",
"RV battery model battery lifetime.",
MakeTraceSourceAccessor (&RvBatteryModel::m_lifetime),
--- a/src/energy/model/simple-device-energy-model.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/energy/model/simple-device-energy-model.cc Wed Jul 29 13:56:55 2015 -0700
@@ -40,7 +40,7 @@
.AddTraceSource ("TotalEnergyConsumption",
"Total energy consumption of the radio device.",
MakeTraceSourceAccessor (&SimpleDeviceEnergyModel::m_totalEnergyConsumption),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
;
return tid;
}
--- a/src/internet/model/codel-queue.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/internet/model/codel-queue.cc Wed Jul 29 13:56:55 2015 -0700
@@ -184,23 +184,23 @@
.AddTraceSource ("Count",
"CoDel count",
MakeTraceSourceAccessor (&CoDelQueue::m_count),
- "ns3::TracedValue::Uint32Callback")
+ "ns3::TracedValueCallback::Uint32")
.AddTraceSource ("DropCount",
"CoDel drop count",
MakeTraceSourceAccessor (&CoDelQueue::m_dropCount),
- "ns3::TracedValue::Uint32Callback")
+ "ns3::TracedValueCallback::Uint32")
.AddTraceSource ("LastCount",
"CoDel lastcount",
MakeTraceSourceAccessor (&CoDelQueue::m_lastCount),
- "ns3::TracedValue::Uint32Callback")
+ "ns3::TracedValueCallback::Uint32")
.AddTraceSource ("DropState",
"Dropping state",
MakeTraceSourceAccessor (&CoDelQueue::m_dropping),
- "ns3::TracedValue::BoolCallback")
+ "ns3::TracedValueCallback::Bool")
.AddTraceSource ("BytesInQueue",
"Number of bytes in the queue",
MakeTraceSourceAccessor (&CoDelQueue::m_bytesInQueue),
- "ns3::TracedValue::Uint32Callback")
+ "ns3::TracedValueCallback::Uint32")
.AddTraceSource ("Sojourn",
"Time in the queue",
MakeTraceSourceAccessor (&CoDelQueue::m_sojourn),
@@ -208,7 +208,7 @@
.AddTraceSource ("DropNext",
"Time until next packet drop",
MakeTraceSourceAccessor (&CoDelQueue::m_dropNext),
- "ns3::TracedValue::Uint32Callback")
+ "ns3::TracedValueCallback::Uint32")
;
return tid;
--- a/src/internet/model/nsc-tcp-socket-impl.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/internet/model/nsc-tcp-socket-impl.cc Wed Jul 29 13:56:55 2015 -0700
@@ -58,11 +58,11 @@
.AddTraceSource ("CongestionWindow",
"The TCP connection's congestion window",
MakeTraceSourceAccessor (&NscTcpSocketImpl::m_cWnd),
- "ns3::TracedValue::Uint32Callback")
+ "ns3::TracedValueCallback::Uint32")
.AddTraceSource ("SlowStartThreshold",
"TCP slow start threshold (bytes)",
MakeTraceSourceAccessor (&NscTcpSocketImpl::m_ssThresh),
- "ns3::TracedValue::Uint32Callback")
+ "ns3::TracedValueCallback::Uint32")
.AddTraceSource ("State",
"TCP state",
MakeTraceSourceAccessor (&NscTcpSocketImpl::m_state),
--- a/src/internet/model/tcp-socket-base.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/internet/model/tcp-socket-base.cc Wed Jul 29 13:56:55 2015 -0700
@@ -141,7 +141,7 @@
.AddTraceSource ("RWND",
"Remote side's flow control window",
MakeTraceSourceAccessor (&TcpSocketBase::m_rWnd),
- "ns3::TracedValue::Uint32Callback")
+ "ns3::TracedValueCallback::Uint32")
.AddTraceSource ("HighestRxSequence",
"Highest sequence number received from peer",
MakeTraceSourceAccessor (&TcpSocketBase::m_highRxMark),
@@ -153,11 +153,11 @@
.AddTraceSource ("CongestionWindow",
"The TCP connection's congestion window",
MakeTraceSourceAccessor (&TcpSocketBase::m_cWnd),
- "ns3::TracedValue::Uint32Callback")
+ "ns3::TracedValueCallback::Uint32")
.AddTraceSource ("SlowStartThreshold",
"TCP slow start threshold (bytes)",
MakeTraceSourceAccessor (&TcpSocketBase::m_ssThresh),
- "ns3::TracedValue::Uint32Callback")
+ "ns3::TracedValueCallback::Uint32")
;
return tid;
}
--- a/src/internet/model/tcp-westwood.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/internet/model/tcp-westwood.cc Wed Jul 29 13:56:55 2015 -0700
@@ -64,7 +64,7 @@
MakeEnumChecker(TcpWestwood::WESTWOOD, "Westwood",TcpWestwood::WESTWOODPLUS, "WestwoodPlus"))
.AddTraceSource("EstimatedBW", "The estimated bandwidth",
MakeTraceSourceAccessor(&TcpWestwood::m_currentBW),
- "ns3::TracedValue::DoubleCallback");
+ "ns3::TracedValueCallback::Double");
return tid;
}
--- a/src/network/utils/sequence-number.h Thu Aug 13 12:10:01 2015 -0700
+++ b/src/network/utils/sequence-number.h Wed Jul 29 13:56:55 2015 -0700
@@ -482,6 +482,8 @@
*/
typedef SequenceNumber<uint8_t, int8_t> SequenceNumber8;
+namespace TracedValueCallback {
+
/**
* \ingroup network
* TracedValue callback signature for SequenceNumber32
@@ -489,8 +491,10 @@
* \param [in] oldValue original value of the traced variable
* \param [in] newValue new value of the traced variable
*/
-typedef void (* SequenceNumber32TracedValueCallback)(const SequenceNumber32 oldValue,
- const SequenceNumber32 newValue);
+typedef void (* SequenceNumber32)(SequenceNumber32 oldValue,
+ SequenceNumber32 newValue);
+
+} // namespace TracedValueCallback
} // namespace ns3
--- a/src/stats/examples/double-probe-example.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/stats/examples/double-probe-example.cc Wed Jul 29 13:56:55 2015 -0700
@@ -66,7 +66,7 @@
.AddTraceSource ("Counter",
"sample counter",
MakeTraceSourceAccessor (&Emitter::m_counter),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
;
return tid;
}
--- a/src/stats/examples/file-helper-example.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/stats/examples/file-helper-example.cc Wed Jul 29 13:56:55 2015 -0700
@@ -69,7 +69,7 @@
.AddTraceSource ("Counter",
"sample counter",
MakeTraceSourceAccessor (&Emitter::m_counter),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
;
return tid;
}
--- a/src/stats/examples/gnuplot-helper-example.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/stats/examples/gnuplot-helper-example.cc Wed Jul 29 13:56:55 2015 -0700
@@ -68,7 +68,7 @@
.AddTraceSource ("Counter",
"sample counter",
MakeTraceSourceAccessor (&Emitter::m_counter),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
;
return tid;
}
--- a/src/stats/model/boolean-probe.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/stats/model/boolean-probe.cc Wed Jul 29 13:56:55 2015 -0700
@@ -44,7 +44,7 @@
.AddTraceSource ( "Output",
"The bool that serves as output for this probe",
MakeTraceSourceAccessor (&BooleanProbe::m_output),
- "ns3::TracedValue::BoolCallback")
+ "ns3::TracedValueCallback::Bool")
;
return tid;
}
--- a/src/stats/model/double-probe.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/stats/model/double-probe.cc Wed Jul 29 13:56:55 2015 -0700
@@ -44,7 +44,7 @@
.AddTraceSource ( "Output",
"The double that serves as output for this probe",
MakeTraceSourceAccessor (&DoubleProbe::m_output),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
;
return tid;
}
--- a/src/stats/model/time-probe.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/stats/model/time-probe.cc Wed Jul 29 13:56:55 2015 -0700
@@ -45,7 +45,7 @@
.AddTraceSource ("Output",
"The double valued (units of seconds) probe output",
MakeTraceSourceAccessor (&TimeProbe::m_output),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
;
return tid;
}
--- a/src/stats/model/uinteger-16-probe.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/stats/model/uinteger-16-probe.cc Wed Jul 29 13:56:55 2015 -0700
@@ -43,7 +43,7 @@
.AddTraceSource ( "Output",
"The uint16_t that serves as output for this probe",
MakeTraceSourceAccessor (&Uinteger16Probe::m_output),
- "ns3::TracedValue::Uint16Callback")
+ "ns3::TracedValueCallback::Uint16")
;
return tid;
}
--- a/src/stats/model/uinteger-32-probe.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/stats/model/uinteger-32-probe.cc Wed Jul 29 13:56:55 2015 -0700
@@ -43,7 +43,7 @@
.AddTraceSource ( "Output",
"The uint32_t that serves as output for this probe",
MakeTraceSourceAccessor (&Uinteger32Probe::m_output),
- "ns3::TracedValue::Uint32Callback")
+ "ns3::TracedValueCallback::Uint32")
;
return tid;
}
--- a/src/stats/model/uinteger-8-probe.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/stats/model/uinteger-8-probe.cc Wed Jul 29 13:56:55 2015 -0700
@@ -43,7 +43,7 @@
.AddTraceSource ( "Output",
"The uint8_t that serves as output for this probe",
MakeTraceSourceAccessor (&Uinteger8Probe::m_output),
- "ns3::TracedValue::Uint8Callback")
+ "ns3::TracedValueCallback::Uint8")
;
return tid;
}
--- a/src/stats/test/double-probe-test-suite.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/stats/test/double-probe-test-suite.cc Wed Jul 29 13:56:55 2015 -0700
@@ -64,7 +64,7 @@
.SetParent<Object> ()
.AddTraceSource ("Emitter", "XX",
MakeTraceSourceAccessor (&SampleEmitter::m_trace),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
;
return tid;
}
--- a/src/uan/model/acoustic-modem-energy-model.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/uan/model/acoustic-modem-energy-model.cc Wed Jul 29 13:56:55 2015 -0700
@@ -66,7 +66,7 @@
.AddTraceSource ("TotalEnergyConsumption",
"Total energy consumption of the modem device.",
MakeTraceSourceAccessor (&AcousticModemEnergyModel::m_totalEnergyConsumption),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
;
return tid;
}
--- a/src/wifi/model/wifi-radio-energy-model.cc Thu Aug 13 12:10:01 2015 -0700
+++ b/src/wifi/model/wifi-radio-energy-model.cc Wed Jul 29 13:56:55 2015 -0700
@@ -83,7 +83,7 @@
.AddTraceSource ("TotalEnergyConsumption",
"Total energy consumption of the radio device.",
MakeTraceSourceAccessor (&WifiRadioEnergyModel::m_totalEnergyConsumption),
- "ns3::TracedValue::DoubleCallback")
+ "ns3::TracedValueCallback::Double")
;
return tid;
}