27 #include "ns3/core-module.h"
28 #include "ns3/double-probe.h"
45 static TypeId GetTypeId (
void);
48 void DoInitialize (
void);
67 .SetGroupName (
"Stats")
69 .AddTraceSource (
"Counter",
72 "ns3::TracedValueCallback::Double")
81 m_var = CreateObject<ExponentialRandomVariable> ();
114 NS_LOG_DEBUG (
"context: " << context <<
" old " << oldVal <<
" new " << newVal);
121 NS_LOG_DEBUG (
"context: " << context <<
" old " << oldVal <<
" new " << newVal);
124 int main (
int argc,
char *argv[])
127 cmd.Parse (argc, argv);
152 probe1->SetName (
"ObjectProbe");
155 connected = probe1->ConnectByObject (
"Counter", emitter);
156 NS_ASSERT_MSG (connected,
"Trace source not connected to probe1");
162 NS_ASSERT_MSG (connected,
"Trace source not connected to probe1 Output");
171 probe2->SetName (
"PathProbe");
174 probe2->ConnectByPath (
"/Names/Emitter/Counter");
180 NS_ASSERT_MSG (connected,
"Trace source not connected to probe2 Output");
187 probe3->SetName (
"StaticallyAccessedProbe");
189 Names::Add (
"/Names/Probes", probe3->GetName (), probe3);
195 NS_ASSERT_MSG (connected,
"Trace source not connected to probe3 Output");
This is our test object, an object that increments counters at various times and emits one of them as...
TracedValue< double > m_counter
Sample counter, normally this would be integer type.
void Count(void)
Counts how many times this function is called.
void Emit(void)
Generate data - actually this function is not traced.
void DoInitialize(void)
Initialize() implementation.
Ptr< ExponentialRandomVariable > m_var
Random number generator.
static TypeId GetTypeId(void)
Register this type.
Parse command-line arguments.
static void SetValueByPath(std::string path, double value)
Set a probe value by its name in the Config system.
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
A base class which provides memory management and object aggregation.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Run(void)
Run the simulation.
static Time Now(void)
Return the current simulation virtual time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void NotifyViaProbe(std::string context, double oldVal, double newVal)
void NotifyViaTraceSource(std::string context, double oldVal, double newVal)
#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 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, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...