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