From d692e338d47e995efcac47fd4108b0d5c77200cd Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 27 Jun 2013 19:36:47 -0400 Subject: [PATCH] Extend Team's listener interface. Add hooks for sending and listening for console output events. --- src/apps/debugger/model/Team.cpp | 32 ++++++++++++++++++++++++++++++++ src/apps/debugger/model/Team.h | 26 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/src/apps/debugger/model/Team.cpp b/src/apps/debugger/model/Team.cpp index af38083a0d..016da1c742 100644 --- a/src/apps/debugger/model/Team.cpp +++ b/src/apps/debugger/model/Team.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -613,6 +614,18 @@ Team::NotifyImageDebugInfoChanged(Image* image) } +void +Team::NotifyConsoleOutputReceived(int32 fd, const BString& output) +{ + for (ListenerList::Iterator it = fListeners.GetIterator(); + Listener* listener = it.Next();) { + listener->ConsoleOutputReceived( + ConsoleOutputEvent(TEAM_EVENT_CONSOLE_OUTPUT_RECEIVED, this, + fd, output)); + } +} + + void Team::NotifyUserBreakpointChanged(UserBreakpoint* breakpoint) { @@ -731,6 +744,19 @@ Team::BreakpointEvent::BreakpointEvent(uint32 type, Team* team, } +// #pragma mark - ConsoleOutputEvent + + +Team::ConsoleOutputEvent::ConsoleOutputEvent(uint32 type, Team* team, + int32 fd, const BString& output) + : + Event(type, team), + fDescriptor(fd), + fOutput(output) +{ +} + + // #pragma mark - DebugReportEvent @@ -823,6 +849,12 @@ Team::Listener::ImageDebugInfoChanged(const Team::ImageEvent& event) } +void +Team::Listener::ConsoleOutputReceived(const Team::ConsoleOutputEvent& event) +{ +} + + void Team::Listener::BreakpointAdded(const Team::BreakpointEvent& event) { diff --git a/src/apps/debugger/model/Team.h b/src/apps/debugger/model/Team.h index 4b89c02c21..98a2fb2c18 100644 --- a/src/apps/debugger/model/Team.h +++ b/src/apps/debugger/model/Team.h @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef TEAM_H @@ -32,6 +33,8 @@ enum { TEAM_EVENT_IMAGE_DEBUG_INFO_CHANGED, + TEAM_EVENT_CONSOLE_OUTPUT_RECEIVED, + TEAM_EVENT_BREAKPOINT_ADDED, TEAM_EVENT_BREAKPOINT_REMOVED, TEAM_EVENT_USER_BREAKPOINT_CHANGED, @@ -41,6 +44,7 @@ enum { TEAM_EVENT_WATCHPOINT_CHANGED, TEAM_EVENT_DEBUG_REPORT_CHANGED + }; @@ -63,6 +67,7 @@ class Team { public: class Event; class BreakpointEvent; + class ConsoleOutputEvent; class DebugReportEvent; class ImageEvent; class ThreadEvent; @@ -178,6 +183,10 @@ public: // service methods for Image void NotifyImageDebugInfoChanged(Image* image); + // service methods for console output + void NotifyConsoleOutputReceived( + int32 fd, const BString& output); + // breakpoint related service methods void NotifyUserBreakpointChanged( UserBreakpoint* breakpoint); @@ -268,6 +277,20 @@ protected: }; +class Team::ConsoleOutputEvent : public Event { +public: + ConsoleOutputEvent(uint32 type, Team* team, + int32 fd, const BString& output); + + int32 Descriptor() const { return fDescriptor; } + const BString& Output() const { return fOutput; } + +protected: + int32 fDescriptor; + BString fOutput; +}; + + class Team::DebugReportEvent : public Event { public: DebugReportEvent(uint32 type, Team* team, @@ -323,6 +346,9 @@ public: virtual void ImageDebugInfoChanged( const Team::ImageEvent& event); + virtual void ConsoleOutputReceived( + const Team::ConsoleOutputEvent& event); + virtual void BreakpointAdded( const Team::BreakpointEvent& event); virtual void BreakpointRemoved(