|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/core-module.h"
23 #include "ns3/network-module.h"
35 template <
typename T>
inline
36 std::string
TypeName (
void) {
return "unknown"; }
80 << (int64_t)oldValue <<
" -> "
85 else if (newValue != 1)
96 TracedValueCbSink <int64_t> (oldValue.
GetInteger (),
125 template <
typename T>
138 TypeId ( (
"CheckTvCb<" + TypeName<T>() +
">").c_str ())
140 .AddTraceSource (
"value",
141 "A value being traced.",
143 (
"ns3::TracedValueCallback::" + TypeName<T>()).c_str () )
157 template <
typename U>
160 bool ok = TraceConnectWithoutContext (
"value",
MakeCallback (cb));
161 std::cout << GetTypeId () <<
": "
162 << (ok ?
"connected " :
"failed to connect ")
163 << GetTypeId ().GetTraceSource (0).callback
170 m_value = m_value + (T) 1;
174 std::cout << std::endl;
177 g_Result =
"failed to connect callback";
195 template <
typename T,
typename U>
198 U
sink = TracedValueCbSink<T>;
199 CreateObject<CheckTvCb<T> > ()->Invoke (
sink);
206 virtual void DoRun (
void);
211 :
TestCase (
"Check basic TracedValue callback operation")
218 CheckType< bool, TracedValueCallback::Bool > ();
219 CheckType< int8_t, TracedValueCallback::Int8 > ();
220 CheckType< int16_t, TracedValueCallback::Int16 > ();
221 CheckType< int32_t, TracedValueCallback::Int32 > ();
222 CheckType< int64_t, TracedValueCallback::Int64 > ();
223 CheckType< uint8_t, TracedValueCallback::Uint8 > ();
224 CheckType< uint16_t, TracedValueCallback::Uint16 > ();
225 CheckType< uint32_t, TracedValueCallback::Uint32 > ();
226 CheckType< uint64_t, TracedValueCallback::Uint64 > ();
227 CheckType< double, TracedValueCallback::Double > ();
228 CheckType< Time, TracedValueCallback::Time > ();
229 CheckType< SequenceNumber32, TracedValueCallback::SequenceNumber32 > ();
239 :
TestSuite (
"traced-value-callback", UNIT)
a unique identifier for an interface.
std::string TypeName< int16_t >(void)
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
std::string TypeName< uint16_t >(void)
std::string TypeName< uint8_t >(void)
std::string TypeName< Time >(void)
std::string g_Result
Result of callback test.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void DoRun(void)
Implementation to actually run this TestCase.
TracedValueCallbackTestCase()
std::string TypeName< uint32_t >(void)
std::string TypeName< int8_t >(void)
TracedValueCallbackTestSuite()
int64_t GetInteger(void) const
Get the raw time value, in the current resolution unit.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
std::string TypeName< double >(void)
std::string TypeName< uint64_t >(void)
static TypeId GetTypeId(void)
Register this type.
std::string TypeName< bool >(void)
std::string TypeName< SequenceNumber32 >(void)
A base class which provides memory management and object aggregation.
void TracedValueCbSink(T oldValue, T newValue)
Template for TracedValue sink functions.
CheckTvCb(void)
Constructor.
Simulation virtual time values and global simulation resolution.
std::string TypeName(void)
std::string TypeName< int64_t >(void)
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
void Invoke(U cb)
Check the sink function against the actual TracedValue invocation.
static TracedValueCallbackTestSuite tracedValueCallbackTestSuite
NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Trace classes with value semantics.
virtual ~TracedValueCallbackTestCase()
A class to check that the callback function typedef will actually connect to the TracedValue.
void TracedValueCbSink< Time >(Time oldValue, Time newValue)
TracedValueCbSink specialization for Time.
std::string TypeName< int32_t >(void)
void TracedValueCbSink< SequenceNumber32 >(SequenceNumber32 oldValue, SequenceNumber32 newValue)
TracedValueCbSink specialization for SequenceNumber32.
void CheckType(void)
Check the TracedValue typedef against TracedValueCbSink<T>.