Lluvia
Object.h
Go to the documentation of this file.
1 
8 #ifndef LLUVIA_CORE_OBJECT_H_
9 #define LLUVIA_CORE_OBJECT_H_
10 
12 
13 #include <algorithm>
14 #include <array>
15 #include <cstdint>
16 #include <stdexcept>
17 #include <string>
18 #include <tuple>
19 
20 namespace ll {
21 
29 enum class ObjectType : ll::enum_t {
30  Buffer = 0,
31  Image = 1,
32  ImageView = 2
33 };
34 
35 namespace impl {
36 
42  constexpr const std::array<std::tuple<const char*, ll::ObjectType>, 3> ObjectTypeStrings {{
43  std::make_tuple("Buffer", ll::ObjectType::Buffer),
44  std::make_tuple("Image", ll::ObjectType::Image),
45  std::make_tuple("ImageView", ll::ObjectType::ImageView),
46  }};
47 
48 } // namespace impl
49 
59 template <typename T = std::string>
60 inline T objectTypeToString(ll::ObjectType&& value) noexcept
61 {
62  return impl::enumToString<ll::ObjectType, ll::impl::ObjectTypeStrings.size(), ll::impl::ObjectTypeStrings>(std::forward<ll::ObjectType>(value));
63 }
64 
80 template <typename T>
81 inline ll::ObjectType stringToObjectType(T&& stringValue)
82 {
83  return impl::stringToEnum<ll::ObjectType, T, ll::impl::ObjectTypeStrings.size(), ll::impl::ObjectTypeStrings>(std::forward<T>(stringValue));
84 }
85 
94 class Object {
95 
96 public:
103  Object() = default;
104 
112  Object(const Object&) = delete;
113 
120  Object(Object&&) = delete;
121 
122  virtual ~Object() = default;
123 
129  Object& operator=(const Object&) = delete;
130 
136  Object& operator=(Object&&) = delete;
137 
154  virtual ll::ObjectType getType() const noexcept = 0;
155 };
156 
157 } // namespace ll
158 
159 #endif // LLUVIA_CORE_OBJECT_H_
Objects to manage raw portions of allocated memory.
Definition: Buffer.h:57
Represents portions of a ll::Image to be sent as parameter to a GLSL shader.
Definition: ImageView.h:149
Objects to manage images.
Definition: Image.h:74
Base class for all types that can be used in computer shaders.
Definition: Object.h:94
Object & operator=(Object &&)=delete
Move assignment.
virtual ~Object()=default
Object & operator=(const Object &)=delete
Copy assignment.
Object()=default
Default constructor.
Object(const Object &)=delete
Copy constructor.
Object(Object &&)=delete
Move constructor.
virtual ll::ObjectType getType() const noexcept=0
Gets the object type.
Enums.
constexpr const std::array< std::tuple< const char *, ll::ObjectType >, 3 > ObjectTypeStrings
Object type string values used for converting ll::ObjectType to std::string and vice-versa.
Definition: Object.h:42
E stringToEnum(T &&stringValue)
Definition: enums.h:172
std::string enumToString(E &&value) noexcept
Definition: enums.h:146
Definition: Buffer.h:28
ObjectType
Object types.
Definition: Object.h:29
ll::ObjectType stringToObjectType(T &&stringValue)
Converts from a string-like object to ll::ObjectType enum.
Definition: Object.h:81
T objectTypeToString(ll::ObjectType &&value) noexcept
Converts from ll::ObjectType enum value to std::string.
Definition: Object.h:60
uint32_t enum_t
Definition: enums.h:23