summaryrefslogtreecommitdiffstats
path: root/src/common-lib/watchdogconfiguration.h
blob: 0e440e17d95058b1792cfc69a6e2190ba9339411 (plain)
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
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef WATCHDOGCONFIGURATION_H
#define WATCHDOGCONFIGURATION_H

#include <QtCore/QString>
#include <QtCore/QVariantMap>
#include <QtCore/QDataStream>
#include <QtAppManCommon/global.h>
#include <QtAppManCommon/qtyaml.h>

QT_BEGIN_NAMESPACE_AM

class WatchdogConfiguration
{
public:
    enum Type { SystemUI, Application };

    struct {
        std::chrono::milliseconds checkInterval { -1 };
        std::chrono::milliseconds warnTimeout { -1 };
        std::chrono::milliseconds killTimeout { -1 };
    } eventloop;
    struct {
        std::chrono::milliseconds checkInterval { -1 };
        std::chrono::milliseconds warnTimeout { -1 };
        std::chrono::milliseconds killTimeout { -1 };
    } quickwindow;
    struct {
        std::chrono::milliseconds checkInterval { -1 };
        std::chrono::milliseconds warnTimeout { -1 };
        std::chrono::milliseconds killTimeout { -1 };
    } wayland;

    void merge(const WatchdogConfiguration &other);
    bool isValid(Type type) const;

    QVariantMap toMap(Type type) const;
    static WatchdogConfiguration fromMap(const QVariantMap &map, Type type);
    static WatchdogConfiguration fromYaml(YamlParser &yp, Type type);

    WatchdogConfiguration() = default;
    WatchdogConfiguration(const WatchdogConfiguration &copy) = default;
    WatchdogConfiguration &operator=(const WatchdogConfiguration &other) = default;

    bool operator==(const WatchdogConfiguration &other) const;
    bool operator!=(const WatchdogConfiguration &other) const;
};

QDataStream &operator<<(QDataStream &ds, const WatchdogConfiguration &cfg);
QDataStream &operator>>(QDataStream &ds, WatchdogConfiguration &cfg);

QT_END_NAMESPACE_AM

#endif // WATCHDOGCONFIGURATION_H