RavEngine
Loading...
Searching...
No Matches
Queryable.hpp
1#pragma once
2#include "CTTI.hpp"
3#include <array>
4#include <tuple>
5
6namespace RavEngine{
7//to_array, which converts a std::tuple into std::array
8template<typename Tuple,typename VTuple = std::remove_reference_t<Tuple>,std::size_t... Indices>
9constexpr inline std::array<std::common_type_t<std::tuple_element_t<Indices, VTuple>...>,sizeof...(Indices)>
10to_array(Tuple&& tuple, std::index_sequence<Indices...>)
11{
12 return { std::get<Indices>(std::forward<Tuple>(tuple))... };
13}
14template<typename Tuple, typename VTuple = std::remove_reference_t<Tuple>>
15constexpr inline decltype(auto) to_array(Tuple&& tuple)
16{
17 return to_array(std::forward<Tuple>(tuple),std::make_index_sequence<std::tuple_size<VTuple>::value> {} );
18}
19
20template<typename ... types>
21struct Queryable{
22 inline static constexpr std::size_t ntypes = sizeof ... (types);
23 typedef std::array<ctti_t,ntypes> arraytype;
24#define q_qt_def static const arraytype queryTypes{ CTTI<types>() ... }
25#ifndef _MSC_VER
26 constexpr q_qt_def;
27#endif
28
29 inline static constexpr const arraytype& GetQueryTypes(){
30#ifdef _MSC_VER
31 q_qt_def;
32#endif
33 return queryTypes;
34 }
35};
36
37template<class base, typename ... types>
39 inline static constexpr std::size_t ntypes = sizeof ... (types) + base::ntypes;
40 typedef std::array<ctti_t,ntypes> arraytype;
41#define qb_qt_def static const arraytype queryTypes = to_array(std::tuple_cat(std::array<ctti_t, sizeof ... (types)>{ CTTI<types>() ...}, base::GetQueryTypes()))
42#ifndef _MSC_VER
43 constexpr qb_qt_def;
44#endif
45
46 inline static constexpr const arraytype& GetQueryTypes(){
47#ifdef _MSC_VER
48 qb_qt_def;
49#endif
50 return queryTypes;
51 }
52};
53}
Definition concurrentqueue.h:747
Definition Animation.hpp:6
Definition Queryable.hpp:38
Definition Queryable.hpp:21