~aleteoryx/muditaos

ref: 46f9cc7e100b471afef4efc4449880eb480ac7fa muditaos/module-services/service-desktop/endpoints/EndpointFactory.hpp -rw-r--r-- 2.4 KiB
46f9cc7e — Lucjan Bryndza [EGD-5737] Merge master into experimental 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
52
53
54
55
56
// 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 "Endpoint.hpp"

#include "Service/Service.hpp"
#include "calendarEvents/CalendarEventsEndpoint.hpp"
#include "backup/BackupEndpoint.hpp"
#include "deviceInfo/DeviceInfoEndpoint.hpp"
#include "update/UpdateEndpoint.hpp"
#include "filesystem/FilesystemEndpoint.hpp"
#include "factoryReset/FactoryResetEndpoint.hpp"
#include "calllog/CalllogEndpoint.hpp"
#include "contacts/ContactsEndpoint.hpp"
#include "developerMode/DeveloperModeEndpoint.hpp"
#include "messages/MessagesEndpoint.hpp"
#include "restore/RestoreEndpoint.hpp"
#include "update/UpdateEndpoint.hpp"

class EndpointFactory
{
  public:
    static auto create(parserFSM::Context &context, sys::Service *ownerServicePtr)
        -> std::unique_ptr<parserFSM::Endpoint>
    {
        LOG_DEBUG("Creating endpoint: %d", static_cast<int>(context.getEndpoint()));
        switch (context.getEndpoint()) {
        case parserFSM::EndpointType::update:
            return std::make_unique<UpdateEndpoint>(ownerServicePtr);
        case parserFSM::EndpointType::filesystemUpload:
            return std::make_unique<FilesystemEndpoint>(ownerServicePtr);
        case parserFSM::EndpointType::backup:
            return std::make_unique<BackupEndpoint>(ownerServicePtr);
        case parserFSM::EndpointType::deviceInfo:
            return std::make_unique<DeviceInfoEndpoint>(ownerServicePtr);
        case parserFSM::EndpointType::restore:
            return std::make_unique<RestoreEndpoint>(ownerServicePtr);
        case parserFSM::EndpointType::contacts:
            return std::make_unique<ContactsEndpoint>(ownerServicePtr);
        case parserFSM::EndpointType::messages:
            return std::make_unique<MessagesEndpoint>(ownerServicePtr);
        case parserFSM::EndpointType::factory:
            return std::make_unique<FactoryResetEndpoint>(ownerServicePtr);
        case parserFSM::EndpointType::calllog:
            return std::make_unique<CalllogEndpoint>(ownerServicePtr);
        case parserFSM::EndpointType::developerMode:
            return std::make_unique<DeveloperModeEndpoint>(ownerServicePtr);
        case parserFSM::EndpointType::calendarEvents:
            return std::make_unique<CalendarEventsEndpoint>(ownerServicePtr);
        default:
            return nullptr;
        }
    }
};