~aleteoryx/muditaos

ref: 3fd296c50def4440e2aff28214bd3c51c0bbc9ac muditaos/module-apps/GuiTimer.hpp -rw-r--r-- 1.6 KiB
3fd296c5 — Tomasz Langowski [EGD-5845] Fix broken harness messages tests 4 years ago
                                                                                
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
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "Service/Timer.hpp"             // for Timer
#include <module-gui/gui/core/Timer.hpp> // for ms, Timer
#include <string>                        // for string

namespace app
{
    class Application;
} // namespace app
namespace gui
{
    class Item;
} // namespace gui

namespace app
{

    class Application;

    /// proxies system Timer capabilities to gui::Timer and disconnects dependencies
    /// by default one time run
    class GuiTimer : public gui::Timer, protected sys::Timer
    {
      public:
        /// gui timer default named GUI, infinite timeout on start
        explicit GuiTimer(Application *parent);
        /// gui timer with user name, infinite timeout on start
        GuiTimer(const std::string &name,
                 Application *parent,
                 gui::ms timeout       = sys::Timer::timeout_infinite,
                 gui::Timer::Type type = gui::Timer::Single);
        /// there is no valid reason to create timer without app
        GuiTimer() = delete;

        /// @defgroup interface
        /// @ {
        void start() override;
        void stop() override;
        void reset() override;
        void setInterval(gui::ms time) override;
        /// @ }

        /// interface to trigger timing callback
        class Sysapi
        {
            friend Application;
            GuiTimer &parent;
            void connect(gui::Item *item);

          public:
            Sysapi(GuiTimer &parent) : parent(parent)
            {}
        } sysapi;
    };
}; // namespace app