ECSTASY
All in the name
Loading...
Searching...
No Matches
BinaryModifier.hpp
Go to the documentation of this file.
1
11
12#ifndef ECSTASY_QUERY_MODIFIERS_BINARYMODIFIER_HPP_
13#define ECSTASY_QUERY_MODIFIERS_BINARYMODIFIER_HPP_
14
15#include "Modifier.hpp"
17
19{
33 template <typename Derived, bool AutoLock, template <typename> class DataModifier, Queryable Q1, Queryable Q2,
34 Queryable... Qs>
35 class BinaryModifier : public Modifier<AutoLock> {
36 public:
38 using Operands = util::meta::Traits<Q1, Q2, Qs...>;
41
43 // clang-format off
45 typename DataModifier<typename Q1::QueryData>::type,
46 typename DataModifier<typename Q2::QueryData>::type,
47 typename DataModifier<typename Qs::QueryData>::type...>;
48 // clang-format on
49
51 template <size_t operandId>
52 using OperandData = std::tuple_element_t<operandId, QueryData>;
53
64 BinaryModifier(Q1 &firstOperand, Q2 &secondOperand, Qs &...otherOperands)
65 : _operands(firstOperand, secondOperand, otherOperands...)
66 {
67 static_cast<Derived &>(*this).reloadMask();
68 }
69
81 [[nodiscard]] constexpr const util::BitSet &getMask() const noexcept
82 {
83 return _mask;
84 }
85
98 [[nodiscard]] QueryData getQueryData(size_t index)
99 {
100 return getQueryData(index, std::make_index_sequence<(sizeof...(Qs))>());
101 }
102
103 protected:
115 template <size_t operandId>
117 {
118 return static_cast<Derived &>(*this).template getOperandData<operandId>(index);
119 }
120
134 template <size_t... ints>
135 inline QueryData getQueryData(size_t index, [[maybe_unused]] std::integer_sequence<size_t, ints...> int_seq)
136 {
137 return {getDerivedOperandData<0>(index), getDerivedOperandData<1>(index),
138 getDerivedOperandData<ints + 2>(index)...};
139 }
140
145 };
146} // namespace ecstasy::query::modifier
147
148#endif /* !ECSTASY_QUERY_MODIFIERS_BINARYMODIFIER_HPP_ */
Contains the concepts for queryable objects.
Base class of query modifier operating on at least two queryables.
BinaryModifier(Q1 &firstOperand, Q2 &secondOperand, Qs &...otherOperands)
Construct a new binary query modifier.
Internal _operands
Tuple containing the queryables.
QueryData getQueryData(size_t index, std::integer_sequence< size_t, ints... > int_seq)
Get the query data.
OperandData< operandId > getDerivedOperandData(size_t index)
util::BitSet _mask
Mask of the queryables.
QueryData getQueryData(size_t index)
Get the operands data at the given index.
constexpr const util::BitSet & getMask() const noexcept
Get the Mask of the internal queryables.
std::tuple_element_t< operandId, QueryData > OperandData
QueryData for the given operand.
Mimics the API of std::bitset but with the dynamic properties of std::vector<bool>
Definition BitSet.hpp:35
Defines a query modifier type.
Definition Modifier.hpp:31
Type erased base class for all query modifiers.
Namespaces regrouping all the available query modifiers.
Definition And.hpp:19
typename queryable_qualifiers< Q, AutoLock >::type queryable_qualifiers_t
Alias for the queryable type with the correct qualifiers.
Empty parameter pack helper type.
Definition Traits.hpp:28