LLDB mainline
SBBroadcaster.cpp
Go to the documentation of this file.
1//===-- SBBroadcaster.cpp -------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11
13#include "lldb/API/SBEvent.h"
14#include "lldb/API/SBListener.h"
15
16using namespace lldb;
17using namespace lldb_private;
18
20
22 : m_opaque_sp(new Broadcaster(nullptr, name)) {
23 LLDB_INSTRUMENT_VA(this, name);
24
26}
27
29 : m_opaque_sp(owns ? broadcaster : nullptr), m_opaque_ptr(broadcaster) {}
30
32 : m_opaque_sp(rhs.m_opaque_sp), m_opaque_ptr(rhs.m_opaque_ptr) {
33 LLDB_INSTRUMENT_VA(this, rhs);
34}
35
37 LLDB_INSTRUMENT_VA(this, rhs);
38
39 if (this != &rhs) {
42 }
43 return *this;
44}
45
47
48void SBBroadcaster::BroadcastEventByType(uint32_t event_type, bool unique) {
49 LLDB_INSTRUMENT_VA(this, event_type, unique);
50
51 if (m_opaque_ptr == nullptr)
52 return;
53
54 if (unique)
56 else
57 m_opaque_ptr->BroadcastEvent(event_type);
58}
59
60void SBBroadcaster::BroadcastEvent(const SBEvent &event, bool unique) {
61 LLDB_INSTRUMENT_VA(this, event, unique);
62
63 if (m_opaque_ptr == nullptr)
64 return;
65
66 EventSP event_sp = event.GetSP();
67 if (unique)
69 else
71}
72
74 uint32_t requested_events) {
75 LLDB_INSTRUMENT_VA(this, listener, requested_events);
76
77 if (m_opaque_ptr)
79 requested_events);
80}
81
83 uint32_t event_mask) {
84 LLDB_INSTRUMENT_VA(this, listener, event_mask);
85
86 if (m_opaque_ptr)
87 return m_opaque_ptr->AddListener(listener.m_opaque_sp, event_mask);
88 return 0;
89}
90
91const char *SBBroadcaster::GetName() const {
93
94 if (m_opaque_ptr)
96 return nullptr;
97}
98
100 LLDB_INSTRUMENT_VA(this, event_type);
101
102 if (m_opaque_ptr)
103 return m_opaque_ptr->EventTypeHasListeners(event_type);
104 return false;
105}
106
108 uint32_t event_mask) {
109 LLDB_INSTRUMENT_VA(this, listener, event_mask);
110
111 if (m_opaque_ptr)
112 return m_opaque_ptr->RemoveListener(listener.m_opaque_sp, event_mask);
113 return false;
114}
115
117
118void SBBroadcaster::reset(Broadcaster *broadcaster, bool owns) {
119 if (owns)
120 m_opaque_sp.reset(broadcaster);
121 else
122 m_opaque_sp.reset();
123 m_opaque_ptr = broadcaster;
124}
125
127 LLDB_INSTRUMENT_VA(this);
128 return this->operator bool();
129}
130SBBroadcaster::operator bool() const {
131 LLDB_INSTRUMENT_VA(this);
132
133 return m_opaque_ptr != nullptr;
134}
135
137 LLDB_INSTRUMENT_VA(this);
138
139 m_opaque_sp.reset();
140 m_opaque_ptr = nullptr;
141}
142
144 LLDB_INSTRUMENT_VA(this, rhs);
145
146 return m_opaque_ptr == rhs.m_opaque_ptr;
147}
148
150 LLDB_INSTRUMENT_VA(this, rhs);
151
152 return m_opaque_ptr != rhs.m_opaque_ptr;
153}
154
156 LLDB_INSTRUMENT_VA(this, rhs);
157
158 return m_opaque_ptr < rhs.m_opaque_ptr;
159}
#define LLDB_INSTRUMENT_VA(...)
bool RemoveListener(const lldb::SBListener &listener, uint32_t event_mask=UINT32_MAX)
const char * GetName() const
void AddInitialEventsToListener(const lldb::SBListener &listener, uint32_t requested_events)
lldb_private::Broadcaster * m_opaque_ptr
Definition: SBBroadcaster.h:80
void reset(lldb_private::Broadcaster *broadcaster, bool owns)
bool operator!=(const lldb::SBBroadcaster &rhs) const
bool operator==(const lldb::SBBroadcaster &rhs) const
const SBBroadcaster & operator=(const SBBroadcaster &rhs)
void BroadcastEventByType(uint32_t event_type, bool unique=false)
bool operator<(const lldb::SBBroadcaster &rhs) const
uint32_t AddListener(const lldb::SBListener &listener, uint32_t event_mask)
void BroadcastEvent(const lldb::SBEvent &event, bool unique=false)
bool EventTypeHasListeners(uint32_t event_type)
lldb_private::Broadcaster * get() const
lldb::BroadcasterSP m_opaque_sp
Definition: SBBroadcaster.h:79
lldb::ListenerSP m_opaque_sp
Definition: SBListener.h:102
An event broadcasting class.
Definition: Broadcaster.h:242
uint32_t AddListener(const lldb::ListenerSP &listener_sp, uint32_t event_mask)
Listen for any events specified by event_mask.
Definition: Broadcaster.h:308
bool EventTypeHasListeners(uint32_t event_type)
Definition: Broadcaster.h:345
ConstString GetBroadcasterName()
Get the NULL terminated C string name of this Broadcaster object.
Definition: Broadcaster.h:317
bool RemoveListener(const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX)
Removes a Listener from this broadcasters list and frees the event bits specified by event_mask that ...
Definition: Broadcaster.h:365
virtual void AddInitialEventsToListener(const lldb::ListenerSP &listener_sp, uint32_t requested_events)
void BroadcastEventIfUnique(lldb::EventSP &event_sp)
Definition: Broadcaster.h:266
void BroadcastEvent(lldb::EventSP &event_sp)
Broadcast an event which has no associated data.
Definition: Broadcaster.h:262
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:215
A class that represents a running process on the host machine.
Definition: SBAddress.h:15