summaryrefslogtreecommitdiffhomepage
path: root/src/tile-image.hpp
blob: 7292c5f031f03e7e297a8251ec38eb8a44a9913f (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 "tile-defs.hpp"
#include <memory>

namespace floormat {

class ground_atlas;
class wall_atlas;

template<typename Atlas>
struct image_proto_
{
    std::shared_ptr<Atlas> atlas;
    variant_t variant = 0;

    bool operator==(const image_proto_<Atlas>& b) const noexcept;
    explicit operator bool() const noexcept;
};

template<typename Atlas, typename Proto>
struct image_ref_ final
{
    std::shared_ptr<Atlas>& atlas;
    variant_t& variant;

    image_ref_(std::shared_ptr<Atlas>& atlas, variant_t& variant) noexcept;
    image_ref_(const image_ref_&) noexcept;
    image_ref_& operator=(const Proto& proto) noexcept;
    operator Proto() const noexcept;
    explicit operator bool() const noexcept;
};

using tile_image_proto = image_proto_<ground_atlas>;
using tile_image_ref = image_ref_<ground_atlas, tile_image_proto>;

using wall_image_proto = image_proto_<wall_atlas>;
using wall_image_ref = image_ref_<wall_atlas, wall_image_proto>;

} // namespace floormat