summaryrefslogtreecommitdiff
path: root/deimos/core/api_registry.cpp
blob: aa993e06b4aa9bbe78fef7a0e96b32691cb1c23c (plain)
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
#include "deimos/core/api_registry.h"
#include "deimos/core/allocator.h"
#include "deimos/core/hash.h"

namespace deimos
{

AllocatorApi* BootstrapAllocatorApi();

struct ApiEntry
{
    const ApiEntry* next{};
    IdName name;
    void* impl;

    ApiEntry(const IdName& name, void* impl) :
        name{name}, impl{impl}
    {}
};

class ApiRegistryImpl: public ApiRegistry
{
    IAllocator* m_allocator;

public:
    explicit ApiRegistryImpl(IAllocator* allocator) :
        m_allocator{allocator}
    {}

    void Set(const IdName& name, void* impl) final
    {
    }
};

ApiRegistry* InitializeGlobalApiRegistry()
{
    AllocatorApi* allocator_api = BootstrapAllocatorApi();
    IAllocator* allocator = allocator_api->system;
    ApiRegistry* api_registry = allocator->New<ApiRegistryImpl>();

    api_registry->Set(allocator_api);

    return api_registry;
}

} // namespace deimos