1 //===-- Event.h -------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_Event_h_
11 #define liblldb_Event_h_
18 // Other libraries and framework includes
20 #include "lldb/lldb-private.h"
21 #include "lldb/Core/ConstString.h"
22 #include "lldb/Host/Predicate.h"
24 namespace lldb_private {
26 //----------------------------------------------------------------------
28 //----------------------------------------------------------------------
39 virtual const ConstString &
40 GetFlavor () const = 0;
43 Dump (Stream *s) const;
47 DoOnRemoval (Event *event_ptr)
51 DISALLOW_COPY_AND_ASSIGN (EventData);
55 //----------------------------------------------------------------------
56 // lldb::EventDataBytes
57 //----------------------------------------------------------------------
58 class EventDataBytes : public EventData
61 //------------------------------------------------------------------
63 //------------------------------------------------------------------
66 EventDataBytes (const char *cstr);
68 EventDataBytes (const void *src, size_t src_len);
73 //------------------------------------------------------------------
75 //------------------------------------------------------------------
76 virtual const ConstString &
80 Dump (Stream *s) const;
89 SetBytes (const void *src, size_t src_len);
92 SwapBytes (std::string &new_bytes);
95 SetBytesFromCString (const char *cstr);
97 //------------------------------------------------------------------
99 //------------------------------------------------------------------
100 static const EventDataBytes *
101 GetEventDataFromEvent (const Event *event_ptr);
104 GetBytesFromEvent (const Event *event_ptr);
107 GetByteSizeFromEvent (const Event *event_ptr);
109 static const ConstString &
115 DISALLOW_COPY_AND_ASSIGN (EventDataBytes);
119 //----------------------------------------------------------------------
121 //----------------------------------------------------------------------
124 friend class Broadcaster;
125 friend class Listener;
126 friend class EventData;
130 Event (Broadcaster *broadcaster, uint32_t event_type, EventData *data = NULL);
132 Event (uint32_t event_type, EventData *data = NULL);
137 Dump (Stream *s) const;
142 return m_data_ap.get();
148 return m_data_ap.get();
152 SetData (EventData *new_data)
154 m_data_ap.reset (new_data);
164 SetType (uint32_t new_type)
170 GetBroadcaster () const
172 return m_broadcaster;
176 BroadcasterIs (Broadcaster *broadcaster)
178 return broadcaster == m_broadcaster;
189 // This is only called by Listener when it pops an event off the queue for
190 // the listener. It calls the Event Data's DoOnRemoval() method, which is
191 // virtual and can be overridden by the specific data classes.
196 // Called by Broadcaster::BroadcastEvent prior to letting all the listeners
197 // know about it update the contained broadcaster so that events can be
198 // popped off one queue and re-broadcast to others.
200 SetBroadcaster (Broadcaster *broadcaster)
202 m_broadcaster = broadcaster;
206 Broadcaster * m_broadcaster; // The broadcaster that sent this event
207 uint32_t m_type; // The bit describing this event
208 std::unique_ptr<EventData> m_data_ap; // User specific data for this event
211 DISALLOW_COPY_AND_ASSIGN (Event);
212 Event(); // Disallow default constructor
215 } // namespace lldb_private
217 #endif // liblldb_Event_h_