Lluvia
DeviceType.h
Go to the documentation of this file.
1 
8 #ifndef LLUVIA_CORE_DEVICE_DEVICE_TYPE_H_
9 #define LLUVIA_CORE_DEVICE_DEVICE_TYPE_H_
10 
13 
14 namespace ll {
15 
19 enum class DeviceType : ll::enum_t {
20  Other = static_cast<ll::enum_t>(vk::PhysicalDeviceType::eOther),
21  DiscreteGPU = static_cast<ll::enum_t>(vk::PhysicalDeviceType::eDiscreteGpu),
22  IntegratedGPU = static_cast<ll::enum_t>(vk::PhysicalDeviceType::eIntegratedGpu),
23  VirtualGPU = static_cast<ll::enum_t>(vk::PhysicalDeviceType::eVirtualGpu),
24  CPU = static_cast<ll::enum_t>(vk::PhysicalDeviceType::eCpu),
25 };
26 
27 namespace impl {
28 
29  constexpr ll::DeviceType fromVkPhysicalDeviceType(const vk::PhysicalDeviceType& physicalDeviceType) noexcept
30  {
31  return ll::DeviceType {static_cast<ll::enum_t>(physicalDeviceType)};
32  }
33 
39  constexpr const std::array<std::tuple<const char*, ll::DeviceType>, 5> DeviceTypeStrings {{
40  std::make_tuple("Other", ll::DeviceType::Other),
41  std::make_tuple("DiscreteGPU", ll::DeviceType::DiscreteGPU),
42  std::make_tuple("IntegratedGPU", ll::DeviceType::IntegratedGPU),
43  std::make_tuple("VirtualGPU", ll::DeviceType::VirtualGPU),
44  std::make_tuple("CPU", ll::DeviceType::CPU),
45  }};
46 
47 } // namespace impl
48 
49 template <typename T = std::string>
50 inline T deviceTypeToString(ll::DeviceType&& deviceType) noexcept
51 {
52  return impl::enumToString<ll::DeviceType, ll::impl::DeviceTypeStrings.size(), ll::impl::DeviceTypeStrings>(std::forward<ll::DeviceType>(deviceType));
53 }
54 
55 template <typename T>
56 inline ll::DeviceType stringToDeviceType(T&& stringValue)
57 {
58  return impl::stringToEnum<ll::DeviceType, T, ll::impl::DeviceTypeStrings.size(), ll::impl::DeviceTypeStrings>(std::forward<T>(stringValue));
59 }
60 
61 } // namespace ll
62 
63 #endif // LLUVIA_CORE_DEVICE_DEVICE_TYPE_H_
Enums.
constexpr const std::array< std::tuple< const char *, ll::DeviceType >, 5 > DeviceTypeStrings
Image axis strings used for converting ll::DeviceType to std::string and vice-versa.
Definition: DeviceType.h:39
constexpr ll::DeviceType fromVkPhysicalDeviceType(const vk::PhysicalDeviceType &physicalDeviceType) noexcept
Definition: DeviceType.h:29
E stringToEnum(T &&stringValue)
Definition: enums.h:172
std::string enumToString(E &&value) noexcept
Definition: enums.h:146
Definition: Buffer.h:28
ll::DeviceType stringToDeviceType(T &&stringValue)
Definition: DeviceType.h:56
DeviceType
Image axis enumeration.
Definition: DeviceType.h:19
T deviceTypeToString(ll::DeviceType &&deviceType) noexcept
Definition: DeviceType.h:50
uint32_t enum_t
Definition: enums.h:23