File: process_data_provider.h

package info (click to toggle)
libksysguard 4%3A6.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,596 kB
  • sloc: cpp: 13,691; xml: 297; sh: 23; makefile: 11
file content (87 lines) | stat: -rw-r--r-- 2,023 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
    SPDX-FileCopyrightText: 2019 David Edmundson <davidedmundson@kde.org>

    SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once

#include <QList>
#include <QObject>
#include <QVariant>

#include "processcore_export.h"

namespace KSysGuard
{
class Processes;
class Process;
class ProcessAttribute;

/**
 * Base class for a process plugin data
 * Plugins provide a list of additional attributes, which in turn have data about a given process
 */
class PROCESSCORE_EXPORT ProcessDataProvider : public QObject
{
    Q_OBJECT

public:
    ProcessDataProvider(QObject *parent, const QVariantList &args);
    ~ProcessDataProvider() override;

    /**
     * Accessors for process information matching
     */
    KSysGuard::Processes *processes() const;

    /**
     * Returns a new process object for a given PID
     * This will update the process list if this PID does not exist yet
     * This may return a null pointer
     */
    KSysGuard::Process *getProcess(long pid);

    /**
     * A list of all process attributes provided by this plugin
     * It is expected to remain constant through the lifespan of this class
     */
    QList<ProcessAttribute *> attributes() const;

    /**
     * Called when processes should be updated if manually polled
     * Plugins can however update at any time if enabled
     */
    virtual void update()
    {
    }

    /**
     * True when at least one attribute from this plugin is subscribed
     */
    bool enabled() const;

    virtual void handleEnabledChanged(bool enabled)
    {
        Q_UNUSED(enabled)
    }

    // for any future compatibility
    virtual void virtual_hook(int id, void *data)
    {
        Q_UNUSED(id)
        Q_UNUSED(data)
    }

protected:
    /**
     * Register a new process attribute
     * Process attributes should be created in the plugin constructor and must live for the duration the plugin
     */
    void addProcessAttribute(ProcessAttribute *attribute);

private:
    class Private;
    QScopedPointer<Private> d;
};

}