summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/bcat/backend/backend.h
blob: 2e9511f3f6c40d193efa75a90a3d63bf57024685 (plain) (blame)
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
// Copyright 2019 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <functional>
#include "common/common_types.h"
#include "core/file_sys/vfs_types.h"

namespace Service::BCAT {

using CompletionCallback = std::function<void(bool)>;
using DirectoryGetter = std::function<FileSys::VirtualDir(u64)>;
using Passphrase = std::array<u8, 0x20>;

struct TitleIDVersion {
    u64 title_id;
    u64 build_id;
};

class Backend {
public:
    explicit Backend(DirectoryGetter getter);
    virtual ~Backend();

    virtual bool Synchronize(TitleIDVersion title, CompletionCallback callback) = 0;
    virtual bool SynchronizeDirectory(TitleIDVersion title, std::string name,
                                      CompletionCallback callback) = 0;

    virtual bool Clear(u64 title_id) = 0;

    virtual void SetPassphrase(u64 title_id, const Passphrase& passphrase) = 0;

protected:
    DirectoryGetter dir_getter;
};

class NullBackend : public Backend {
public:
    explicit NullBackend(const DirectoryGetter& getter);
    ~NullBackend() override;

    bool Synchronize(TitleIDVersion title, CompletionCallback callback) override;
    bool SynchronizeDirectory(TitleIDVersion title, std::string name,
                              CompletionCallback callback) override;

    bool Clear(u64 title_id) override;

    void SetPassphrase(u64 title_id, const Passphrase& passphrase) override;
};

} // namespace Service::BCAT