A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
time-probe.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Bucknell University
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: L. Felipe Perrone (perrone@bucknell.edu)
7 * Tiago G. Rodrigues (tgr002@bucknell.edu)
8 *
9 * Modified by: Mitch Watrous (watrous@u.washington.edu)
10 */
11
12#ifndef TIME_PROBE_H
13#define TIME_PROBE_H
14
15#include "probe.h"
16
17#include "ns3/boolean.h"
18#include "ns3/callback.h"
19#include "ns3/nstime.h"
20#include "ns3/object.h"
21#include "ns3/simulator.h"
22#include "ns3/traced-value.h"
23
24namespace ns3
25{
26
27/**
28 * \ingroup probes
29 *
30 * This class is designed to probe an underlying ns3 TraceSource exporting
31 * an ns3::Time. This probe exports a trace source "Output" of type
32 * double, in units of seconds. The Output trace source emits a value when
33 * either the trace source emits a new value, or when SetValue () is called.
34 *
35 * The current value of the probe can be polled with the GetValue ()
36 * method.
37 */
38class TimeProbe : public Probe
39{
40 public:
41 /**
42 * \brief Get the type ID.
43 * \return the object TypeId
44 */
45 static TypeId GetTypeId();
46 TimeProbe();
47 ~TimeProbe() override;
48
49 /**
50 * \return the most recent value (units of seconds)
51 */
52 double GetValue() const;
53
54 /**
55 * \param value set the traced Time to a new value
56 */
57 void SetValue(Time value);
58
59 /**
60 * \brief Set a probe value by its name in the Config system
61 *
62 * \param path Config path to access the probe
63 * \param value set the traced Time to a new value
64 */
65 static void SetValueByPath(std::string path, Time value);
66
67 /**
68 * \brief connect to a trace source attribute provided by a given object
69 *
70 * \param traceSource the name of the attribute TraceSource to connect to
71 * \param obj ns3::Object to connect to
72 * \return true if the trace source was successfully connected
73 */
74 bool ConnectByObject(std::string traceSource, Ptr<Object> obj) override;
75
76 /**
77 * \brief connect to a trace source provided by a config path
78 *
79 * \param path Config path to bind to
80 *
81 * Note, if an invalid path is provided, the probe will not be connected
82 * to anything.
83 */
84 void ConnectByPath(std::string path) override;
85
86 private:
87 /**
88 * \brief Method to connect to an underlying ns3::TraceSource of type Time
89 *
90 * \param oldData previous value of the Time
91 * \param newData new value of the Time
92 */
93 void TraceSink(Time oldData, Time newData);
94
95 TracedValue<double> m_output; //!< Output trace source.
96};
97
98} // namespace ns3
99
100#endif // TIME_PROBE_H
Base class for probes.
Definition probe.h:30
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
This class is designed to probe an underlying ns3 TraceSource exporting an ns3::Time.
Definition time-probe.h:39
static TypeId GetTypeId()
Get the type ID.
Definition time-probe.cc:29
bool ConnectByObject(std::string traceSource, Ptr< Object > obj) override
connect to a trace source attribute provided by a given object
Definition time-probe.cc:77
void SetValue(Time value)
Definition time-probe.cc:61
double GetValue() const
Definition time-probe.cc:54
TracedValue< double > m_output
Output trace source.
Definition time-probe.h:95
~TimeProbe() override
Definition time-probe.cc:48
void TraceSink(Time oldData, Time newData)
Method to connect to an underlying ns3::TraceSource of type Time.
Definition time-probe.cc:96
void ConnectByPath(std::string path) override
connect to a trace source provided by a config path
Definition time-probe.cc:88
static void SetValueByPath(std::string path, Time value)
Set a probe value by its name in the Config system.
Definition time-probe.cc:68
Trace classes with value semantics.
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.