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
This commit is contained in:
Peter D. Barnes, Jr.
2015-07-29 13:56:55 -07:00
parent 6c8fcc72b9
commit baddf3f749
28 changed files with 90 additions and 74 deletions

View File

@@ -255,7 +255,7 @@ parameter, this could be declared like,
<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 @@ simple Object we can work with.
.AddTraceSource ("MyInteger",
"An integer value to trace.",
MakeTraceSourceAccessor (&MyObject::m_myInt),
"ns3::Traced::Value::Int32Callback")
"ns3::TracedValueCallback::Int32")
;
return tid;
}
@@ -399,11 +399,11 @@ The ``TracedValue<>`` declaration provides the infrastructure that
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 @@ Repeating the "CourseChange" trace source entry from
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 @@ Callback function that takes a string context, then the template
arguments::
void
CourseChange (const std::string context, Ptr<const MobilityModel> model)
CourseChange (std::string context, Ptr<const MobilityModel> model)
{
...
}
@@ -942,7 +942,7 @@ visible in your local file, you can add the keyword ``static`` and
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 @@ the callback process. On use of any of the operators above with a
``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``, so the expected callback signature for the sink function
``traceSink`` will be::
void (* TracedValueCallback)(const int32_t oldValue, const int32_t newValue);
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 @@ agruments to ``AddTraceSource``: the Attribute name for the Config
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 @@ the list of TraceSources you will find
* **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

View File

@@ -39,7 +39,7 @@ public:
.AddTraceSource ("MyInteger",
"An integer value to trace.",
MakeTraceSourceAccessor (&MyObject::m_myInt),
"ns3::TracedValue::Int32Callback")
"ns3::TracedValueCallback::Int32")
;
return tid;
}

View File

@@ -531,15 +531,6 @@ public:
*/
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 @@ private:
}; // 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 ();

View File

@@ -60,6 +60,32 @@ namespace ns3 {
* - ns3::SequenceNumber32TracedValueCallback
*/
/**
* \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
*
@@ -225,23 +251,6 @@ public:
}
/**@}*/
/**
* 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;

View File

@@ -195,7 +195,7 @@ public:
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")

View File

@@ -98,7 +98,7 @@ ConfigTestObject::GetTypeId (void)
MakeIntegerChecker<int16_t> ())
.AddTraceSource ("Source", "XX",
MakeTraceSourceAccessor (&ConfigTestObject::m_trace),
"ns3::TracedValue::Int16Callback")
"ns3::TracedValueCallback::Int16")
;
return tid;
}

View File

@@ -55,11 +55,11 @@ BasicEnergyHarvester::GetTypeId (void)
.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;
}

View File

@@ -69,7 +69,7 @@ BasicEnergySource::GetTypeId (void)
.AddTraceSource ("RemainingEnergy",
"Remaining energy at BasicEnergySource.",
MakeTraceSourceAccessor (&BasicEnergySource::m_remainingEnergyJ),
"ns3::TracedValue::DoubleCallback")
"ns3::TracedValueCallback::Double")
;
return tid;
}

View File

@@ -106,7 +106,7 @@ LiIonEnergySource::GetTypeId (void)
.AddTraceSource ("RemainingEnergy",
"Remaining energy at BasicEnergySource.",
MakeTraceSourceAccessor (&LiIonEnergySource::m_remainingEnergyJ),
"ns3::TracedValue::DoubleCallback")
"ns3::TracedValueCallback::Double")
;
return tid;
}

View File

@@ -83,7 +83,7 @@ RvBatteryModel::GetTypeId (void)
.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),

View File

@@ -40,7 +40,7 @@ SimpleDeviceEnergyModel::GetTypeId (void)
.AddTraceSource ("TotalEnergyConsumption",
"Total energy consumption of the radio device.",
MakeTraceSourceAccessor (&SimpleDeviceEnergyModel::m_totalEnergyConsumption),
"ns3::TracedValue::DoubleCallback")
"ns3::TracedValueCallback::Double")
;
return tid;
}

View File

@@ -184,23 +184,23 @@ TypeId CoDelQueue::GetTypeId (void)
.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 @@ TypeId CoDelQueue::GetTypeId (void)
.AddTraceSource ("DropNext",
"Time until next packet drop",
MakeTraceSourceAccessor (&CoDelQueue::m_dropNext),
"ns3::TracedValue::Uint32Callback")
"ns3::TracedValueCallback::Uint32")
;
return tid;

View File

@@ -58,11 +58,11 @@ NscTcpSocketImpl::GetTypeId ()
.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),

View File

@@ -141,7 +141,7 @@ TcpSocketBase::GetTypeId (void)
.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 @@ TcpSocketBase::GetTypeId (void)
.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;
}

View File

@@ -64,7 +64,7 @@ TcpWestwood::GetTypeId (void)
MakeEnumChecker(TcpWestwood::WESTWOOD, "Westwood",TcpWestwood::WESTWOODPLUS, "WestwoodPlus"))
.AddTraceSource("EstimatedBW", "The estimated bandwidth",
MakeTraceSourceAccessor(&TcpWestwood::m_currentBW),
"ns3::TracedValue::DoubleCallback");
"ns3::TracedValueCallback::Double");
return tid;
}

View File

@@ -482,6 +482,8 @@ typedef SequenceNumber<uint16_t, int16_t> SequenceNumber16;
*/
typedef SequenceNumber<uint8_t, int8_t> SequenceNumber8;
namespace TracedValueCallback {
/**
* \ingroup network
* TracedValue callback signature for SequenceNumber32
@@ -489,8 +491,10 @@ typedef SequenceNumber<uint8_t, int8_t> SequenceNumber8;
* \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

View File

@@ -66,7 +66,7 @@ Emitter::GetTypeId (void)
.AddTraceSource ("Counter",
"sample counter",
MakeTraceSourceAccessor (&Emitter::m_counter),
"ns3::TracedValue::DoubleCallback")
"ns3::TracedValueCallback::Double")
;
return tid;
}

View File

@@ -69,7 +69,7 @@ Emitter::GetTypeId (void)
.AddTraceSource ("Counter",
"sample counter",
MakeTraceSourceAccessor (&Emitter::m_counter),
"ns3::TracedValue::DoubleCallback")
"ns3::TracedValueCallback::Double")
;
return tid;
}

View File

@@ -68,7 +68,7 @@ Emitter::GetTypeId (void)
.AddTraceSource ("Counter",
"sample counter",
MakeTraceSourceAccessor (&Emitter::m_counter),
"ns3::TracedValue::DoubleCallback")
"ns3::TracedValueCallback::Double")
;
return tid;
}

View File

@@ -44,7 +44,7 @@ BooleanProbe::GetTypeId ()
.AddTraceSource ( "Output",
"The bool that serves as output for this probe",
MakeTraceSourceAccessor (&BooleanProbe::m_output),
"ns3::TracedValue::BoolCallback")
"ns3::TracedValueCallback::Bool")
;
return tid;
}

View File

@@ -44,7 +44,7 @@ DoubleProbe::GetTypeId ()
.AddTraceSource ( "Output",
"The double that serves as output for this probe",
MakeTraceSourceAccessor (&DoubleProbe::m_output),
"ns3::TracedValue::DoubleCallback")
"ns3::TracedValueCallback::Double")
;
return tid;
}

View File

@@ -45,7 +45,7 @@ TimeProbe::GetTypeId ()
.AddTraceSource ("Output",
"The double valued (units of seconds) probe output",
MakeTraceSourceAccessor (&TimeProbe::m_output),
"ns3::TracedValue::DoubleCallback")
"ns3::TracedValueCallback::Double")
;
return tid;
}

View File

@@ -43,7 +43,7 @@ Uinteger16Probe::GetTypeId ()
.AddTraceSource ( "Output",
"The uint16_t that serves as output for this probe",
MakeTraceSourceAccessor (&Uinteger16Probe::m_output),
"ns3::TracedValue::Uint16Callback")
"ns3::TracedValueCallback::Uint16")
;
return tid;
}

View File

@@ -43,7 +43,7 @@ Uinteger32Probe::GetTypeId ()
.AddTraceSource ( "Output",
"The uint32_t that serves as output for this probe",
MakeTraceSourceAccessor (&Uinteger32Probe::m_output),
"ns3::TracedValue::Uint32Callback")
"ns3::TracedValueCallback::Uint32")
;
return tid;
}

View File

@@ -43,7 +43,7 @@ Uinteger8Probe::GetTypeId ()
.AddTraceSource ( "Output",
"The uint8_t that serves as output for this probe",
MakeTraceSourceAccessor (&Uinteger8Probe::m_output),
"ns3::TracedValue::Uint8Callback")
"ns3::TracedValueCallback::Uint8")
;
return tid;
}

View File

@@ -64,7 +64,7 @@ SampleEmitter::GetTypeId (void)
.SetParent<Object> ()
.AddTraceSource ("Emitter", "XX",
MakeTraceSourceAccessor (&SampleEmitter::m_trace),
"ns3::TracedValue::DoubleCallback")
"ns3::TracedValueCallback::Double")
;
return tid;
}

View File

@@ -66,7 +66,7 @@ AcousticModemEnergyModel::GetTypeId (void)
.AddTraceSource ("TotalEnergyConsumption",
"Total energy consumption of the modem device.",
MakeTraceSourceAccessor (&AcousticModemEnergyModel::m_totalEnergyConsumption),
"ns3::TracedValue::DoubleCallback")
"ns3::TracedValueCallback::Double")
;
return tid;
}

View File

@@ -83,7 +83,7 @@ WifiRadioEnergyModel::GetTypeId (void)
.AddTraceSource ("TotalEnergyConsumption",
"Total energy consumption of the radio device.",
MakeTraceSourceAccessor (&WifiRadioEnergyModel::m_totalEnergyConsumption),
"ns3::TracedValue::DoubleCallback")
"ns3::TracedValueCallback::Double")
;
return tid;
}