A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uinteger-32-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 UINTEGER_32_PROBE_H
13#define UINTEGER_32_PROBE_H
14
15#include "probe.h"
16
17#include "ns3/callback.h"
18#include "ns3/traced-value.h"
19
20namespace ns3
21{
22
23/**
24 * \ingroup probes
25 *
26 * This class is designed to probe an underlying ns3 TraceSource exporting
27 * an uint32_t. This probe exports a trace source "Output" of type uint32_t.
28 * The Output trace source emits a value when either the trace source
29 * emits a new value, or when SetValue () is called.
30 *
31 * The current value of the probe can be polled with the GetValue () method.
32 */
33class Uinteger32Probe : public Probe
34{
35 public:
36 /**
37 * \brief Get the type ID.
38 * \return the object TypeId
39 */
40 static TypeId GetTypeId();
42 ~Uinteger32Probe() override;
43
44 /**
45 * \return the most recent value
46 */
47 uint32_t GetValue() const;
48
49 /**
50 * \param value set the traced uint32_t to a new value
51 */
52 void SetValue(uint32_t value);
53
54 /**
55 * \brief Set a probe value by its name in the Config system
56 *
57 * \param path Config path to access the probe
58 * \param value set the traced uint32_t to a new value
59 */
60 static void SetValueByPath(std::string path, uint32_t value);
61
62 /**
63 * \brief connect to a trace source attribute provided by a given object
64 *
65 * \param traceSource the name of the attribute TraceSource to connect to
66 * \param obj ns3::Object to connect to
67 * \return true if the trace source was successfully connected
68 */
69 bool ConnectByObject(std::string traceSource, Ptr<Object> obj) override;
70
71 /**
72 * \brief connect to a trace source provided by a config path
73 *
74 * \param path Config path to bind to
75 *
76 * Note, if an invalid path is provided, the probe will not be connected
77 * to anything.
78 */
79 void ConnectByPath(std::string path) override;
80
81 private:
82 /**
83 * \brief Method to connect to an underlying ns3::TraceSource of type uint32_t
84 *
85 * \param oldData previous value of the uint32_t
86 * \param newData new value of the uint32_t
87 */
88 void TraceSink(uint32_t oldData, uint32_t newData);
89
90 TracedValue<uint32_t> m_output; //!< Output trace source.
91};
92
93} // namespace ns3
94
95#endif // UINTEGER_32_PROBE_H
Base class for probes.
Definition probe.h:30
Smart pointer class similar to boost::intrusive_ptr.
Trace classes with value semantics.
a unique identifier for an interface.
Definition type-id.h:48
This class is designed to probe an underlying ns3 TraceSource exporting an uint32_t.
static void SetValueByPath(std::string path, uint32_t value)
Set a probe value by its name in the Config system.
void SetValue(uint32_t value)
bool ConnectByObject(std::string traceSource, Ptr< Object > obj) override
connect to a trace source attribute provided by a given object
static TypeId GetTypeId()
Get the type ID.
uint32_t GetValue() const
void TraceSink(uint32_t oldData, uint32_t newData)
Method to connect to an underlying ns3::TraceSource of type uint32_t.
TracedValue< uint32_t > m_output
Output trace source.
void ConnectByPath(std::string path) override
connect to a trace source provided by a config path
Every class exported by the ns3 library is enclosed in the ns3 namespace.