24#include "ns3/core-module.h"
25#include "ns3/double-probe.h"
66 .SetGroupName(
"Stats")
68 .AddTraceSource(
"Counter",
71 "ns3::TracedValueCallback::Double");
79 m_var = CreateObject<ExponentialRandomVariable>();
104 DoubleProbe::SetValueByPath(
"/Names/StaticallyAccessedProbe",
m_counter);
118 NS_LOG_DEBUG(
"context: " << context <<
" old " << oldVal <<
" new " << newVal);
131 NS_LOG_DEBUG(
"context: " << context <<
" old " << oldVal <<
" new " << newVal);
135main(
int argc,
char* argv[])
138 cmd.Parse(argc, argv);
142 Names::Add(
"/Names/Emitter", emitter);
164 probe1->SetName(
"ObjectProbe");
167 connected = probe1->ConnectByObject(
"Counter", emitter);
168 NS_ASSERT_MSG(connected,
"Trace source not connected to probe1");
174 NS_ASSERT_MSG(connected,
"Trace source not connected to probe1 Output");
183 probe2->SetName(
"PathProbe");
186 probe2->ConnectByPath(
"/Names/Emitter/Counter");
191 connected = probe2->TraceConnect(
"Output",
192 "/Names/Probes/PathProbe/Output",
194 NS_ASSERT_MSG(connected,
"Trace source not connected to probe2 Output");
201 probe3->SetName(
"StaticallyAccessedProbe");
203 Names::Add(
"/Names/Probes", probe3->GetName(), probe3);
208 connected = probe3->TraceConnect(
"Output",
209 "/Names/Probes/StaticallyAccessedProbe/Output",
211 NS_ASSERT_MSG(connected,
"Trace source not connected to probe3 Output");
217 Simulator::Stop(
Seconds(100.0));
219 Simulator::Destroy();
This is our test object, an object that increments counters at various times and emits one of them as...
void DoInitialize() override
Initialize() implementation.
static TypeId GetTypeId()
Register this type.
void Emit()
Generate data - actually this function is not traced.
TracedValue< double > m_counter
Sample counter, normally this would be integer type.
void Count()
Counts how many times this function is called.
Ptr< ExponentialRandomVariable > m_var
Random number generator.
Parse command-line arguments.
double GetValue(double mean, double bound)
Get the next random value, as a double from the exponential distribution with the specified mean and ...
A base class which provides memory management and object aggregation.
void Initialize()
Invoke DoInitialize on all Objects aggregated to this one.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void NotifyViaProbe(std::string context, double oldVal, double newVal)
This is a function to test hooking it to the probe output.
void NotifyViaTraceSource(std::string context, double oldVal, double newVal)
This is a function to test hooking a raw function to the trace source,.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...