A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uinteger-16-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_16_PROBE_H
13#define UINTEGER_16_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 uint16_t. This probe exports a trace source "Output" of type uint16_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 Uinteger16Probe : public Probe
34{
35 public:
36 /**
37 * \brief Get the type ID.
38 * \return the object TypeId
39 */
40 static TypeId GetTypeId();
42 ~Uinteger16Probe() override;
43
44 /**
45 * \return the most recent value
46 */
47 uint16_t GetValue() const;
48
49 /**
50 * \param value set the traced uint16_t to a new value
51 */
52 void SetValue(uint16_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 uint16_t to a new value
59 */
60 static void SetValueByPath(std::string path, uint16_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 uint16_t
84 *
85 * \param oldData previous value of the uint16_t
86 * \param newData new value of the uint16_t
87 */
88 void TraceSink(uint16_t oldData, uint16_t newData);
89
90 TracedValue<uint16_t> m_output; //!< Output trace source.
91};
92
93} // namespace ns3
94
95#endif // UINTEGER_16_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 uint16_t.
void TraceSink(uint16_t oldData, uint16_t newData)
Method to connect to an underlying ns3::TraceSource of type uint16_t.
TracedValue< uint16_t > m_output
Output trace source.
static void SetValueByPath(std::string path, uint16_t value)
Set a probe value by its name in the Config system.
bool ConnectByObject(std::string traceSource, Ptr< Object > obj) override
connect to a trace source attribute provided by a given object
void ConnectByPath(std::string path) override
connect to a trace source provided by a config path
void SetValue(uint16_t value)
static TypeId GetTypeId()
Get the type ID.
uint16_t GetValue() const
Every class exported by the ns3 library is enclosed in the ns3 namespace.