Nebula
Loading...
Searching...
No Matches
filter.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
9//------------------------------------------------------------------------------
10#include "category.h"
11#include "dataset.h"
12
13namespace Game
14{
15
16//------------------------------------------------------------------------------
24
26typedef uint32_t Filter;
27
30
31void DestroyFilter(Filter filter);
32
43
45{
46public:
52
53public:
55
56 template<typename ... TYPES>
58 FilterBuilder& Including(std::initializer_list<ComponentRequest>);
59
60 // Get current count in inclusive set
61 uint8_t GetNumInclusive();
62
63 template<typename ... TYPES>
65 FilterBuilder& Excluding(std::initializer_list<ComponentId>);
66 Filter Build();
67
83
85
86private:
88
89 template<class TYPE>
90 void SetInclusive(size_t const i)
91 {
92 using UnqualifiedType = typename std::remove_const<typename std::remove_reference<TYPE>::type>::type;
93
94 int offset = info.numInclusive++;
96
98 info.access[offset] = std::is_const<typename std::remove_reference<TYPE>::type>() ? Game::AccessMode::READ : Game::AccessMode::WRITE;
99 }
100
101 template<typename ... TYPES, std::size_t...Is>
102 void UnrollInclusiveComponents(std::index_sequence<Is...>)
103 {
104 (SetInclusive<typename std::tuple_element<Is, std::tuple<TYPES...>>::type>(Is), ...);
105 }
106
107 template<class TYPE>
108 void SetExclusive(size_t const i)
109 {
110 using UnqualifiedType = typename std::remove_const<typename std::remove_reference<TYPE>::type>::type;
111 int offset = info.numExclusive++;
114 }
115
116 template<typename ... TYPES, std::size_t...Is>
117 void UnrollExclusiveComponents(std::index_sequence<Is...>)
118 {
119 (SetExclusive<typename std::tuple_element<Is, std::tuple<TYPES...>>::type>(Is), ...);
120 }
121};
122
123//------------------------------------------------------------------------------
126template<typename ... TYPES>
127inline FilterBuilder&
129{
130 UnrollInclusiveComponents<TYPES...>(std::make_index_sequence<sizeof...(TYPES)>());
131 return *this;
132}
133
134//------------------------------------------------------------------------------
137template<typename ... TYPES>
138inline FilterBuilder&
140{
141 UnrollExclusiveComponents<TYPES...>(std::make_index_sequence<sizeof...(TYPES)>());
142 return *this;
143}
144
145//------------------------------------------------------------------------------
148inline uint8_t
153
154} // namespace Game
typename std::remove_const< typename std::remove_reference< T >::type >::type UnqualifiedType
Removes const reference from T.
Definition message.h:61
Definition filter.h:45
void UnrollExclusiveComponents(std::index_sequence< Is... >)
Definition filter.h:117
uint8_t GetNumInclusive()
Definition filter.h:149
static Filter CreateFilter(FilterCreateInfo)
Definition filter.cc:125
Filter Build()
Definition filter.cc:116
FilterCreateInfo info
Definition filter.h:87
void SetExclusive(size_t const i)
Definition filter.h:108
void UnrollInclusiveComponents(std::index_sequence< Is... >)
Definition filter.h:102
FilterBuilder()
Definition filter.cc:75
FilterBuilder & Excluding()
Definition filter.h:139
void SetInclusive(size_t const i)
Definition filter.h:90
FilterBuilder & Including()
Definition filter.h:128
Basically a bitfield with packed ComponentIds.
Definition tablesignature.h:26
Implements a fixed size one-dimensional array.
Definition fixedarray.h:20
#define n_assert(exp)
Definition debug.h:50
Game::EditorState.
Definition orientation.h:7
uint32_t Filter
Opaque filter identifier.
Definition filter.h:26
MemDb::TableSignature InclusiveTableMask
Definition filter.h:28
AccessMode
Definition filter.h:20
@ WRITE
Definition filter.h:22
@ READ
Definition filter.h:21
Util::FixedArray< ComponentId > const & ComponentsInFilter(Filter filter)
retrieve the inclusive component array
Definition filter.cc:49
MemDb::TableSignature ExclusiveTableMask
Definition filter.h:29
ComponentId GetComponentId()
Returns a component id, based on template type.
Definition component.h:120
InclusiveTableMask const & GetInclusiveTableMask(Filter filter)
retrieve the inclusive table mask
Definition filter.cc:31
ExclusiveTableMask const & GetExclusiveTableMask(Filter filter)
retrieve the exclusive table mask
Definition filter.cc:40
void DestroyFilter(Filter)
Destroy a filter.
Definition filter.cc:22
Util::FixedArray< ComponentId > const & ExcludedComponentsInFilter(Filter filter)
retrieve the excluded component array
Definition filter.cc:67
Util::FixedArray< AccessMode > const & AccessModesInFilter(Filter filter)
retrieve the inclusive access mode array
Definition filter.cc:58
static const uint32_t MAX_COMPONENT_BUFFERS
Definition dataset.h:24
AccessMode access
Definition filter.h:49
ComponentId id
Definition filter.h:50
AccessMode access[Dataset::MAX_COMPONENT_BUFFERS]
how we intend to access the components
Definition filter.h:77
uint8_t numInclusive
number of components in the inclusive set
Definition filter.h:73
static const uint32_t MAX_EXCLUSIVE_COMPONENTS
Definition filter.h:70
uint8_t numExclusive
number of components in the exclusive set
Definition filter.h:79
ComponentId inclusive[Dataset::MAX_COMPONENT_BUFFERS]
inclusive set
Definition filter.h:75
ComponentId exclusive[MAX_EXCLUSIVE_COMPONENTS]
exclusive set
Definition filter.h:81
Definition attributeid.h:19