MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
renderable.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <mbgl/util/size.hpp>
4 
5 #include <memory>
6 #include <cassert>
7 
8 namespace mbgl {
9 namespace gfx {
10 
12 protected:
13  explicit RenderableResource() = default;
14 
15 public:
16  virtual ~RenderableResource() = default;
19 };
20 
21 class Renderable {
22 protected:
23  Renderable(const Size size_, std::unique_ptr<RenderableResource> resource_)
24  : size(size_), resource(std::move(resource_)) {
25  }
26  virtual ~Renderable() = default;
27 
28 public:
29  Size getSize() const {
30  return size;
31  }
32 
33  template <typename T>
34  T& getResource() const {
35  assert(resource);
36  return static_cast<T&>(*resource);
37  }
38 
39  virtual void wait() {}
40 
41 protected:
43  std::unique_ptr<RenderableResource> resource;
44 };
45 
46 } // namespace gfx
47 } // namespace mbgl
virtual ~RenderableResource()=default
RenderableResource(const RenderableResource &)=delete
RenderableResource & operator=(const RenderableResource &)=delete
std::unique_ptr< RenderableResource > resource
Definition: renderable.hpp:43
virtual void wait()
Definition: renderable.hpp:39
Size getSize() const
Definition: renderable.hpp:29
T & getResource() const
Definition: renderable.hpp:34
Renderable(const Size size_, std::unique_ptr< RenderableResource > resource_)
Definition: renderable.hpp:23
virtual ~Renderable()=default
Definition: actor.hpp:15
Definition: tile_id.hpp:256