1 /* 2 SPDX-FileCopyrightText: 2002 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> 3 SPDX-FileCopyrightText: 2002 John Firebaugh <jfirebaugh@kde.org> 4 SPDX-FileCopyrightText: 2007 Hamish Rodda <rodda@kde.org> 5 SPDX-FileCopyrightText: 2009 Niko Sams <niko.sams@gmail.com> 6 7 SPDX-License-Identifier: LGPL-2.0-or-later 8 */ 9 10 #ifndef KDEVPLATFORM_IBREAKPOINTCONTROLLER_H 11 #define KDEVPLATFORM_IBREAKPOINTCONTROLLER_H 12 13 #include <QObject> 14 #include <QMap> 15 #include <QSet> 16 17 #include <debugger/debuggerexport.h> 18 19 #include "idebugsession.h" 20 #include "../breakpoint/breakpoint.h" 21 #include "../breakpoint/breakpointmodel.h" 22 23 namespace KDevelop { 24 class IDebugSession; 25 26 class KDEVPLATFORMDEBUGGER_EXPORT IBreakpointController : public QObject 27 { 28 Q_OBJECT 29 public: 30 explicit IBreakpointController(IDebugSession* parent); 31 32 /** 33 * Called just after a breakpoint is added in the given row. 34 * The breakpoint which was previously at the given row and all later breakpoints have 35 * been moved. 36 * 37 * Implementations may implement this function to maintain their internal data structures. 38 * Note, however, that breakpoints are typically still empty (i.e. without a useful location) 39 * when this method is called. 40 */ 41 virtual void breakpointAdded(int row); 42 43 /** 44 * Implementors must handle changes to the breakpoint model, which are signaled via 45 * this method, by forwarding the changes to the backend debugger. 46 */ 47 virtual void breakpointModelChanged(int row, BreakpointModel::ColumnFlags columns); 48 49 /** 50 * Called when a breakpoint is about to be deleted from the model. 51 */ 52 virtual void breakpointAboutToBeDeleted(int row); 53 54 /** 55 * Called when the debugger state changed. 56 * 57 * Note: this method exists to ease the API transition; it should probably go away eventually, 58 * since controller implementations that do want to listen to debugger state changes probably 59 * have better ways to do so. 60 */ 61 virtual void debuggerStateChanged(KDevelop::IDebugSession::DebuggerState); 62 63 protected: 64 IDebugSession *debugSession() const; 65 BreakpointModel *breakpointModel() const; 66 67 void updateState(int row, Breakpoint::BreakpointState state); 68 void updateHitCount(int row, int hitCount); 69 void updateErrorText(int row, const QString& errorText); 70 void notifyHit(int row, const QString & msg); 71 72 // The API below is obsolete and will be removed soon 73 protected: 74 void breakpointStateChanged(Breakpoint* breakpoint); 75 void setHitCount(Breakpoint* breakpoint, int count); 76 77 void error(Breakpoint* breakpoint, const QString& msg, Breakpoint::Column column); 78 void hit(Breakpoint* breakpoint, const QString& msg = QString()); 79 80 void sendMaybeAll(); 81 virtual void sendMaybe(Breakpoint *breakpoint) = 0; 82 83 QMap<const Breakpoint*, QSet<Breakpoint::Column> > m_dirty; 84 QSet<const Breakpoint*> m_pending; 85 QMap<const Breakpoint*, QSet<Breakpoint::Column> > m_errors; 86 int m_dontSendChanges; 87 }; 88 89 } 90 91 #endif // KDEVPLATFORM_IBREAKPOINTCONTROLLER_H 92