File indexing completed on 2024-05-12 04:37:36

0001 /*
0002     SPDX-FileCopyrightText: 2002 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
0003     SPDX-FileCopyrightText: 2002 John Firebaugh <jfirebaugh@kde.org>
0004     SPDX-FileCopyrightText: 2007 Hamish Rodda <rodda@kde.org>
0005     SPDX-FileCopyrightText: 2009 Niko Sams <niko.sams@gmail.com>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 #ifndef KDEVPLATFORM_IBREAKPOINTCONTROLLER_H
0011 #define KDEVPLATFORM_IBREAKPOINTCONTROLLER_H
0012 
0013 #include <QObject>
0014 #include <QMap>
0015 #include <QSet>
0016 
0017 #include <debugger/debuggerexport.h>
0018 
0019 #include "idebugsession.h"
0020 #include "../breakpoint/breakpoint.h"
0021 #include "../breakpoint/breakpointmodel.h"
0022 
0023 namespace KDevelop {
0024 class IDebugSession;
0025 
0026 class KDEVPLATFORMDEBUGGER_EXPORT IBreakpointController : public QObject
0027 {
0028     Q_OBJECT
0029 public:
0030     explicit IBreakpointController(IDebugSession* parent);
0031 
0032     /**
0033      * Called just after a breakpoint is added in the given row.
0034      * The breakpoint which was previously at the given row and all later breakpoints have
0035      * been moved.
0036      *
0037      * Implementations may implement this function to maintain their internal data structures.
0038      * Note, however, that breakpoints are typically still empty (i.e. without a useful location)
0039      * when this method is called.
0040      */
0041     virtual void breakpointAdded(int row);
0042 
0043     /**
0044      * Implementors must handle changes to the breakpoint model, which are signaled via
0045      * this method, by forwarding the changes to the backend debugger.
0046      */
0047     virtual void breakpointModelChanged(int row, BreakpointModel::ColumnFlags columns);
0048 
0049     /**
0050      * Called when a breakpoint is about to be deleted from the model.
0051      */
0052     virtual void breakpointAboutToBeDeleted(int row);
0053 
0054     /**
0055      * Called when the debugger state changed.
0056      *
0057      * Note: this method exists to ease the API transition; it should probably go away eventually,
0058      * since controller implementations that do want to listen to debugger state changes probably
0059      * have better ways to do so.
0060      */
0061     virtual void debuggerStateChanged(KDevelop::IDebugSession::DebuggerState);
0062 
0063 protected:
0064     IDebugSession *debugSession() const;
0065     BreakpointModel *breakpointModel() const;
0066 
0067     void updateState(int row, Breakpoint::BreakpointState state);
0068     void updateHitCount(int row, int hitCount);
0069     void updateErrorText(int row, const QString& errorText);
0070     void notifyHit(int row, const QString & msg);
0071 
0072     // The API below is obsolete and will be removed soon
0073 protected:
0074     void breakpointStateChanged(Breakpoint* breakpoint);
0075     void setHitCount(Breakpoint* breakpoint, int count);
0076 
0077     void error(Breakpoint* breakpoint, const QString& msg, Breakpoint::Column column);
0078     void hit(Breakpoint* breakpoint, const QString& msg = QString());
0079 
0080     void sendMaybeAll();
0081     virtual void sendMaybe(Breakpoint *breakpoint) = 0;
0082 
0083     QMap<const Breakpoint*, QSet<Breakpoint::Column> > m_dirty;
0084     QSet<const Breakpoint*> m_pending;
0085     QMap<const Breakpoint*, QSet<Breakpoint::Column> > m_errors;
0086     int m_dontSendChanges;
0087 };
0088 
0089 }
0090 
0091 #endif // KDEVPLATFORM_IBREAKPOINTCONTROLLER_H