ECSTASY
All in the name
Loading...
Searching...
No Matches
And.hpp
Go to the documentation of this file.
1
11
12#ifndef ECSTASY_QUERY_MODIFIERS_AND_HPP_
13#define ECSTASY_QUERY_MODIFIERS_AND_HPP_
14
15#include "BinaryModifier.hpp"
17
19{
33 template <bool AutoLock, Queryable Q1, Queryable Q2, Queryable... Qs>
34 class AndImpl
35 : public BinaryModifier<AndImpl<AutoLock, Q1, Q2, Qs...>, AutoLock, std::type_identity, Q1, Q2, Qs...> {
36 private:
39 BinaryModifier<AndImpl<AutoLock, Q1, Q2, Qs...>, AutoLock, std::type_identity, Q1, Q2, Qs...>;
40
41 public:
52 AndImpl(Q1 &firstOperand, Q2 &secondOperand, Qs &...otherOperands)
53 : ModifierClass(firstOperand, secondOperand, otherOperands...)
54 {
55 }
56
71 template <size_t operandId>
72 [[nodiscard]] inline typename ModifierClass::template OperandData<operandId> getOperandData(size_t index)
73 {
74 return getQueryableData(std::get<operandId>(this->_operands), index);
75 }
76
83 inline void reloadMask()
84 {
85 if constexpr (sizeof...(Qs) > 0)
87 else
88 this->_mask = ecstasy::query::getQueryableMask(std::get<0>(this->_operands))
89 & ecstasy::query::getQueryableMask(std::get<1>(this->_operands));
90 }
91
92 private:
103 template <size_t... ints>
105 {
106 this->_mask = ((util::BitSet(getQueryableMask(std::get<0>(this->_operands)))
107 & getQueryableMask(std::get<1>(this->_operands))) &= ... &=
108 getQueryableMask(std::get<ints + 2>(this->_operands)));
109 }
110 };
111
127 template <Queryable Q1, Queryable Q2, Queryable... Qs>
128 [[nodiscard]] auto constexpr And(Q1 &firstOperand, Q2 &secondOperand, Qs &...otherOperands)
129 {
130 return AndImpl<false, Q1, Q2, Qs...>(firstOperand, secondOperand, otherOperands...);
131 }
132} // namespace ecstasy::query::modifier
133
134#endif /* !ECSTASY_QUERY_MODIFIERS_AND_HPP_ */
Contains the concepts for queryable objects.
Binary query modifier which performs a and between at least two queryables.
Definition And.hpp:35
void reloadMask()
Update the mask to be up to date with the operands bitmasks.
Definition And.hpp:83
AndImpl(Q1 &firstOperand, Q2 &secondOperand, Qs &...otherOperands)
Construct a new And Queryable modifier.
Definition And.hpp:52
ModifierClass::template OperandData< operandId > getOperandData(size_t index)
Get the specified operand data at the given index.
Definition And.hpp:72
void combineOperandMasks(std::integer_sequence< size_t, ints... > int_seq)
Combine all the operands' bitmasks.
Definition And.hpp:104
Base class of query modifier operating on at least two queryables.
Mimics the API of std::bitset but with the dynamic properties of std::vector<bool>
Definition BitSet.hpp:35
Defines a type that can be queried.
Namespaces regrouping all the available query modifiers.
Definition And.hpp:19
constexpr queryable_data_t< Q > getQueryableData(Q &queryable, size_t index)
Get the query data at the given index.
constexpr const util::BitSet & getQueryableMask(const Q &queryable)
Get the mask of the queryable object.
Placeholder for And.
Definition And.hpp:31