summaryrefslogtreecommitdiffhomepage
path: root/loader/atlas-loader.hpp
blob: 226918f0a8cadfe7b8f4bb9cd1b2c2d36ae7f5e3 (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
#pragma once
#include "compat/defs.hpp"
#include "atlas-loader-fwd.hpp"
#include "policy.hpp"
#include <memory>

namespace floormat::loader_detail {

template<typename ATLAS, typename TRAITS>
class atlas_loader final
{
    [[fm_no_unique_address]] TRAITS t;
    atlas_storage<ATLAS, TRAITS> s;

public:
    using Traits = TRAITS;
    using Atlas = ATLAS;
    using Cell = typename TRAITS::Cell;
    using AtlasPtr = std::decay_t<decltype(t.atlas_of(std::declval<const Cell&>()))>;

    ~atlas_loader() noexcept = default;
    fm_DECLARE_DELETED_COPY_ASSIGNMENT(atlas_loader);
    fm_DECLARE_DELETED_MOVE_ASSIGNMENT(atlas_loader);

    atlas_loader(TRAITS&& traits);
    atlas_loader() requires std::is_default_constructible_v<TRAITS>;

    ArrayView<const Cell> atlas_list();
    const AtlasPtr& get_atlas(StringView name, loader_policy p);
    AtlasPtr make_atlas(StringView name, const Cell& cell);

    bool cell_exists(StringView name);
    const Cell& get_cell(StringView name);
    void register_cell(Cell&& c);

    const Cell& get_invalid_atlas();
};

} // namespace floormat::loader_detail