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

0001 /*
0002     SPDX-FileCopyrightText: 2009 Niko Sams <niko.sams@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KDEVPLATFORM_IVARIABLECONTROLLER_H
0008 #define KDEVPLATFORM_IVARIABLECONTROLLER_H
0009 
0010 #include <QObject>
0011 
0012 #include "idebugsession.h"
0013 
0014 namespace KTextEditor {
0015 class Document;
0016 class Cursor;
0017 class Range;
0018 }
0019 
0020 namespace KDevelop {
0021 
0022 class VariableCollection;
0023 class Variable;
0024 class TreeModel;
0025 class TreeItem;
0026 class IVariableControllerPrivate;
0027 
0028 class KDEVPLATFORMDEBUGGER_EXPORT IVariableController : public QObject
0029 {
0030     Q_OBJECT
0031 public:
0032     explicit IVariableController(IDebugSession* parent);
0033     ~IVariableController() override;
0034 
0035     /* Create a variable for the specified expression in the current
0036        thread and frame.  */     
0037     virtual Variable* createVariable(TreeModel* model, TreeItem* parent, 
0038                                      const QString& expression,
0039                                      const QString& display = {}) = 0;
0040 
0041     virtual KTextEditor::Range expressionRangeUnderCursor(KTextEditor::Document* doc, const KTextEditor::Cursor& cursor) = 0;
0042 
0043     virtual void addWatch(Variable* variable) = 0;
0044     virtual void addWatchpoint(Variable* variable) = 0;
0045 
0046     enum UpdateType {
0047         UpdateNone    = 0x0,
0048         UpdateLocals  = 0x1,
0049         UpdateWatches = 0x2
0050     };
0051     Q_DECLARE_FLAGS(UpdateTypes, UpdateType)
0052     void setAutoUpdate(QFlags<UpdateType> autoUpdate);
0053     QFlags<UpdateType> autoUpdate();
0054 
0055 protected:
0056     /**
0057      * Convenience function that returns the VariableCollection
0058      **/
0059     VariableCollection *variableCollection();
0060 
0061     /**
0062      * Convenience function that returns the used DebugSession
0063      **/
0064     IDebugSession *session() const;
0065 
0066     virtual void update() = 0;
0067 
0068     virtual void handleEvent(IDebugSession::event_t event);
0069     friend class IDebugSession;
0070 
0071 private Q_SLOTS:
0072     void stateChanged(KDevelop::IDebugSession::DebuggerState);
0073 
0074 private:
0075     void updateIfFrameOrThreadChanged();
0076 
0077 private:
0078     const QScopedPointer<class IVariableControllerPrivate> d_ptr;
0079     Q_DECLARE_PRIVATE(IVariableController)
0080 };
0081 
0082 Q_DECLARE_OPERATORS_FOR_FLAGS(IVariableController::UpdateTypes)
0083 } // namespace KDevelop
0084 
0085 #endif