File indexing completed on 2024-05-12 05:46:43

0001 /* This file is part of the KDE project
0002    Copyright (C) 2002 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
0003    Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org>
0004    Copyright (C) 2007 Hamish Rodda <rodda@kde.org>
0005 
0006    This library is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU Library General Public
0008    License as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 
0011    This library is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.
0018    If not, see <http://www.gnu.org/licenses/>.
0019 */
0020 
0021 #ifndef KDEVPLATFORM_BREAKPOINT_H
0022 #define KDEVPLATFORM_BREAKPOINT_H
0023 
0024 #include <QSet>
0025 #include <QUrl>
0026 
0027 #include <debugger/debuggerexport.h>
0028 
0029 class QVariant;
0030 class KConfigGroup;
0031 namespace KTextEditor {
0032 class MovingCursor;
0033 }
0034 namespace KDevelop
0035 {
0036 class BreakpointModel;
0037 
0038 class KDEVPLATFORMDEBUGGER_EXPORT Breakpoint
0039 {
0040 public:
0041     enum BreakpointKind {
0042         CodeBreakpoint = 0,
0043         WriteBreakpoint,
0044         ReadBreakpoint,
0045         AccessBreakpoint,
0046         LastBreakpointKind
0047     };
0048     enum BreakpointState {
0049         NotStartedState,
0050         DirtyState,
0051         PendingState,
0052         CleanState
0053     };
0054     ///Custom roles for retrieving data from breakpoint model.
0055     enum BreakpointRole{
0056         LocationRole = Qt::UserRole + 1 ///< Retrieves breakpoint's full path unlike Qt::DisplayRole. Note: it's only appliable to LocationColumn.
0057     };
0058 
0059     Breakpoint(BreakpointModel *model, BreakpointKind kind);
0060     Breakpoint(BreakpointModel *model, const KConfigGroup& config);
0061 
0062     bool setData(int index, const QVariant& value);
0063     void setDeleted();
0064 
0065     ///Note: to retrieve the full path use LocationRole, Qt::DisplayRole return only a file's name
0066     QVariant data(int column, int role) const;
0067 
0068     void save(KConfigGroup& config);
0069 
0070     // Moved to BreakpointModel; temporarily left here to ease API transition
0071     enum Column {
0072         EnableColumn,
0073         StateColumn,
0074         TypeColumn,
0075         LocationColumn,
0076         ConditionColumn,
0077         HitCountColumn,
0078         IgnoreHitsColumn
0079     };
0080 
0081     void setUrl(const QUrl &url);
0082     QUrl url() const;
0083     
0084     void setLine(int line);
0085     int line() const;
0086     
0087     void setLocation(const QUrl& url, int line);
0088     QString location();
0089 
0090     BreakpointKind kind() const;
0091 
0092     void setAddress(const QString& address);
0093     QString address() const;
0094 
0095     int hitCount() const;
0096 
0097     bool deleted() const;
0098     
0099     bool enabled() const;
0100     
0101     void setMovingCursor(KTextEditor::MovingCursor *cursor);
0102     KTextEditor::MovingCursor *movingCursor() const;
0103 
0104     void setIgnoreHits(int c);
0105     int ignoreHits() const;
0106 
0107     void setCondition(const QString &c);
0108     QString condition() const;
0109 
0110     void setExpression(const QString &c);
0111     QString expression() const;
0112 
0113     BreakpointState state() const;
0114     QString errorText() const;
0115 
0116 protected:
0117     friend class BreakpointModel;
0118     friend class IBreakpointController;
0119     
0120     /**
0121      * Return the model this breakpoint is attached to
0122      *
0123      * @note This might be null, e.g. after the breakpoint has been marked as deleted
0124      */
0125     BreakpointModel *breakpointModel();
0126 
0127     BreakpointModel *m_model;
0128     bool m_enabled;
0129     bool m_deleted;
0130     BreakpointState m_state;
0131     BreakpointKind m_kind;
0132     /* For watchpoints, the address it is set at.  */
0133     QString m_address;
0134     QUrl m_url;
0135     int m_line;
0136     QString m_condition;
0137     KTextEditor::MovingCursor *m_movingCursor;
0138     int m_hitCount;
0139     int m_ignoreHits;
0140     QString m_expression;
0141     QString m_errorText;
0142 
0143     void reportChange(Column c);
0144 };
0145 
0146 }
0147 #endif