[Go to site: main page, start]

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
12
14#include "lldb/API/SBEvent.h"
15#include "lldb/API/SBListener.h"
16
17using namespace lldb;
18using namespace lldb_private;
19
21
23 : m_opaque_sp(new Broadcaster(nullptr, name)) {
24 LLDB_INSTRUMENT_VA(this, name);
25
27}
28
30 : m_opaque_sp(owns ? broadcaster : nullptr), m_opaque_ptr(broadcaster) {}
31
36
38 LLDB_INSTRUMENT_VA(this, rhs);
39
40 if (this != &rhs) {
43 }
44 return *this;
45}
46
48
49void SBBroadcaster::BroadcastEventByType(uint32_t event_type, bool unique) {
50 LLDB_INSTRUMENT_VA(this, event_type, unique);
51
52 if (m_opaque_ptr == nullptr)
53 return;
54
55 if (unique)
56 m_opaque_ptr->BroadcastEventIfUnique(event_type);
57 else
58 m_opaque_ptr->BroadcastEvent(event_type);
59}
60
61void SBBroadcaster::BroadcastEvent(const SBEvent &event, bool unique) {
62 LLDB_INSTRUMENT_VA(this, event, unique);
63
64 if (m_opaque_ptr == nullptr)
65 return;
66
67 EventSP event_sp = event.GetSP();
68 if (unique)
69 m_opaque_ptr->BroadcastEventIfUnique(event_sp);
70 else
71 m_opaque_ptr->BroadcastEvent(event_sp);
72}
73
75 uint32_t requested_events) {
76 LLDB_INSTRUMENT_VA(this, listener, requested_events);
77
78 if (m_opaque_ptr)
79 m_opaque_ptr->AddInitialEventsToListener(listener.m_opaque_sp,
80 requested_events);
81}
82
83uint32_t SBBroadcaster::AddListener(const SBListener &listener,
84 uint32_t event_mask) {
85 LLDB_INSTRUMENT_VA(this, listener, event_mask);
86
87 if (m_opaque_ptr)
88 return m_opaque_ptr->AddListener(listener.m_opaque_sp, event_mask);
89 return 0;
90}
91
92const char *SBBroadcaster::GetName() const {
94
95 if (m_opaque_ptr)
96 return ConstString(m_opaque_ptr->GetBroadcasterName()).GetCString();
97 return nullptr;
98}
99
100bool SBBroadcaster::EventTypeHasListeners(uint32_t event_type) {
101 LLDB_INSTRUMENT_VA(this, event_type);
102
103 if (m_opaque_ptr)
104 return m_opaque_ptr->EventTypeHasListeners(event_type);
105 return false;
106}
107
109 uint32_t event_mask) {
110 LLDB_INSTRUMENT_VA(this, listener, event_mask);
111
112 if (m_opaque_ptr)
113 return m_opaque_ptr->RemoveListener(listener.m_opaque_sp, event_mask);
114 return false;
115}
116
118
119void SBBroadcaster::reset(Broadcaster *broadcaster, bool owns) {
120 if (owns)
121 m_opaque_sp.reset(broadcaster);
122 else
123 m_opaque_sp.reset();
124 m_opaque_ptr = broadcaster;
125}
126
128 LLDB_INSTRUMENT_VA(this);
129 return this->operator bool();
130}
131SBBroadcaster::operator bool() const {
132 LLDB_INSTRUMENT_VA(this);
133
134 return m_opaque_ptr != nullptr;
135}
136
138 LLDB_INSTRUMENT_VA(this);
139
140 m_opaque_sp.reset();
141 m_opaque_ptr = nullptr;
142}
143
145 LLDB_INSTRUMENT_VA(this, rhs);
146
147 return m_opaque_ptr == rhs.m_opaque_ptr;
148}
149
151 LLDB_INSTRUMENT_VA(this, rhs);
152
153 return m_opaque_ptr != rhs.m_opaque_ptr;
154}
155
157 LLDB_INSTRUMENT_VA(this, rhs);
158
159 return m_opaque_ptr < rhs.m_opaque_ptr;
160}
#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
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)
friend class SBListener
friend class SBEvent
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
lldb::ListenerSP m_opaque_sp
Definition SBListener.h:102
An event broadcasting class.
A uniqued constant string class.
Definition ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Event > EventSP