~aleteoryx/muditaos

muditaos/module-apps/apps-common/DOMResponder.hpp -rw-r--r-- 1.2 KiB
a405cad6Aleteoryx trim readme 6 days 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
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#pragma once

#include <service-desktop/DesktopEvent.hpp>
#include <Service/MessageForward.hpp>
#include <string>

namespace gui
{
    class Item;
}

namespace sdesktop::developerMode
{
    class Event;
}

namespace app
{
    /// This class essentially hides implementation of: ServiceDesktop mechanics and DOM serialization from Application
    /// gets event data
    /// creates DOM and enapsulates in it event data
    /// builds response to be used with ServiceDesktop response type
    class DOMResponder
    {
        std::string name;
        gui::Item &item;
        std::unique_ptr<sdesktop::Event> event;
        /// uses gui::Item serializer to create DOM dump
        void createDOM();

      public:
        DOMResponder(const std::string &, gui::Item &, std::unique_ptr<sdesktop::Event> event);
        /// creates response used to inform ServiceDesktop with DOM dump encapsulated
        /// requires use of createDOM first
        [[nodiscard]] auto build() -> std::shared_ptr<sys::Message>;
    };

}; // namespace app