File indexing completed on 2024-05-05 16:41:34

0001 /*
0002     SPDX-FileCopyrightText: 2012 Sven Brauch <svenbrauch@googlemail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef VARIABLE_H
0008 #define VARIABLE_H
0009 
0010 #include <debugger/variable/variablecollection.h>
0011 
0012 namespace Python {
0013 
0014 class Variable : public KDevelop::Variable
0015 {
0016 Q_OBJECT
0017 public:
0018     Variable(KDevelop::TreeModel* model, TreeItem* parent, const QString& expression, const QString& display = "");
0019     
0020     /**
0021      * @brief Fetch this variable's value, and notify callback::callbackMethod when done.
0022      *
0023      * @param callback Object to notify. Skipped if 0. Defaults to 0.
0024      * @param callbackMethod Method to call. Skipped if 0. Defaults to 0.
0025      **/
0026     void attachMaybe(QObject* callback = nullptr, const char* callbackMethod = nullptr) override;
0027     
0028     /**
0029      * @brief Fetches children (list items, object attributes...) for this variable.
0030      * TODO: Should fetch more children, it currently simply fetches all children which is not so good
0031      * if there's 20.000 of them
0032      * This is invoked if the user clicks the "expand" icon in any variable tree view
0033      **/
0034     void fetchMoreChildren() override;
0035     
0036     QObject* m_notifyCreated;
0037     const char* m_notifyCreatedMethod;
0038 public slots:
0039     /**
0040      * @brief Parse the debugger output and update this variable's value.
0041      **/
0042     void dataFetched(QByteArray rawData);
0043     /**
0044      * @brief Parse the debugger output and add children to this variable.
0045      **/
0046     void moreChildrenFetched(QByteArray rawData);
0047     /**
0048      * @brief Set this object's python ID
0049      **/
0050     void setId(long unsigned int id);
0051 private:
0052     /// A unique ID of the python object pointed to by this variable.
0053     unsigned long int m_pythonPtr;
0054 };
0055 
0056 }
0057 
0058 #endif // VARIABLE_H