~aleteoryx/muditaos

ref: bc4d32c7d8717eebd9e2eb7b1e91ac535eb363e9 muditaos/module-sys/Service/BusProxy.cpp -rw-r--r-- 1.5 KiB
bc4d32c7 — Piotr Tański [EGD-5158] Change access to the bus methods 5 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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "BusProxy.hpp"

#include "details/bus/Bus.hpp"

namespace sys
{
    BusProxy::BusProxy(Service *owner) : owner{owner}, busImpl{std::make_unique<Bus>()}
    {
        channels.push_back(BusChannel::System); // Mandatory for each service.
    }

    BusProxy::~BusProxy() noexcept = default;

    bool BusProxy::sendUnicast(std::shared_ptr<Message> message, const std::string &targetName)
    {
        return busImpl->SendUnicast(std::move(message), targetName, owner);
    }

    SendResult BusProxy::sendUnicast(std::shared_ptr<Message> message, const std::string &targetName, uint32_t timeout)
    {
        return busImpl->SendUnicast(std::move(message), targetName, owner, timeout);
    }

    void BusProxy::sendMulticast(std::shared_ptr<Message> message, BusChannel channel)
    {
        busImpl->SendMulticast(std::move(message), channel, owner);
    }

    void BusProxy::sendBroadcast(std::shared_ptr<Message> message)
    {
        busImpl->SendBroadcast(std::move(message), owner);
    }

    void BusProxy::sendResponse(std::shared_ptr<Message> response, std::shared_ptr<Message> request)
    {
        busImpl->SendResponse(std::move(response), std::move(request), owner);
    }

    void BusProxy::connect()
    {
        Bus::Add(owner);
    }

    void BusProxy::disconnect()
    {
        Bus::Remove(owner);
    }
} // namespace sys